<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8439834739738122981</id><updated>2024-10-24T13:56:55.397+08:00</updated><category term="SOURCE CODE"/><category term="Qt"/><category term="MFC"/><category term="VC6"/><category term="Android"/><category term="BLOG"/><category term="Windows"/><title type='text'>if then...</title><subtitle type='html'>一位初心者阿宅的奮鬥歷程筆記...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://if2if.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://if2if.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8439834739738122981.post-2685372588736653336</id><published>2014-06-23T17:45:00.001+08:00</published><updated>2014-06-23T17:46:43.442+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="SOURCE CODE"/><title type='text'>[Android] 將resource轉換成Bitmap (transforming drawable resource into Bitmap)</title><content type='html'>&lt;pre class=&quot;codeblock prettyprint&quot;&gt; private Bitmap decodeFile(int resId) {
     try {
         // decode image size
         BitmapFactory.Options o = new BitmapFactory.Options();
         o.inJustDecodeBounds = true;
         BitmapFactory.decodeResource(context.getResources(), resId, o);
         // Find the correct scale value. It should be the power of 2.
         final int REQUIRED_SIZE = 70;
         int width_tmp = o.outWidth, height_tmp = o.outHeight;
         int scale = 1;
         while (true) {
             if (width_tmp / 2 &amp;lt; REQUIRED_SIZE
                     || height_tmp / 2 &amp;lt; REQUIRED_SIZE)
                 break;
             width_tmp /= 2;
             height_tmp /= 2;
             scale++;
         }

         // decode with inSampleSize
         BitmapFactory.Options o2 = new BitmapFactory.Options();
         o2.inSampleSize = scale;
         return BitmapFactory.decodeResource(context.getResources(), resId, o2);
     } catch (Exception e) {
     }
     return null;
 }

&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://if2if.blogspot.com/feeds/2685372588736653336/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://if2if.blogspot.com/2014/06/android-resourcebitmap-transforming.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/2685372588736653336'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/2685372588736653336'/><link rel='alternate' type='text/html' href='http://if2if.blogspot.com/2014/06/android-resourcebitmap-transforming.html' title='[Android] 將resource轉換成Bitmap (transforming drawable resource into Bitmap)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8439834739738122981.post-1860415659441964578</id><published>2013-05-23T15:58:00.000+08:00</published><updated>2013-05-23T15:58:02.348+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MFC"/><category scheme="http://www.blogger.com/atom/ns#" term="SOURCE CODE"/><category scheme="http://www.blogger.com/atom/ns#" term="VC6"/><title type='text'>[MFC] 使用自訂的Cursor</title><content type='html'>&lt;br /&gt;
&lt;br /&gt;
1.將想要加入的Cursor(.cur檔)加入專案中&lt;br /&gt;
2.在類別下的MemberData中加入一個HCURSOR類別的成員(在此使用的名稱為 m_hNoDrop)&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;   protected:
      HCURSOR m_hNoDrop;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span style=&quot;white-space: normal;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
