40 likes | 155 Views
Usin g Visua l Studi o t o Creat e a Win32 API Application with a Menu and an Icon. Open Visua l Studio , ope n a Ne w Project creat e a n empt y Win3 2 application Creat e a ne w Visua l C+ + sourc e file , typ e or past e i n th e cod e (winapp2.cpp) ,
E N D
UsingVisualStudiotoCreatea Win32APIApplicationwitha MenuandanIcon
OpenVisualStudio, • openaNewProject • createanemptyWin32application • CreateanewVisualC++sourcefile, • typeor pasteinthecode(winapp2.cpp), • saveitasa C++ source file in the app’s subdirectory • must have: #include “resource.h” • Addittotheproject • Create the Icon Resource (and the .rcfile) • Select‘Project|AddResource|Icon|New’– Bringsupiconeditor • Draw desired icon • Click on IDI_ICON1 in “Resource View” to bring up the “Properties” window and change the icon ID to “MYICON”- don't forget the quote marks • Give a name to .ico file (or leave the default name)
Select‘Project|AddResource|Menu|New’ This bringsupthemenueditor • Type the caption: &Circle in the “Type Here” rectangle • Inresulting"Properties"box,Select“False”for“Pop- up” • Click on the Circle menu item to bring up the “Properties”box again. • NotethedefaultIDofID_CIRCLE • Click on the next rectangle over in the menu editor • Repeattheabove 5 stepsusingcaption:&Rectangle • Keep the default IDs • Repeatfor: • Clear&Screen,&Quitmenuitems • Keep default IDs
Clickon“IDI_MENU1”in“ResourceView” tobringupthe“Properties”windowand changethemenuIDto“MYMENU”- • Don’tforgetthequotemarks • Buildtheproject