<?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: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-7726932685002102918</id><updated>2012-02-07T06:32:31.545-08:00</updated><title type='text'>Win32 Tips</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>17</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-2077930141771202009</id><published>2011-05-13T12:59:00.000-07:00</published><updated>2011-05-13T12:59:24.933-07:00</updated><title type='text'>Some C++ Tips and Functions</title><content type='html'>&lt;A name='1'&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;A simple C++ function to tokenize a string &lt;/h3&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;#include &amp;lt;vector&amp;gt;&lt;br /&gt;#include &amp;lt;string&amp;gt;&lt;br /&gt;#include &amp;lt;sstream&amp;gt;&lt;br /&gt;using namespace std;&lt;br /&gt;vector&amp;lt;string&amp;gt;  getTokens(string str){&lt;br /&gt; string buf; &lt;span class=green&gt; // Have a buffer string&lt;/span&gt;&lt;br /&gt; stringstream ss(str); &lt;span class=green&gt; // Insert the string into a stream&lt;/span&gt;&lt;br /&gt; vector&lt;string&gt; tokens; &lt;span class=green&gt; // Create vector to hold our words&lt;/span&gt;&lt;br /&gt; while (ss &gt;&gt; buf)&lt;br /&gt;    tokens.push_back(buf);&lt;br /&gt; return tokens;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;A name='2'&gt;&lt;br /&gt;&lt;h4&gt;A more complex tokenize function &lt;/h4&gt;&lt;/a&gt;&lt;br /&gt;&lt;pre&gt;void Tokenize(const string&amp; str,&lt;br /&gt;                      vector&lt;string&gt;&amp; tokens,&lt;br /&gt;                      const string&amp; delimiters = " ")&lt;br /&gt;{&lt;br /&gt;    &lt;span class=green&gt; // Skip delimiters at beginning.&lt;/span&gt;&lt;br /&gt;    string::size_type lastPos = str.find_first_not_of(delimiters, 0);&lt;br /&gt;    &lt;span class=green&gt; // Find first "non-delimiter".&lt;/span&gt;&lt;br /&gt;    string::size_type pos     = str.find_first_of(delimiters, lastPos);&lt;br /&gt;    while (string::npos != pos || string::npos != lastPos)&lt;br /&gt;    {&lt;br /&gt;        &lt;span class=green&gt; // Found a token, add it to the vector.&lt;/span&gt;&lt;br /&gt;        tokens.push_back(str.substr(lastPos, pos - lastPos));&lt;br /&gt;        &lt;span class=green&gt; // Skip delimiters.  Note the "not_of"&lt;/span&gt;&lt;br /&gt;        lastPos = str.find_first_not_of(delimiters, pos);&lt;br /&gt;        &lt;span class=green&gt; // Find next "non-delimiter"&lt;/span&gt;&lt;br /&gt;        pos = str.find_first_of(delimiters, lastPos);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Usage:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt; vector&amp;lt;string&amp;gt; tokens;&lt;br /&gt;  string str("Split,me up!&lt;W'ord1&gt;Word2 Word3.");&lt;br /&gt;  Tokenize(str, tokens, ",&lt;'&gt; " );&lt;br /&gt;  vector &amp;lt;string&amp;gt;::iterator iter;&lt;br /&gt;  for(iter = tokens.begin();iter!=tokens.end();iter++){&lt;br /&gt;    cout&lt;&lt; (*iter) &lt;&lt; endl;&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;A name='3'&gt;&lt;h3&gt;Write a number to a string &lt;/h3&gt;&lt;/a&gt;&lt;pre&gt;int                   myInteger;&lt;br /&gt;string              myString;&lt;br /&gt;ostringstream myStream;&lt;br /&gt;&lt;span class=green&gt; // Copy Integer to String Stream&lt;/span&gt;&lt;br /&gt;myStream &lt;&lt; myInteger;&lt;br /&gt;&lt;span class=green&gt; // Assign characters in stream to std::string&lt;/span&gt;&lt;br /&gt;myString = myStream.str();&lt;br /&gt;&lt;/pre&gt;A stream can be cleared in the following way:&lt;pre&gt;myStream.str("");&lt;br /&gt;&lt;/pre&gt;&lt;A name='4'&gt;&lt;h3&gt;Replace a vector element &lt;/h3&gt;&lt;/a&gt;&lt;pre&gt;vector &lt;string&gt; theVector;&lt;br /&gt;&lt;span class=green&gt; //populate the vector&lt;/span&gt;&lt;br /&gt;theVector.at(2) = "new string";&lt;br /&gt;&lt;/pre&gt;&lt;A name='5'&gt;&lt;h3&gt;Transform HTML color code string to COLORREF&lt;/h3&gt;&lt;/a&gt;The string parameter is assumed to be in '#FFFFFF' format.&lt;pre&gt;COLORREF transformHTML(string color){&lt;br /&gt; string s1(color, 1,2);&lt;br /&gt; string s2(color, 3,2);&lt;br /&gt; string s3(color, 5,2);&lt;br /&gt;&lt;br /&gt; long r = strtol(s1.c_str(), NULL, 16);&lt;br /&gt; long g = strtol(s2.c_str(), NULL, 16);&lt;br /&gt; long b = strtol(s3.c_str(), NULL, 16);&lt;br /&gt;&lt;br /&gt; return RGB (r,g,b);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;A name='6'&gt;&lt;h3&gt;Determine Whether A String is in Upper Case&lt;/h3&gt;&lt;/a&gt;&lt;pre&gt;bool isUpper(string line){&lt;br /&gt; const char *str = line.c_str();&lt;br /&gt; while(*str != '\0'){&lt;br /&gt;  if(IsCharLower(*str))&lt;br /&gt;   return false;&lt;br /&gt;  *str++;&lt;br /&gt; }&lt;br /&gt; return true;&lt;br /&gt;}&lt;br /&gt;A Windows &lt;b&gt;IsCharLower&lt;/b&gt; function is used.&lt;br /&gt;&lt;/pre&gt;&lt;A name='7'&gt;&lt;h3&gt;Convert str::string to char&lt;/h3&gt;&lt;/a&gt;Use  the &lt;b&gt;c_str() &lt;/b&gt; function.&lt;p&gt;Example:&lt;br&gt;&lt;pre&gt;string str = "test string";&lt;br /&gt;const char *ch = str.c_str();&lt;br /&gt;&lt;/pre&gt;&lt;A name='8'&gt;&lt;h3&gt;Pass string arrays to functions&lt;/h3&gt;&lt;/a&gt;This actually refers to C.&lt;br&gt;You declare a string array in the calling function as follows:&lt;pre&gt; char arr[10][30];&lt;br /&gt;&lt;/pre&gt;The second dimension must always have the exact number of elements in the function declaration:&lt;pre&gt; int functionName(char  (*arr) [30], int numberOfElements 10);&lt;br /&gt;&lt;/pre&gt;The brackets around the array name are important. You also passthe number of elements in the first dimension as an argument to the function.&lt;p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-2077930141771202009?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/2077930141771202009/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2011/05/some-c-tips-and-functions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/2077930141771202009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/2077930141771202009'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2011/05/some-c-tips-and-functions.html' title='Some C++ Tips and Functions'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-8076531037095437883</id><published>2009-03-25T10:01:00.000-07:00</published><updated>2009-03-25T10:02:10.394-07:00</updated><title type='text'>Make Sure Only One Instance of the Application Is Running</title><content type='html'>Place the following code in your WinMain: &lt;br /&gt;&lt;code&gt;&lt;br /&gt;// Look for the running instance of the application&lt;br /&gt;char* szTitle = "My Title";&lt;br /&gt;if (FindWindow(NULL, szTitle)){&lt;br /&gt;  SetForegroundWindow(FindWindow(NULL, szTitle));&lt;br /&gt;  return FALSE;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;First, it looks for a window that has the same title as your application. If it finds it, it will make it active. &lt;br /&gt;Another approach is to use a mutex: &lt;br /&gt;&lt;code&gt;&lt;br /&gt;BOOL IsFirstInstance()&lt;br /&gt;{&lt;br /&gt;HANDLE hMutex = CreateMutex(NULL, FALSE, "PUT A GUID HERE");&lt;br /&gt;if(hMutex &amp;&amp; GetLastError() == ERROR_ALREADY_EXISTS)&lt;br /&gt;{&lt;br /&gt;ReleaseMutex(hMutex);&lt;br /&gt;return FALSE;&lt;br /&gt;}&lt;br /&gt;ReleaseMutex(hMutex);&lt;br /&gt;return TRUE;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;You call the above-mentioned function in your "InitInstance" method of your application.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-8076531037095437883?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/8076531037095437883/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/make-sure-only-one-instance-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/8076531037095437883'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/8076531037095437883'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/make-sure-only-one-instance-of.html' title='Make Sure Only One Instance of the Application Is Running'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-1448450758272420106</id><published>2009-03-25T10:00:00.001-07:00</published><updated>2009-03-25T10:00:58.228-07:00</updated><title type='text'>How to Launch Internet Properties Control Applet</title><content type='html'>Use the following code: &lt;br /&gt;&lt;code&gt;&lt;br /&gt;WinExec("rundll32 inetcpl.cpl LaunchConnectionDialog", SW_SHOW); &lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-1448450758272420106?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/1448450758272420106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/how-to-launch-internet-properties.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/1448450758272420106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/1448450758272420106'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/how-to-launch-internet-properties.html' title='How to Launch Internet Properties Control Applet'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-7991739373849840792</id><published>2009-03-25T09:58:00.001-07:00</published><updated>2009-03-25T10:00:30.000-07:00</updated><title type='text'>Measure Time In Milliseconds</title><content type='html'>Use the DWORD GetTickCount(void) function. &lt;br /&gt;The return value is the number of milliseconds that have elapsed since the system was started. &lt;br /&gt;Example Code:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;DWORD dwStart = GetTickCount(); &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Stop if this has taken too long: &lt;br /&gt;&lt;code&gt;&lt;br /&gt;if( GetTickCount() - dwStart &gt;= TIMELIMIT )&lt;br /&gt;Cancel(); &lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-7991739373849840792?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/7991739373849840792/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/measure-time-in-milliseconds_25.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/7991739373849840792'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/7991739373849840792'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/measure-time-in-milliseconds_25.html' title='Measure Time In Milliseconds'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-3726204308672040094</id><published>2009-03-25T09:58:00.000-07:00</published><updated>2009-03-25T09:59:11.158-07:00</updated><title type='text'>Measure Time In Milliseconds</title><content type='html'>Use the &lt;span class=code&gt;DWORD GetTickCount(void);&lt;/span&gt; function.&lt;br /&gt;&lt;br&gt;&lt;br /&gt;The return value is the number of milliseconds that have elapsed since the system was started.&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;Example Code:&lt;/b&gt;&lt;br&gt;&lt;br /&gt;&lt;div class=code&gt;&lt;br /&gt;DWORD dwStart = GetTickCount();&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;Stop if this has taken too long:&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;div class=code&gt;if( GetTickCount() - dwStart &gt;= TIMELIMIT )&lt;br&gt;&lt;br /&gt;    Cancel();&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-3726204308672040094?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/3726204308672040094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/measure-time-in-milliseconds.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/3726204308672040094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/3726204308672040094'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/measure-time-in-milliseconds.html' title='Measure Time In Milliseconds'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-5592603950397724328</id><published>2009-03-25T09:57:00.000-07:00</published><updated>2009-03-25T09:58:29.548-07:00</updated><title type='text'>Retrieve Menu Item Text with GetMenuItemInfo function</title><content type='html'>&lt;code&gt;&lt;br /&gt;MENUITEMINFO MenuItem;&lt;br /&gt;HMENU hmenu, hsubmenu;&lt;br /&gt;HWND hwnd; //handle to main window&lt;br /&gt;char szString[256];&lt;br /&gt;int countLast =0;&lt;br /&gt;//Initialize MENUITEMINFO structure:&lt;br /&gt;memset(&amp;MenuItem,0, sizeof(MenuItem));&lt;br /&gt;MenuItem.cbSize = sizeof(MenuItem);&lt;br /&gt;MenuItem.fMask =MIIM_TYPE; &lt;br /&gt;MenuItem.fType = MFT_STRING;&lt;br /&gt;//Important - the dwTypeData and cch data members must also be initialized to receive the string.&lt;br /&gt;MenuItem.cch = 256; &lt;br /&gt;MenuItem.dwTypeData = szString;&lt;br /&gt;hmenu = GetMenu(hwnd); //get the menu&lt;br /&gt;hsubmenu = GetSubMenu(hmenu,0); //get the first submenu&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;countLast = GetMenuItemCount(hsubmenu); //count number of items in the submenu; starts with 0;&lt;br /&gt;&lt;br /&gt;GetMenuItemInfo(hsubmenu, 0, --countLast, &amp;MenuItem );&lt;br /&gt;&lt;br /&gt;MessageBox(NULL, MenuItem.dwTypeData, "Last Menu Item", MB_OK);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-5592603950397724328?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/5592603950397724328/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/retrieve-menu-item-text-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/5592603950397724328'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/5592603950397724328'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/retrieve-menu-item-text-with.html' title='Retrieve Menu Item Text with GetMenuItemInfo function'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-7604257363402480364</id><published>2009-03-25T09:55:00.000-07:00</published><updated>2009-03-25T09:57:37.246-07:00</updated><title type='text'>Use Bold or Underlined Font</title><content type='html'>1. Define a static HFONT variable:&lt;br /&gt;&lt;br /&gt;static HFONT hFont;&lt;br /&gt;&lt;br /&gt;2. In the response to the WM_INITDIALOG message, create a font with desired features, using CreateFont function:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;HFONT CreateFont(&lt;br /&gt;int nHeight, // logical height of font &lt;br /&gt;int nWidth, // logical average character width &lt;br /&gt;int nEscapement, // angle of escapement &lt;br /&gt;int nOrientation, // base-line orientation angle &lt;br /&gt;int fnWeight, // font weight &lt;br /&gt;DWORD fdwItalic, // italic attribute flag &lt;br /&gt;DWORD fdwUnderline, // underline attribute flag &lt;br /&gt;DWORD fdwStrikeOut, // strikeout attribute flag &lt;br /&gt;DWORD fdwCharSet, // character set identifier &lt;br /&gt;DWORD fdwOutputPrecision, // output precision &lt;br /&gt;DWORD fdwClipPrecision, // clipping precision &lt;br /&gt;DWORD fdwQuality, // output quality &lt;br /&gt;DWORD fdwPitchAndFamily, // pitch and family &lt;br /&gt;LPCTSTR lpszFace // pointer to typeface name string &lt;br /&gt;); &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Use the pre-defined FW_BOLD parameter for fnWeight for Bold text.&lt;br /&gt;Set fdwUnderline parameter to TRUE for underlined text.&lt;br /&gt;&lt;br /&gt;Use default values for most of the other parameters.&lt;br /&gt;&lt;br /&gt;Here is a simple helper function:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;HFONT SimpleCreateFont( int Height, BOOL Bold, BOOL Italic, BOOL Underline,&lt;br /&gt;BOOL StrikeOut, DWORD Family, char* FaceName )&lt;br /&gt;{&lt;br /&gt;HFONT Ret;&lt;br /&gt;int Weight;&lt;br /&gt;Weight = Bold ? FW_BOLD : FW_NORMAL;&lt;br /&gt;Ret = CreateFont( Height, 0, 0, 0, Weight,&lt;br /&gt;Italic, Underline, StrikeOut, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,&lt;br /&gt;CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | Family, FaceName );&lt;br /&gt;return( Ret );&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;3. Use the WM_SETFONT message to tell child control to use new font&lt;br /&gt;&lt;code&gt;&lt;br /&gt;SendMessage( GetDlgItem( hwnd, ID_WEB ), WM_SETFONT, (WPARAM)hFont, 0 );&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-7604257363402480364?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/7604257363402480364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/use-bold-or-underlined-font.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/7604257363402480364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/7604257363402480364'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/use-bold-or-underlined-font.html' title='Use Bold or Underlined Font'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-4550705618518167287</id><published>2009-03-25T08:58:00.000-07:00</published><updated>2009-03-25T08:59:57.312-07:00</updated><title type='text'>Enable a Button Depending On Whether There is Any Text in the Edit Box</title><content type='html'>Use this function:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;int EntryFieldMessages(HWND hDlg,WPARAM wParam) { &lt;br /&gt;char buffer[1024]; &lt;br /&gt;//Get a handle to the button&lt;br /&gt;HWND hIdOk = GetDlgItem(hDlg,1005);&lt;br /&gt;switch (HIWORD(wParam)) {&lt;br /&gt;case EN_CHANGE:&lt;br /&gt;if (GetDlgItemText(hDlg,1004,&lt;br /&gt;buffer, sizeof(buffer))) {&lt;br /&gt;// There is some text in the entry field. Enable the IDOK button. &lt;br /&gt;EnableWindow(hIdOk,1);&lt;br /&gt;}&lt;br /&gt;else // no text, disable the IDOK button&lt;br /&gt;EnableWindow(hIdOk,0);&lt;br /&gt;break;&lt;br /&gt;}&lt;br /&gt;return 1;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;in response to WM_COMMAND message, i.e.:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;case 1004:&lt;br /&gt;{&lt;br /&gt;switch (HIWORD(wParam)){&lt;br /&gt;case EN_CHANGE:&lt;br /&gt;return EntryFieldMessages(hwnd,wParam);&lt;br /&gt;}&lt;br /&gt;break;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;1004 represents an edit box identifier, of course.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-4550705618518167287?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/4550705618518167287/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/enable-button-depending-on-whether.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/4550705618518167287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/4550705618518167287'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/enable-button-depending-on-whether.html' title='Enable a Button Depending On Whether There is Any Text in the Edit Box'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-3728541827567259618</id><published>2009-03-25T08:56:00.002-07:00</published><updated>2009-03-25T08:58:23.103-07:00</updated><title type='text'>Set Foreground Color to an Individual Edit Box or Static Control</title><content type='html'>If you have several edit boxes but want to set color to one of them only,&lt;br /&gt;capture the WM_CTLCOLOREDIT message and get the handle to that edit box.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;case WM_CTLCOLOREDIT: &lt;br /&gt;//Get Handle to that control first&lt;br /&gt;&lt;br /&gt;if((HWND)lParam==GetDlgItem(hwnd,IDC_TEXTBOX)){&lt;br /&gt;HDC hDC = (HDC)wParam;&lt;br /&gt;COLORREF color = RGB(192,0,0); // red color&lt;br /&gt;SetTextColor(hDC, color);&lt;br /&gt;//Optionally, set background color &lt;br /&gt;//SetBkColor(hDC, RGB(255,255,0)); /* yellow */&lt;br /&gt;}&lt;br /&gt;return GetStockObject(WHITE_BRUSH);&lt;br /&gt;break;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;For a static control use WM_CTLCOLORSTATIC message: &lt;br /&gt;Example:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;HDC hdcStatic = (HDC)wParam;&lt;br /&gt;SetTextColor(hdcStatic, RGB(255, 0, 0)); //red color &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Set the background mode to transparent to use the parent window's background color and return NULL_BRUSH:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;SetBkMode(hdcStatic,TRANSPARENT); &lt;br /&gt;return GetStockObject(NULL_BRUSH);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;A more detailed explanation at http://www.geocities.com/Heartland/Meadows/9818/win32tut/lesson4.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-3728541827567259618?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/3728541827567259618/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/set-foreground-color-to-individual-edit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/3728541827567259618'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/3728541827567259618'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/set-foreground-color-to-individual-edit.html' title='Set Foreground Color to an Individual Edit Box or Static Control'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-4265234477867761294</id><published>2009-03-25T08:56:00.001-07:00</published><updated>2009-03-25T08:56:52.030-07:00</updated><title type='text'>How to Get a Handle to a Control</title><content type='html'>Use GetDlgItem function: &lt;br /&gt;&lt;code&gt;&lt;br /&gt; HWND GetDlgItem(&lt;br /&gt; HWND hDlg,       // handle of dialog box&lt;br /&gt; int nIDDlgItem   // identifier of control&lt;br /&gt; );&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-4265234477867761294?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/4265234477867761294/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/how-to-get-handle-to-control.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/4265234477867761294'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/4265234477867761294'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/how-to-get-handle-to-control.html' title='How to Get a Handle to a Control'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-38166357724601331</id><published>2009-03-25T07:37:00.000-07:00</published><updated>2009-03-25T07:38:22.349-07:00</updated><title type='text'>Create A Combo Box on a Toolbar</title><content type='html'>const int nDropHeight = 100; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Create a dummy button on a toolbar. Separator style recommended.&lt;br /&gt;&lt;br /&gt;Command identifier associated with the button: &lt;br /&gt;&lt;br /&gt;button.idCommand = CM_DUMMY;&lt;br /&gt;&lt;br /&gt;Get the button size:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;RECT rect; &lt;br /&gt;SendMessage(g_hToolBar, TB_GETITEMRECT, 8, (LPARAM)&amp;rect);&lt;br /&gt;rect.top = 1;&lt;br /&gt;rect.bottom = rect.top + nDropHeight;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Create a combo box window:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;HWND hCombo = CreateWindowEx(0, szComboBox, NULL,&lt;br /&gt;WS_CHILD|WS_VISIBLE|CBS_DROPDOWNLIST|CBS_HASSTRINGS|CBS_AUTOHSCROLL,&lt;br /&gt;rect.left, rect.top, 100,50,&lt;br /&gt;hwndToolBar, (HMENU)1100, hInst, NULL);&lt;br /&gt;&lt;br /&gt;if(hCombo == NULL)&lt;br /&gt;{&lt;br /&gt;MessageBox(0, "Combo Creation Failed!", "Error!",&lt;br /&gt;&lt;br /&gt;MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);&lt;br /&gt;} &lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-38166357724601331?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/38166357724601331/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/create-combo-box-on-toolbar.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/38166357724601331'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/38166357724601331'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/create-combo-box-on-toolbar.html' title='Create A Combo Box on a Toolbar'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-5376560972265095393</id><published>2009-03-25T07:33:00.000-07:00</published><updated>2009-03-25T07:34:18.972-07:00</updated><title type='text'>Create Toolbar Tips</title><content type='html'>Declare: &lt;br /&gt;LPNMTTDISPINFO TTtext; &lt;br /&gt;Example: &lt;br /&gt;&lt;code&gt;&lt;br /&gt; case WM_NOTIFY:&lt;br /&gt;  TTtext = (LPNMTTDISPINFO)lParam;&lt;br /&gt;  if(TTtext-&gt;hdr.code==TTN_GETDISPINFO)&lt;br /&gt;   switch(TTtext-&gt;hdr.idFrom){&lt;br /&gt;   case CM_RED_CIRCLE:&lt;br /&gt;    TTtext-&gt;lpszText = "Red Circle";&lt;br /&gt;    break;&lt;br /&gt;&lt;br /&gt;   case CM_GREEN_SQUARE:&lt;br /&gt;    TTtext-&gt;lpszText = "Green Square";&lt;br /&gt;    break;&lt;br /&gt;   case CM_BLUE_CIRCLE:&lt;br /&gt;    TTtext-&gt;lpszText = "Blue Circle";&lt;br /&gt;    break;&lt;br /&gt;&lt;br /&gt;   case CM_YELLOW_SQUARE:&lt;br /&gt;    TTtext-&gt;lpszText = "Yellow Square";&lt;br /&gt;    break;&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;     break;&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-5376560972265095393?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/5376560972265095393/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/create-toolbar-tips.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/5376560972265095393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/5376560972265095393'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/create-toolbar-tips.html' title='Create Toolbar Tips'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-8566572222113083477</id><published>2009-03-24T17:21:00.000-07:00</published><updated>2009-03-25T07:34:52.465-07:00</updated><title type='text'>How to Trap Enter key on Edit Box</title><content type='html'>In order to trap the keypress you'll need to subclass the edit window.&lt;br /&gt;Here's how to do it.&lt;br /&gt;First, you'll need to store the original window proc in a global, so declare it as such:&lt;br /&gt;FAR PROC DefEditProc;&lt;br /&gt;&lt;br /&gt;Then you'll need to create a window proc to trap the message. Here's one that will do what you need:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;LRESULT CALLBACK MyEditProc(HWND hDlg, UINT message,&lt;br /&gt;  WPARAM wParam, LPARAM lParam) {&lt;br /&gt;    switch(message) {&lt;br /&gt;         case WM_CHAR:&lt;br /&gt;              if( wParam == 13 ) {&lt;br /&gt;      /* User pressed ENTER -- do what you want here. */&lt;br /&gt;                   return(0);&lt;br /&gt;              }&lt;br /&gt;              else return( (LRESULT)CallWindowProc&lt;br /&gt;                ((WNDPROC)DefEditProc,hDlg,message,wParam,lParam) );&lt;br /&gt;         break;&lt;br /&gt;         default:&lt;br /&gt;               return( (LRESULT)CallWindowProc((WNDPROC)DefEditProc,&lt;br /&gt;                 hDlg,message,wParam,lParam) );&lt;br /&gt;         break;&lt;br /&gt;    }&lt;br /&gt;    return(0);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Everything else below should occur when you're initializing the window containing the edit box:&lt;br /&gt;&lt;br /&gt;Store the Edit window handle into EditWnd. You can do this several ways...if you created the edit window in a dialog box you can do this:&lt;br /&gt;HWND EditWnd = GetDlgItem(hDlg,IDC_EDIT1);&lt;br /&gt;&lt;br /&gt;Otherwise you should already have a handle to the edit window -- just store it in EditWnd. Then do the actual subclassing:&lt;br /&gt;&lt;br /&gt;DefEditProc = (WNDPROC)GetWindowLong(EditWnd,GWL_WNDPROC);&lt;br /&gt;SetWindowLong(EditWnd,GWL_WNDPROC,(long)MyEditProc);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-8566572222113083477?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/8566572222113083477/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/how-to-trap-enter-key-on-edit-box.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/8566572222113083477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/8566572222113083477'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/how-to-trap-enter-key-on-edit-box.html' title='How to Trap Enter key on Edit Box'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-2499722098042578006</id><published>2009-03-24T17:20:00.000-07:00</published><updated>2009-03-25T07:35:08.036-07:00</updated><title type='text'>Display Last Error</title><content type='html'>&lt;code&gt;&lt;br /&gt;LPVOID lpMsgBuf;&lt;br /&gt;if(SomeHandle==NULL){&lt;br /&gt;FormatMessage(&lt;br /&gt;FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,&lt;br /&gt;NULL,&lt;br /&gt;GetLastError(),&lt;br /&gt;MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language&lt;br /&gt;(LPTSTR) &amp;lpMsgBuf,&lt;br /&gt;0,&lt;br /&gt;NULL&lt;br /&gt;);&lt;br /&gt;// Display the string.&lt;br /&gt;MessageBox( NULL, lpMsgBuf, "GetLastError", MB_OK|MB_ICONINFORMATION );&lt;br /&gt;// Free the buffer.&lt;br /&gt;LocalFree( lpMsgBuf );&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-2499722098042578006?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/2499722098042578006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/display-last-error.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/2499722098042578006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/2499722098042578006'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/display-last-error.html' title='Display Last Error'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-1679237976361541872</id><published>2009-03-24T17:18:00.001-07:00</published><updated>2009-03-25T07:35:51.227-07:00</updated><title type='text'>Attach Menu to  Dialog-based Application</title><content type='html'>1. Create menu resource MYMENU.&lt;br /&gt;2. Use the following code in response to the WM_INITDIALOG message&lt;br /&gt;&lt;code&gt;&lt;br /&gt;HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(MYMENU));&lt;br /&gt;SetMenu( hwnd,hMenu);&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-1679237976361541872?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/1679237976361541872/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/attach-menu-to-dialog-based-application.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/1679237976361541872'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/1679237976361541872'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/attach-menu-to-dialog-based-application.html' title='Attach Menu to  Dialog-based Application'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-921562602448345798</id><published>2009-03-24T17:17:00.000-07:00</published><updated>2009-03-25T07:36:12.569-07:00</updated><title type='text'>Retrieving the Path of the Running Application</title><content type='html'>&lt;code&gt;&lt;br /&gt;int GetAppPath(LPTSTR pstr,int length){&lt;br /&gt;int ret,i;&lt;br /&gt;// this gets the name of the running app&lt;br /&gt;ret=GetModuleHandle(NULL,pstr,length);&lt;br /&gt;if(!ret)return 0;&lt;br /&gt;i=lstrlen(pstr)-1;&lt;br /&gt;for(;i&gt;=0;i--){&lt;br /&gt;// replace backslash with a terminating null&lt;br /&gt; if(pstr[i]==TEXT('\\')){&lt;br /&gt;  pstr[i]=TEXT('\0');&lt;br /&gt;  break;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;return lstrlen(pstr); //return the length of the final string&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-921562602448345798?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/921562602448345798/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/retrieving-path-of-running-application.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/921562602448345798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/921562602448345798'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/retrieving-path-of-running-application.html' title='Retrieving the Path of the Running Application'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7726932685002102918.post-5270952938625881228</id><published>2009-03-24T17:01:00.000-07:00</published><updated>2009-03-25T07:36:44.448-07:00</updated><title type='text'>Attach Icon to the Title bar of  Dialog-based Application</title><content type='html'>&lt;code&gt;&lt;br /&gt;HICON hIcon = LoadIcon (hInst, MAKEINTRESOURCE (DLG_ICON));&lt;br /&gt;SendMessage (hwnd, WM_SETICON, (WPARAM) ICON_SMALL, (LPARAM) hIcon);&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7726932685002102918-5270952938625881228?l=win32-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-tips.blogspot.com/feeds/5270952938625881228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://win32-tips.blogspot.com/2009/03/attach-icon-to-title-bar-of-dialog.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/5270952938625881228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7726932685002102918/posts/default/5270952938625881228'/><link rel='alternate' type='text/html' href='http://win32-tips.blogspot.com/2009/03/attach-icon-to-title-bar-of-dialog.html' title='Attach Icon to the Title bar of  Dialog-based Application'/><author><name>Eric</name><uri>http://www.blogger.com/profile/04738667434492418561</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