3.在類別建構子中加入以下指令&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;   m_hNoDrop = AfxGetApp()-&amp;gt;LoadCursor( IDC_NODROP );
&lt;/pre&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 註:IDC_NODROP為欲加入的cursor ID
&lt;br /&gt;
4.在欲改變指標的區段加入&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;  SetCursor( m_hNoDrop  );&lt;span style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span style=&quot;white-space: normal;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
5.建立事件OnSetCursor：功能表中的View\MFC ClassWizard下，Object IDs選擇專案名稱，Messages選擇WM_SETCURSOR再選擇Add Function即可。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;   BOOL Your_Project_Name::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
   {
      // TODO: Add your message handler code here and/or call default
      return true;
   }&lt;span style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span style=&quot;white-space: normal;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;註:1.須使該事件的回傳值為ture&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;2.Your_Project_Name為您的專案名稱</content><link rel='replies' type='application/atom+xml' href='http://if2if.blogspot.com/feeds/1860415659441964578/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://if2if.blogspot.com/2012/04/mfc-cursor.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/1860415659441964578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/1860415659441964578'/><link rel='alternate' type='text/html' href='http://if2if.blogspot.com/2012/04/mfc-cursor.html' title='[MFC] 使用自訂的Cursor'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8439834739738122981.post-7549721932015555</id><published>2013-05-23T14:50:00.002+08:00</published><updated>2013-05-23T16:05:44.400+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MFC"/><category scheme="http://www.blogger.com/atom/ns#" term="Qt"/><category scheme="http://www.blogger.com/atom/ns#" term="SOURCE CODE"/><category scheme="http://www.blogger.com/atom/ns#" term="VC6"/><title type='text'>[Qt]如何避免Qt所寫的dll被帶有參數的呼叫時造成的crash?</title><content type='html'>假設我們有一個由Qt所寫成的DLL, 當中有一個StartServer是這樣定義的:&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;extern &quot;C&quot; &amp;nbsp;MY_EXPORT &amp;nbsp;void &amp;nbsp;CALLBACK *StartServer(char* pcAddress, unsigned short uiPort, char* pcWorkingPath)
{
&amp;nbsp; &amp;nbsp; if(g_pNewClass != NULL)
&amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g_pNewClass-&amp;gt;Start(pcAddress, uiPort, pcWorkingPath);
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; else
&amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WriteDebug(&quot;g_pNewClass is NULL&quot;);
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; return g_pNewClass;
}
&lt;/pre&gt;
上述的CALLBACK很關鍵!!&lt;br /&gt;
&lt;br /&gt;
2.而我們一般要呼叫dll的方式如下(以vc6為例):&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;typedef void (CALLBACK* START)(char* , unsigned short , char* );
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;START start = NULL;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;start = (START)GetProcAddress(m_hMod, &quot;StartServer&quot;);
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(start == NULL)
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;//載入函數位置失敗
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;TRACE(&quot;start not found&quot;);
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;start(m_pAddr, m_port,m_pWP);
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}

&lt;/pre&gt;
&lt;br /&gt;
於是我們就會發現函數的位置無法取得,用Dependency Walker這套萬惡的工具一看DLL的內容才知道,&lt;br /&gt;
原來是Qt自己把函數的名字改掉了.&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijb5b7cHs5XB5qMZIQ6of35jFhT2mPWrXqyXMB6oNoE5usWx0rYHxGr84PDzbImg8jpReLVnMg52hyXF8m330TyG_YX_nZ9yxPbedj1PkCAxrs0Tjzn8q9z68k1PQSvAJqDPMu8fDkJFto/s1600/example001.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;196&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijb5b7cHs5XB5qMZIQ6of35jFhT2mPWrXqyXMB6oNoE5usWx0rYHxGr84PDzbImg8jpReLVnMg52hyXF8m330TyG_YX_nZ9yxPbedj1PkCAxrs0Tjzn8q9z68k1PQSvAJqDPMu8fDkJFto/s640/example001.PNG&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;[名稱被改成了StartServer@12]&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
所以我們也要在GetProcAddress時將名字改成DLL內部所記載的:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;start = (START)GetProcAddress(m_hMod, &quot;StartServer@12&quot;);
&lt;/pre&gt;
&lt;br /&gt;
如此一來就可以正確的傳值呼叫我們想要使用的函數啦!</content><link rel='replies' type='application/atom+xml' href='http://if2if.blogspot.com/feeds/7549721932015555/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://if2if.blogspot.com/2013/05/qtqtdllcrash-qtdll-startserver-extern-c.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/7549721932015555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/7549721932015555'/><link rel='alternate' type='text/html' href='http://if2if.blogspot.com/2013/05/qtqtdllcrash-qtdll-startserver-extern-c.html' title='[Qt]如何避免Qt所寫的dll被帶有參數的呼叫時造成的crash?'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijb5b7cHs5XB5qMZIQ6of35jFhT2mPWrXqyXMB6oNoE5usWx0rYHxGr84PDzbImg8jpReLVnMg52hyXF8m330TyG_YX_nZ9yxPbedj1PkCAxrs0Tjzn8q9z68k1PQSvAJqDPMu8fDkJFto/s72-c/example001.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8439834739738122981.post-6295482928374529728</id><published>2013-05-23T11:42:00.001+08:00</published><updated>2013-05-23T15:54:06.095+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MFC"/><category scheme="http://www.blogger.com/atom/ns#" term="Qt"/><category scheme="http://www.blogger.com/atom/ns#" term="VC6"/><title type='text'>[Qt]如何讓Qt建置的dll給其他語言使用</title><content type='html'>1.將 &lt;a href=&quot;http://ftp3.ie.freebsd.org/pub/ftp.trolltech.com/pub/qt/solutions/lgpl/qtwinmigrate-2.8-opensource.zip&quot;&gt;qtwinmigrate &lt;/a&gt;安裝到Qt的目錄下&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2.參照以下連結&quot;&lt;a href=&quot;http://blog.csdn.net/normallife/article/details/5397980&quot;&gt;windows下如何使用QT编写dll程序&lt;/a&gt;&quot;進行設置&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3.在dllMain前面加上敘述字MY_EXPORT以避免Qt把函數名稱改掉&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;#ifdef Q_WS_WIN
#define MY_EXPORT __declspec(dllexport)
#else
#define MY_EXPORT
#endif
extern &quot;C&quot; MY_EXPORT BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID lpvReserved )
{
&amp;nbsp; &amp;nbsp; ...
}

