{"id":315,"date":"2009-04-12T23:40:01","date_gmt":"2009-04-12T18:10:01","guid":{"rendered":"http:\/\/techtwaddle.net\/?p=315"},"modified":"2011-04-12T23:40:18","modified_gmt":"2011-04-12T18:10:18","slug":"applications-creating-a-simple-ui-application-for-windows-mobile-6-using-visual-studio-2005-part-2","status":"publish","type":"post","link":"https:\/\/techtwaddle.co.in\/blog\/2009\/04\/12\/applications-creating-a-simple-ui-application-for-windows-mobile-6-using-visual-studio-2005-part-2\/","title":{"rendered":"Applications: Creating a simple UI application for Windows Mobile 6 using Visual Studio 2005: Part 2"},"content":{"rendered":"<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\">Ok now that we have our basic application up and running, lets make some changes. First, I want to change the right soft key from &quot;HELP&quot; to &quot;Menu&quot;, somehow &quot;HELP&quot; is not very appealing. One more thing, I use the resource editor only to add new resources to the project, any further changes or modification I like to do it by manually editing the resource files (To do that, just right click on the .rc file and select &quot;View Code&quot;).<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\">If you open HelloWorld.cpp and in function <span style=\"font-family: Courier New;\">WndProc<\/span> go to the case where <span style=\"font-family: Courier New;\">WM_CREATE<\/span> is handled, you will see that the menu bar is getting created there using the <span style=\"font-family: Courier New;\">SHCreateMenuBar <\/span>api. The nToolBarId member of <span style=\"font-family: Courier New;\">SHMENUBARINFO <\/span>contains <span style=\"font-family: Courier New;\">IDR_MENU<\/span>, which is the resource identifier of the menu bar. Now open HelloWorldppc.rc2 and you will see that the menu bar is defined as below:<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">IDR_MENU SHMENUBAR DISCARDABLE<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">BEGIN<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; IDR_MENU_POPUP, <\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; 2,<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; I_IMAGENONE, IDM_OK, TBSTATE_ENABLED, TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE,<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; IDS_OK, 0, NOMENU,<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; <\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; I_IMAGENONE, IDM_HELP, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; IDS_HELP, 0, 0,<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">END<\/span><br style=\"font-family: Tahoma;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\">The first line says that <span style=\"font-family: Courier New;\">IDR_MENU<\/span> is a menubar. Everything in between <span style=\"font-family: Courier New;\">BEGIN <\/span>and <span style=\"font-family: Courier New;\">END<\/span> defines the menu bar. The first line under BEGIN identifies the popup menu which will be displayed when the user clicks on the MENU. If your MENUBAR does not have any popup menu&#8217;s, then you can specify a value of 0 here. In this case, the popup menu that will be displayed here, when the user clicks on &quot;Menu&quot; is IDR_MENU_POPUP, which we will define later. &quot;2&quot; specifies that the menu bar will have two entries, one left soft key and one right soft key. The first entry after &quot;2&quot; defines the left soft key and the next entry defines the right softkey. You can see that the left entry is for &quot;OK&quot; and the right entry is for &quot;HELP&quot;. We will not change the first entry. Lets modify the second entry so that it defines our new entry, which is &quot;Menu&quot;. So we change<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; I_IMAGENONE, IDM_HELP, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, <\/span><span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">IDS_HELP, 0, 0,<\/span><br style=\"font-family: Courier New;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\">to<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp; &nbsp; &nbsp;&nbsp; I_IMAGENONE, IDM_MENU, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_MENU, 0, 0,<\/span><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\">This change is not absolutely necessary but I like to name my variables just right.<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\">Now open resourceppc.h and make the same changes. Rename <span style=\"font-family: Courier New;\">IDS_HELP<\/span> to <span style=\"font-family: Courier New;\">IDS_MENU<\/span> and <span style=\"font-family: Courier New;\">IDM_HELP<\/span> to <span style=\"font-family: Courier New;\">IDM_MENU<\/span>. A few more changes and we are done. Open HelloWorld.rc and search for the string table that defines the value for <span style=\"font-family: Courier New;\">IDS_HELP<\/span>. Will be something like:<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">STRINGTABLE&nbsp; <\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">BEGIN<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp; .<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp; .<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp; IDS_HELP&nbsp;&nbsp;&nbsp; &quot;HELP&quot;<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">END<\/span><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<span style=\"font-family: Comic Sans MS;\">Change this to:<\/span><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">STRINGTABLE&nbsp; <\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\"> BEGIN<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\"> &nbsp;&nbsp; .<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\"> &nbsp;&nbsp; .<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\"> &nbsp;&nbsp; IDS_MENU &nbsp;&nbsp; &quot;Menu&quot;<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\"> END<\/span><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\">The items under the popup menu will be defined in HelloWorld.rc file. Although you can define it .rc2 file as well, but by default it will be present in the .rc file.<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">IDR_MENU_POPUP MENU DISCARDABLE <\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">BEGIN<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; POPUP &quot;Help&quot;<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; BEGIN<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MENUITEM &quot;About&quot;,&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; IDM_HELP_ABOUT<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; END<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">END<\/span><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\">This defines our original right soft key menu which is a popup. Change this entry so that &quot;Menu&quot; shows up instead of &quot;HELP&quot;:<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">IDR_MENU_POPUP MENU DISCARDABLE <\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\"> BEGIN<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\"> &nbsp;&nbsp;&nbsp; POPUP &quot;Menu&quot;<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\"> &nbsp;&nbsp;&nbsp; BEGIN<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MENUITEM &quot;About&quot;,&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; IDM_HELP_ABOUT<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\"> &nbsp;&nbsp;&nbsp; END<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\"> END<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\">Thats it. The right soft key should now be renamed to &quot;Menu&quot;. You might think that this is a lot of work just to rename a menu entry. But its not much. The changes in the .rc2 file were just for the sake of naming convention and you can leave that part if you wish but make sure that all your ID*_ macros are in sync.<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\">Build the project and run. The application should now look like this:<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<img decoding=\"async\" loading=\"lazy\" width=\"350\" height=\"544\" alt=\"\" style=\"font-family: Comic Sans MS;\" src=\"\/images\/geekswithblogs_net\/TechTwaddle\/HelloWorld\/HelloWorld2.JPG\" \/><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\">Lets quickly add one more entry under Menu called &quot;System Metric&quot;, which will show the screen width and height in a message box. Adding a menu entry is simple. Open HelloWorld.rc file where the popup items for the right menu are defined. They will be defined like this:<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">IDR_MENU_POPUP MENU DISCARDABLE <\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">BEGIN<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; POPUP &quot;Menu&quot;<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; BEGIN<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MENUITEM &quot;About&quot;,&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; IDM_HELP_ABOUT<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; END<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">END<\/span><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\">Just add another <span style=\"font-family: Courier New;\">MENUITEM <\/span>entry for &quot;System Metric&quot;:<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">IDR_MENU_POPUP MENU DISCARDABLE <\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">BEGIN<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; POPUP &quot;Menu&quot;<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; BEGIN<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; MENUITEM &quot;System Metric&quot;,&nbsp;&nbsp;&nbsp; IDM_SYSTEM_METRIC<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MENUITEM &quot;About&quot;,&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; IDM_HELP_ABOUT<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; END<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">END<\/span><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\"><span style=\"font-family: Courier New;\">IDM_SYSTEM_METRIC<\/span> is the command (or simply a number) that will be sent to our application when the user selects it. So you need to define this in the resourceppc.h header file so that the compiler can find it. You can add a menu separator by adding <span style=\"font-family: Courier New;\">MENUITEM SEPARATOR<\/span> as one of the items in the menu.<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\">Add&nbsp; &quot;<span style=\"font-family: Courier New;\">#define IDM_SYSTEM_METRIC 40003<\/span>&quot; to resourceppc.h. I chose 40003 because that number wasn&#8217;t yet used in my header file. The number doesn&#8217;t matter, just make sure that the number you use is unique and is not used already in this or some other header file. In large projects with many resources this could get messy, manually keeping track of numbers. When creating resources using the resource editor these entries are automatically created and unique.<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\">Now we need to handle this menu item. That is, what happens when the user clicks on it. When the user selects the menu item, a <span style=\"font-family: Courier New;\">WM_COMMAND<\/span> will be sent to our application. This will end up in WndProc function. The <span style=\"font-family: Courier New;\">LPARAM <\/span>and <span style=\"font-family: Courier New;\">WPARAM <\/span>parameters will contain more information about which item in our application caused the <span style=\"font-family: Courier New;\">WM_COMMAND<\/span> message to be sent. In the <span style=\"font-family: Courier New;\">WndProc <\/span>function go the section which is handling <span style=\"font-family: Courier New;\">WM_COMMAND.<\/span> Under <span style=\"font-family: Courier New;\">WM_COMMAND<\/span> handling you will see that other messages like <span style=\"font-family: Courier New;\">IDM_HELP_ABOUT<\/span> and <span style=\"font-family: Courier New;\">ID_OK<\/span> are already being handled. This is where we need to add the entry for our <span style=\"font-family: Courier New;\">IDM_SYSTEM_METRIC<\/span>. Create the following entry just after the <span style=\"font-family: Courier New;\">IDM_OK<\/span> case:<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">case IDM_SYSTEM_METRIC:<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">{<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; int width = -1, height = -1;<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; WCHAR wOutStr[64] = L&quot;&quot;;<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; WCHAR wCaption[16] = L&quot;&quot;;<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; width =&nbsp; GetSystemMetrics(SM_CXSCREEN);<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; height = GetSystemMetrics(SM_CYSCREEN);<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; if(!width || !height)<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; {<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wsprintf(wOutStr, L&quot;Failed to get system metrics.&quot;);<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wsprintf(wCaption, L&quot;Error&quot;);<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; }<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; else<\/span><br style=\"font-family: Courier New;\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; {<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wsprintf(wOutStr, L&quot;System width :%d\\nSystem Height:%d&quot;, width, height);<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; wsprintf(wCaption, L&quot;Info&quot;);<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; }<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">&nbsp;&nbsp;&nbsp; MessageBox(hWnd, wOutStr, wCaption, MB_OK);<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">}<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">break;<\/span><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\"><font size=\"3\">In the message handling I use the <span style=\"font-family: Courier New;\">GetSystemMetrics<\/span> api to get the system width and system height values. If the api&#8217;s return error (zero) I contruct an error string otherwise I construct a string with the values I got and then show the string using a MessageBox. Simple.<br \/>\n<\/font><\/div>\n<p><font size=\"3\"><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<span style=\"font-family: Comic Sans MS;\">This is how the UI looks:<\/span><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<img decoding=\"async\" loading=\"lazy\" width=\"347\" height=\"543\" alt=\"\" style=\"font-family: Comic Sans MS;\" src=\"\/images\/geekswithblogs_net\/TechTwaddle\/HelloWorld\/HelloWorld3.JPG\" \/><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<span style=\"font-family: Comic Sans MS;\">and,<\/span><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<img decoding=\"async\" loading=\"lazy\" width=\"347\" height=\"542\" alt=\"\" style=\"font-family: Comic Sans MS;\" src=\"\/images\/geekswithblogs_net\/TechTwaddle\/HelloWorld\/HelloWorld4.JPG\" \/><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br \/>\n<a href=\"http:\/\/geekswithblogs.net\/TechTwaddle\/archive\/2009\/04\/15\/applications-creating-a-simple-ui-application-for-windows-mobile-6.aspx\">Part 1<\/a><br \/>\n<a href=\"http:\/\/geekswithblogs.net\/TechTwaddle\/archive\/2009\/04\/26\/applications-creating-a-simple-ui-application-for-windows-mobile-6-yet-again.aspx\">Part 3<\/a><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ok now that we have our basic application up and running, lets make some changes. First, I want to change the right soft key from &quot;HELP&quot; to &quot;Menu&quot;, somehow &quot;HELP&quot; is not very appealing. One more thing, I use the resource editor only to add new resources to the project, any further changes or modification &hellip; <a href=\"https:\/\/techtwaddle.co.in\/blog\/2009\/04\/12\/applications-creating-a-simple-ui-application-for-windows-mobile-6-using-visual-studio-2005-part-2\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Applications: Creating a simple UI application for Windows Mobile 6 using Visual Studio 2005: Part 2<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1ktFF-55","_links":{"self":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts\/315"}],"collection":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/comments?post=315"}],"version-history":[{"count":1,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts\/315\/revisions"}],"predecessor-version":[{"id":316,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts\/315\/revisions\/316"}],"wp:attachment":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/media?parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/categories?post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/tags?post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}