{"id":295,"date":"2009-05-12T23:34:48","date_gmt":"2009-05-12T18:04:48","guid":{"rendered":"http:\/\/techtwaddle.net\/?p=295"},"modified":"2011-04-12T23:35:18","modified_gmt":"2011-04-12T18:05:18","slug":"applications-creating-a-simple-ui-application-from-scratch-process-viewer-part-2applications-creating-a-simple-ui-application-from-scratch-process-viewer-part-2","status":"publish","type":"post","link":"https:\/\/techtwaddle.co.in\/blog\/2009\/05\/12\/applications-creating-a-simple-ui-application-from-scratch-process-viewer-part-2applications-creating-a-simple-ui-application-from-scratch-process-viewer-part-2\/","title":{"rendered":"Applications: Creating a simple UI application from scratch, Process Viewer, Part 2Applications: Creating a simple UI application from scratch, Process Viewer, Part 2"},"content":{"rendered":"<div style=\"text-align: justify;\"><span style=\"font-family: Comic Sans MS;\">In this series of posts lets go about creating a simple process viewer, as promised earlier. This post is basically based around a <\/span><a style=\"font-family: Comic Sans MS;\" href=\"http:\/\/geekswithblogs.net\/BruceEitman\/archive\/2008\/05\/14\/windows-ce--using-toolhelpapi-to-list-running-processes.aspx\">post<\/a><span style=\"font-family: Comic Sans MS;\"> by Bruce Eitman. We use Toolhelp32 api&#8217;s to get information about the running processes and other info too, like the process id, number of threads running in the process&#8217;s context etc. I recommend reading Bruce&#8217;s post before proceeding here. That will save me time from explaining the backend stuff and I can concentrate on the UI.<\/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;\">Ok, so lets go about creating the UI. Create a program similar to the one I had created in my previous <\/span><a style=\"font-family: Comic Sans MS;\" href=\"http:\/\/geekswithblogs.net\/TechTwaddle\/archive\/2009\/05\/23\/applications-creating-a-simple-ui-application-from-scratch-part-1.aspx\">post<\/a><span style=\"font-family: Comic Sans MS;\">. This dialog contains a List view control and a group box, shown below:<\/span><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br \/>\n<img decoding=\"async\" loading=\"lazy\" width=\"252\" height=\"315\" alt=\"\" src=\"\/images\/geekswithblogs_net\/TechTwaddle\/Process Viewer\/DialogRun.JPG\" \/><\/p>\n<p>\n<span style=\"font-family: Comic Sans MS;\">Set the &quot;<span style=\"font-family: Verdana;\">View<\/span>&quot; property of the list view control as Report, &quot;<span style=\"font-family: Verdana;\">No Column Header<\/span>&quot; to false. I have set the ID to <span style=\"font-family: Verdana;\">IDC_LISTVIEW_PROCESSES<\/span>. Create 3 static text controls to hold the Process id, No of threads and the load address. Add these three static controls into a group box, name the group box &quot;Process Info&quot;. Remember to create the three static text controls before creating the group box. I was trying the other way around, by creating the group box first, the text controls would not show up, they were hidden behind the group box. Invoke this dialog from <span style=\"font-family: Verdana;\">WinMain <\/span>and check that the dialog is showing up correctly. Here is the WinMain function:<\/span><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">int WinMain(HINSTANCE hInst,<\/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;&nbsp;&nbsp; HINSTANCE hPrevInst,<\/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;&nbsp;&nbsp; LPTSTR lpCmdLine,<\/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;&nbsp;&nbsp; int nCmdShow)<\/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<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; INITCOMMONCONTROLSEX icex;<\/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; g_hInst = hInst;<\/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; memset(&amp;icex, 0, sizeof(icex));<\/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; icex.dwSize = sizeof(INITCOMMONCONTROLSEX);<\/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; icex.dwICC = ICC_LISTVIEW_CLASSES;<\/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; InitCommonControlsEx(&amp;icex);<\/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(NULL, L&quot;Hi&quot;, L&quot;Info&quot;, MB_OK);<\/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; DialogBox(hInst, MAKEINTRESOURCE(IDD_PPC_PROCVIEWER), NULL, ProcessViewerDlgProc);<\/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; return 0;<\/span><br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">}<\/span><\/p>\n<p><span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">InitCommonControlsEx()<\/span> <span style=\"font-family: Comic Sans MS;\">is used to register specific common controls classes from the common control dynamic-link library. In this case a List View control. And then there&#8217;s the call to <span style=\"font-family: Verdana;\">DialogBox()<\/span> which shows up our UI.<\/span><\/p>\n<p>About <span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">ProcessViewerDlgProc<\/span>, for now, you could use the same skeleton dialog proc from my previous <a href=\"http:\/\/geekswithblogs.net\/TechTwaddle\/archive\/2009\/05\/23\/applications-creating-a-simple-ui-application-from-scratch-part-1.aspx\">post<\/a>.<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;\">Well, that is all for now. In the next post, we see how to initialise the List View control headers, get the information about the process and populate the list view control with the process names.<\/span>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this series of posts lets go about creating a simple process viewer, as promised earlier. This post is basically based around a post by Bruce Eitman. We use Toolhelp32 api&#8217;s to get information about the running processes and other info too, like the process id, number of threads running in the process&#8217;s context etc. &hellip; <a href=\"https:\/\/techtwaddle.co.in\/blog\/2009\/05\/12\/applications-creating-a-simple-ui-application-from-scratch-process-viewer-part-2applications-creating-a-simple-ui-application-from-scratch-process-viewer-part-2\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Applications: Creating a simple UI application from scratch, Process Viewer, Part 2Applications: Creating a simple UI application from scratch, Process Viewer, 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-4L","_links":{"self":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts\/295"}],"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=295"}],"version-history":[{"count":1,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts\/295\/revisions"}],"predecessor-version":[{"id":296,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts\/295\/revisions\/296"}],"wp:attachment":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/media?parent=295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/categories?post=295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/tags?post=295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}