&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
4.這樣就可以讓其他語言所撰寫的執行檔正常呼叫囉!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
key words: QMfcApp, qtwinmigrate, dllMain, C++&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://if2if.blogspot.com/feeds/6295482928374529728/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://if2if.blogspot.com/2013/05/qtqtdllvc.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/6295482928374529728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/6295482928374529728'/><link rel='alternate' type='text/html' href='http://if2if.blogspot.com/2013/05/qtqtdllvc.html' title='[Qt]如何讓Qt建置的dll給其他語言使用'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8439834739738122981.post-5859012407015177584</id><published>2012-07-04T11:17:00.002+08:00</published><updated>2013-12-23T14:55:37.129+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Qt"/><category scheme="http://www.blogger.com/atom/ns#" term="SOURCE CODE"/><title type='text'>[Qt] QString, QByteArray與Char的互相轉換</title><content type='html'>第一種方式(比較難記):&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;QByteArray byteArray = &quot;xxx&quot;;
QTextCodec *codec = QTextCodec::codecForName(&quot;KOI8-R&quot;);
QString string = codec-&amp;gt;toUnicode( byteArray );
&lt;/pre&gt;
&lt;br /&gt;
第二種方式:
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;QByteArray byte;
QString string(byte);
&lt;/pre&gt;
第二種方式是不是好記多了呢?:)&lt;br /&gt;
另外附上一些QString、QByteArray與char*的轉換方法

&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;//char* -&amp;gt; QByteArray
char* str;
QByteArray byte(str);
&lt;/pre&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;//char* -&amp;gt; QString
char* str;
QString string(str);
&lt;/pre&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;//QByteArray -&amp;gt; char*
QByteArray byte;
char* str = byte.data();
&lt;/pre&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;//QString -&amp;gt; QByteArray 
QString string;
QByteArray byte = string.toAscii();
&lt;/pre&gt;

&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;//QString -&amp;gt; char*
QString string;
char* str = qPrintable(string);
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
參考自&lt;a href=&quot;http://hi.baidu.com/wellalone/blog/item/0e2a9eedacac5b3badafd558.html&quot;&gt;此篇&lt;/a&gt;文章</content><link rel='replies' type='application/atom+xml' href='http://if2if.blogspot.com/feeds/5859012407015177584/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://if2if.blogspot.com/2012/07/qt-qstring-qbytearraychar.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/5859012407015177584'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/5859012407015177584'/><link rel='alternate' type='text/html' href='http://if2if.blogspot.com/2012/07/qt-qstring-qbytearraychar.html' title='[Qt] QString, QByteArray與Char的互相轉換'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8439834739738122981.post-8620177395942556211</id><published>2012-05-02T17:55:00.002+08:00</published><updated>2013-05-23T15:54:57.258+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Qt"/><category scheme="http://www.blogger.com/atom/ns#" term="SOURCE CODE"/><title type='text'>[Qt]如何利用QFtp的put()方法上傳檔案至ftp server</title><content type='html'>&lt;br /&gt;
在Qt的說明文件中，已有&lt;a href=&quot;http://doc.trolltech.com/4.3.3/network-ftp.html&quot;&gt;QFtp的使用範例&lt;/a&gt;，&lt;br /&gt;
但是該範例並沒有介紹put()，本文便會簡單的介紹put()的使用方法。&lt;br /&gt;
&lt;br /&gt;
1.建立ftp通道&lt;br /&gt;
&amp;nbsp; 使用以下指令便可以連結到想要的ftp server&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;   m_pftp = new QFtp(this);
   m_pftp-&amp;gt;connectToHost(&quot;127.0.0.1&quot;);
   m_pftp-&amp;gt;login(&quot;USER&quot;, &quot;PASSWORD&quot;); 
&lt;/pre&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;※&quot;127.0.0.1&quot;為ftp server的ip，當然也可以是domain name&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;※&quot;USER&quot;及&quot;PASSWORD&quot;分別為使用者的帳號和密碼&lt;br /&gt;
&lt;br /&gt;
2.使用put方法上傳檔案&lt;br /&gt;
&amp;nbsp; 在這邊我的做法是將欲上傳的檔案路徑都放在m_slUploadList這個QStringList變數中，再配合QFile與put()來上傳檔案。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;   if(m_pftp-&amp;gt;state() == QFtp::LoggedIn)
   {
        int iLoop = m_slUploadList.count();
        for(int index = 0; index&lt;iloop index=&quot;&quot; m_sluploadlist=&quot;&quot; pfile-=&quot;&quot; pfile=&quot;new&quot; qfile=&quot;&quot; this=&quot;&quot;&gt;open(QFile::ReadOnly);
           m_pftp-&amp;gt;put(pFile, GetFileName(m_slUploadList[index]));
 }
   }&lt;/iloop&gt;&lt;/pre&gt;
&lt;br /&gt;
&amp;nbsp; 其中&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;if(m_pftp-&amp;gt;state() == QFtp::LoggedIn)&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 這一行是在確定程式已經登入ftp中，不知為何若是將這個判斷是直接寫在 m_pftp-&amp;gt;login(&quot;USER&quot;, &quot;PASSWORD&quot;);這個指令之後，會造成這個if判斷為false，猜想應該是ftp需要一些登入的時間，所以如果一登入就進行判斷的話，會因為程式仍未登入ftp而判斷成false的情形。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;&amp;nbsp; m_pftp-&amp;gt;put(pFile, GetFileName(m_slUploadList[index]));&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; 因為m_slUploadList[index]裡面是存著路徑+檔名，所以需要另外一個函式來取出檔名，在這邊就野人獻曝順便提供一下GetFileName()的內容吧！&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;&amp;nbsp; &amp;nbsp;QString GetFileName(QString NameWithPath)

&amp;nbsp; &amp;nbsp;{

&amp;nbsp; &amp;nbsp; &amp;nbsp; int iLast = NameWithPath.lastIndexOf(&quot;/&quot;);

&amp;nbsp; &amp;nbsp; &amp;nbsp; QString strFileName;

&amp;nbsp; &amp;nbsp; &amp;nbsp; strFileName = NameWithPath.mid(iLast+1);

&amp;nbsp; &amp;nbsp; &amp;nbsp; return strFileName;

&amp;nbsp; &amp;nbsp;}
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://if2if.blogspot.com/feeds/8620177395942556211/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://if2if.blogspot.com/2012/05/qtqftpputftp-server.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/8620177395942556211'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/8620177395942556211'/><link rel='alternate' type='text/html' href='http://if2if.blogspot.com/2012/05/qtqftpputftp-server.html' title='[Qt]如何利用QFtp的put()方法上傳檔案至ftp server'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8439834739738122981.post-5583738131907987084</id><published>2012-04-30T11:40:00.001+08:00</published><updated>2013-05-23T15:55:44.489+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Qt"/><category scheme="http://www.blogger.com/atom/ns#" term="SOURCE CODE"/><title type='text'>[Qt]關於QStringList的二三事</title><content type='html'>&lt;br /&gt;
&lt;a href=&quot;http://flykof.pixnet.net/blog/post/24357943-%E5%9C%A8qt%E4%B8%AD%E5%A5%BD%E7%94%A8%E7%9A%84%E5%AD%97%E4%B8%B2%E9%99%A3%E5%88%97qstringlist&quot;&gt;在QT中好用的字串陣列QStringList&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
這篇文章已經有介紹一些簡單的存取方式，&lt;br /&gt;
有興趣的可以前往該網頁觀看，&lt;br /&gt;
在這邊也會節錄一些常用的方法。&lt;br /&gt;
&lt;br /&gt;
關於QStringList這個型別，&lt;br /&gt;
我們可以把他想成是一個Qt內建的字串陣列，&lt;br /&gt;
只是多了一些內建的函式可以使用而已。&lt;br /&gt;
&lt;br /&gt;
加入字串到QStringList&lt;br /&gt;
&lt;br /&gt;
我們可以使用&quot;&amp;lt;&amp;lt;&quot;運算子將字串加入QStringList中&lt;br /&gt;
ex:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;QStringList slFruitList;

&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;slFruitList &amp;lt;&amp;lt; &quot;apple&quot; &amp;lt;&amp;lt; &quot;banana&quot; &amp;lt;&amp;lt; &quot;cherry&quot; ;
&lt;/pre&gt;
&lt;br /&gt;
也可以使用insert方法將字串插入QStringList，被插隊的原始字串會自動往後移。&lt;br /&gt;
ex:&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;slFruitList.insert(1, &quot;guava&quot;);

&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;//原先的順序為apple, banana, cherry

&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;//新的順序為 &amp;nbsp;apple, guava, banana, cherry&lt;/pre&gt;
&lt;br /&gt;
如果是要將字串加到QStringList的最後，則可以用append()這個函式。&lt;br /&gt;
ex:
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;slFruitList.append(&quot;grape&quot;);
&lt;/pre&gt;
&lt;br /&gt;
要加到最前面的話，則可以用prepend()。&lt;br /&gt;
ex:&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;slFruitList.prepend(&quot;water&quot;);
&lt;/pre&gt;
&lt;br /&gt;
從QStringList中取出字串&lt;br /&gt;
&lt;br /&gt;
Qt提供了一個很簡單的方式，可以像使用陣列一樣來存取QStringList&lt;br /&gt;
ex:
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;QString sTemp = slFruitList[0];
&lt;br /&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;//將slFruitList中第一個字串指定給sTemp&lt;/pre&gt;
&lt;br /&gt;
但是如果你用的QStringList是宣告成指標的型式呢？很簡單，把星號和變數名稱先括起來就可以了！&lt;br /&gt;
ex:
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;QStringList *slList = new QStringList;

&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;slList-&amp;gt;append(&quot;a&quot;);

&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;slList-&amp;gt;append(&quot;b&quot;);

&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;slList-&amp;gt;append(&quot;c&quot;);



&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;QString sTemp = (*slList)[2]; // sTemp = c

&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://if2if.blogspot.com/feeds/5583738131907987084/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://if2if.blogspot.com/2012/04/qtqstringlist.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/5583738131907987084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/5583738131907987084'/><link rel='alternate' type='text/html' href='http://if2if.blogspot.com/2012/04/qtqstringlist.html' title='[Qt]關於QStringList的二三事'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8439834739738122981.post-469187031241598960</id><published>2012-04-24T16:24:00.002+08:00</published><updated>2013-05-23T15:56:48.422+08:00</updated><title type='text'>[Qt] 如何取得使用者設定資料夾(Application Data Folder)</title><content type='html'>&lt;br /&gt;
由於windows有使用者帳號的觀念，&lt;br /&gt;
每個使用者的設定也不同，&lt;br /&gt;
因此如何獲得現在使用者的設定資料夾變成了一項各家語言一定會提供的服務。&lt;br /&gt;
而這個服務通常是使用變數的方式來解決的：&lt;br /&gt;
一般的windows操作或命令提示字元底下，&lt;br /&gt;
我們可以用%APPDATA%這個環境變數來直接取得Application Data這個資料夾的路徑。&lt;br /&gt;
例如:C:\Documents and Settings\xxx\Application Data&lt;br /&gt;
※xxx為目前的使用者名稱&lt;br /&gt;
&lt;br /&gt;
在Qt內，我們則要借重QDir這個函式庫，才能取得使用者帳號的路徑了。&lt;br /&gt;
使用的方式很簡單：&lt;br /&gt;
&lt;br /&gt;
1.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;#include &amp;lt;QDir&amp;gt;&lt;/pre&gt;
2.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;QString strAppPath = QDir::homePath();&lt;/pre&gt;

如此一來便可以使用strAppPath該字串來存取使用者帳號底下的目錄和檔案了(當然也包含了Application Data個資料夾囉~)。</content><link rel='replies' type='application/atom+xml' href='http://if2if.blogspot.com/feeds/469187031241598960/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://if2if.blogspot.com/2012/04/qt-application-data-folder.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/469187031241598960'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/469187031241598960'/><link rel='alternate' type='text/html' href='http://if2if.blogspot.com/2012/04/qt-application-data-folder.html' title='[Qt] 如何取得使用者設定資料夾(Application Data Folder)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8439834739738122981.post-2565975675440283594</id><published>2012-04-24T14:25:00.002+08:00</published><updated>2012-04-24T16:14:18.185+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Windows"/><title type='text'>Windows系統內建的常見環境變數</title><content type='html'>&lt;br /&gt;
%ALLUSERSPROFILE%：All Users設定檔的資料夾位置。&lt;br /&gt;
&lt;br /&gt;
%APPDATA%：目前使用者的Application Data資料夾位置。&lt;br /&gt;
&lt;br /&gt;
%CD%：目前的工作資料夾。&lt;br /&gt;
&lt;br /&gt;
%CLIENTNAME%：目前使用者的NETBIOS電腦名稱。&lt;br /&gt;
&lt;br /&gt;
%CMDCMDLINE%：處理目前命令提示字元視窗命令的cmd.exe的完整路徑。&lt;br /&gt;
&lt;br /&gt;
%CMDEXTVERSION%：目前Command Processor Extensions的版本。&lt;br /&gt;
&lt;br /&gt;
%COMPUTERNAME%：電腦名稱。&lt;br /&gt;
&lt;br /&gt;
%COMSPEC%:：命令提示字元視窗的解譯程式路徑，通常與%CMDCMDLINE%相同。&lt;br /&gt;
&lt;br /&gt;
%CommonProgramFiles%：Common Files資料夾的路徑。&lt;br /&gt;
&lt;br /&gt;
%DATE%：目前的系統日期。&lt;br /&gt;
&lt;br /&gt;
%ERRORLEVEL%：最近執行過的命令的錯誤碼；非零的值表示發生過的錯誤碼。&lt;br /&gt;
&lt;br /&gt;
%HOMESHARE%：目前使用者共用資料夾的網路路徑。&lt;br /&gt;
&lt;br /&gt;
%HomeDrive%：使用者目錄的磁碟機。&lt;br /&gt;
&lt;br /&gt;
%HomePath%：使用者家目錄。&lt;br /&gt;
&lt;br /&gt;
%LOGONSEVER%：目前使用者所登入的網路控制器名稱。&lt;br /&gt;
&lt;br /&gt;
%NUMBER_OF_PROCESSORS%：電腦的處理器數量。&lt;br /&gt;
&lt;br /&gt;
%OS%：作業系統名稱，其值固定為Windows_NT&lt;br /&gt;
&lt;br /&gt;
%PATHEXT%：作業系統是為執行檔的副檔名。&lt;br /&gt;
&lt;br /&gt;
%PROCESSOR_ARCHITECTURE%：處理器的架構名稱，例如x86。&lt;br /&gt;
&lt;br /&gt;
%PROCESSOR_IDENTFIER%：說明處理器的文字（不一定會有此環境變數）。&lt;br /&gt;
&lt;br /&gt;
%PROCESSOR_LEVEL%：處理器的model number。&lt;br /&gt;
&lt;br /&gt;
%PROCESSOR_REVISION%：處理器的revision number。&lt;br /&gt;
&lt;br /&gt;
%PROMPT%：目前解譯程式的命令提示字串。&lt;br /&gt;
&lt;br /&gt;
%Path%：執行檔的搜尋路徑。&lt;br /&gt;
&lt;br /&gt;
%ProgramFiles%：應用程式目錄，預設是C:\Program Files。&lt;br /&gt;
&lt;br /&gt;
%RANDOM%：顯示0到32767之間的十進位整數亂數。&lt;br /&gt;
&lt;br /&gt;
%SESSIONNAME%：連上終端伺服器的session names。&lt;br /&gt;
&lt;br /&gt;
%SystemDirectory%：系統目錄，預設是C:\WINNT\System32或C:\WINDOWS\System32。&lt;br /&gt;
&lt;br /&gt;
%SystemDrive%：系統磁碟機，預設是C:。&lt;br /&gt;
&lt;br /&gt;
%SystemRoot%：系統根目錄，預設是C:\WINNT或C:\WINDOWS。&lt;br /&gt;
&lt;br /&gt;
%TIME%：目前的系統時間。&lt;br /&gt;
&lt;br /&gt;
%Temp%、%Tmp%：暫存檔目錄。&lt;br /&gt;
&lt;br /&gt;
%USERPROFILE%：目前使用者的設定檔路徑。&lt;br /&gt;
&lt;br /&gt;
%UserDomain%：包含使用者帳號的網域名稱，或者電腦名稱。&lt;br /&gt;
&lt;br /&gt;
%UserName%：使用者帳號名稱。&lt;br /&gt;
&lt;br /&gt;
%WinDir%：Windows目錄，預設是C:\WINNT或C:\WINDOWS。&lt;br /&gt;
&lt;br /&gt;
轉載自&lt;a href=&quot;http://jck11.pixnet.net/blog/post/13459124-windows%E7%B3%BB%E7%B5%B1%E5%85%A7%E5%BB%BA%E7%9A%84%E5%B8%B8%E8%A6%8B%E7%92%B0%E5%A2%83%E8%AE%8A%E6%95%B8&quot;&gt;此網頁&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://if2if.blogspot.com/feeds/2565975675440283594/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://if2if.blogspot.com/2012/04/windows.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/2565975675440283594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/2565975675440283594'/><link rel='alternate' type='text/html' href='http://if2if.blogspot.com/2012/04/windows.html' title='Windows系統內建的常見環境變數'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8439834739738122981.post-8620199779108673023</id><published>2012-04-10T18:28:00.004+08:00</published><updated>2013-05-23T15:59:26.008+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MFC"/><category scheme="http://www.blogger.com/atom/ns#" term="SOURCE CODE"/><category scheme="http://www.blogger.com/atom/ns#" term="VC6"/><title type='text'>[MFC] 改變Progress的顏色</title><content type='html'>使用以下語法即可改變Progress進度條的顏色:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;    m_Pro1.SendMessage(PBM_SETBARCOLOR, 0, RGB(0, 0, 0));
&lt;/pre&gt;
&lt;br /&gt;
其中：&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;m_Por1為CProgressCtrl的名稱。&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;RGB(0, 0, 0)改變裡面的數字可以讓ProgressBar變成不同的顏色，&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;數值可以參考&lt;a href=&quot;http://www.wahart.com.hk/rgb.htm&quot;&gt;RGB配色表&lt;/a&gt;。&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;備註：&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;CProgressCtrl的Member Function .SetBarColor無法在VC6中使用。&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://if2if.blogspot.com/feeds/8620199779108673023/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://if2if.blogspot.com/2012/04/vc6-progressbar.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/8620199779108673023'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/8620199779108673023'/><link rel='alternate' type='text/html' href='http://if2if.blogspot.com/2012/04/vc6-progressbar.html' title='[MFC] 改變Progress的顏色'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8439834739738122981.post-6608980718430318524</id><published>2012-04-10T18:21:00.000+08:00</published><updated>2013-07-29T11:55:57.712+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MFC"/><category scheme="http://www.blogger.com/atom/ns#" term="SOURCE CODE"/><category scheme="http://www.blogger.com/atom/ns#" term="VC6"/><title type='text'>[MFC] 忽略esc與enter鍵，使其無法結束dialog</title><content type='html'>1.重載PreTranslateMessage事件&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;
afx_msg BOOL PreTranslateMessage(MSG *pMsg);
&lt;/pre&gt;
2.在上述事件中，加入以下的code&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;
BOOL CTestDlg::PreTranslateMessage(MSG* pMsg) 
{
   if(pMsg-&amp;gt;message == WM_KEYDOWN)
   {
      switch(pMsg-&amp;gt;wParam)
      {
         case VK_RETURN:
         case VK_ESCAPE:
              return true;
      }
   }
   return CDialog::PreTranslateMessage(pMsg);
}
&lt;/pre&gt;
&lt;br /&gt;
如此即可避免程式執行中，因按下esc或enter而造成程式結束。</content><link rel='replies' type='application/atom+xml' href='http://if2if.blogspot.com/feeds/6608980718430318524/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://if2if.blogspot.com/2012/04/vc6-escenterdialog.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/6608980718430318524'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/6608980718430318524'/><link rel='alternate' type='text/html' href='http://if2if.blogspot.com/2012/04/vc6-escenterdialog.html' title='[MFC] 忽略esc與enter鍵，使其無法結束dialog'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8439834739738122981.post-7326887484483249193</id><published>2012-04-10T14:03:00.001+08:00</published><updated>2013-05-23T16:00:43.523+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Qt"/><category scheme="http://www.blogger.com/atom/ns#" term="SOURCE CODE"/><title type='text'>[Qt] 取得自己電腦的ip位置(ipv4)</title><content type='html'>&lt;div style=&quot;font-family: &#39;Times New Roman&#39;; white-space: normal;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
先include下面兩個函式庫&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;#include &amp;lt;QHostInfo&amp;gt;
#include &amp;lt;QHostAddress&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
然後在欲得到ip的程式碼區段加入以下的code&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt;    QString ip;
    QHostInfo host = QHostInfo::fromName(QHostInfo::localHostName());
    foreach (QHostAddress address, host.addresses())
    ip = address.toString();
&lt;/pre&gt;
&lt;br /&gt;
QString ip即為想得到的本機ip address</content><link rel='replies' type='application/atom+xml' href='http://if2if.blogspot.com/feeds/7326887484483249193/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://if2if.blogspot.com/2012/04/qt-ipipv4.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/7326887484483249193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/7326887484483249193'/><link rel='alternate' type='text/html' href='http://if2if.blogspot.com/2012/04/qt-ipipv4.html' title='[Qt] 取得自己電腦的ip位置(ipv4)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8439834739738122981.post-1466244806817475188</id><published>2012-04-09T16:23:00.000+08:00</published><updated>2013-05-23T15:24:07.588+08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BLOG"/><category scheme="http://www.blogger.com/atom/ns#" term="SOURCE CODE"/><title type='text'>[blog]如何在Blogger中顯示code區段</title><content type='html'>1.進入網誌後台設定頁面&lt;br /&gt;
&lt;br /&gt;
2.選擇 &#39;範本\修改HTML\繼續\&#39;&lt;br /&gt;
&lt;br /&gt;
3.將以下code加入至post區段中:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;codeblock prettyprint&quot;&gt; .post pre {
  background: #F0F0F0 url(http://yourwebspace/Code_BG.gif) repeat-y scroll left top;
  border: 1px solid #CCCCCC;
  color: #333333;
  display: block;
  font-family: Courier New;
  font-size: 10pt;
  line-height: 120%;
  margin: 5px 0 0 20px;
  max-height: 200px;
  overflow: auto;
  padding: 10px 10px 10px 21px;
  width: 90%;
}
&lt;/pre&gt;
&lt;br /&gt;
4.http://yourwebspace/即您的網路空間，這裡是指向程式碼區段左側的那條灰底圖。&lt;br /&gt;
5.之後只需在&amp;nbsp;source code前後加入&amp;lt;pre&amp;gt;和&amp;lt;/pre&amp;gt;標籤即可！</content><link rel='replies' type='application/atom+xml' href='http://if2if.blogspot.com/feeds/1466244806817475188/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://if2if.blogspot.com/2012/04/bloggercode.html#comment-form' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/1466244806817475188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8439834739738122981/posts/default/1466244806817475188'/><link rel='alternate' type='text/html' href='http://if2if.blogspot.com/2012/04/bloggercode.html' title='[blog]如何在Blogger中顯示code區段'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>