0. How to open the console in the Win32 program and copy the following code:
# Include "Io. H "# include" fcntl. H "Void initconsole () {int nret = 0; file * FP; allocconsole (); // call the window nret = _ open_osfhandle (long) getstdhandle (std_output_handle) that generates the console ), _ o_text); // getstdhandle gets the console handle. If there is no allocconsole (), obtain the standard input/output window handle fp = _ fdopen (nret, "W "); // fdopen () converts the nret file description to the corresponding file pointer and returns * stdout = * FP; setvbuf (stdout, null, _ ionbf, 0 ); // output stream}
The following describes how to right-click a menu in Win32. The steps are as follows:
1: first define three IDM Resources in the header file. These three parameters are very important and will be used when listening for menu click events.
#define IDM_AAA 200#define IDM_BBB 201#define IDM_CCC 202
2. define a global variable
static HMENU hMenu;
3. Add the code in the init () method:
hMenu=CreatePopupMenu();AppendMenu(hMenu,MF_STRING,IDM_AAA,_T("&AAA"));AppendMenu(hMenu,MF_SEPARATOR,0,NULL);AppendMenu(hMenu,MF_STRING,IDM_BBB,_T("&BBB"));AppendMenu(hMenu,MF_STRING,IDM_CCC,_T("&CCC"));
4. Add the right-click response code in wm_rbuttondown of the callback function wndproc.
case WM_RBUTTONDOWN:{ printf("Right"); POINT point; point.x=LOWORD(lParam); point.y=HIWORD(lParam); ClientToScreen(hWnd,&point); TrackPopupMenu(hMenu,TPM_RIGHTALIGN,point.x,point.y,0,hWnd,NULL); break;}
You can also set the status of this field:
CheckMenuItem(hMenu,IDM_AAA,MF_CHECKED);
5. Add the response from the selected menu to the wm_command of the callback function wndproc.
To facilitate the test, add the following code:
cout<<wParam<<endl;
Right-click and view the output table. The selected macro-defined value is displayed. The switch type of this value can be processed without mentioning the table.
0. How to open the console in the Win32 program and copy the following code:
# Include "Io. H "# include" fcntl. H "Void initconsole () {int nret = 0; file * FP; allocconsole (); // call the window nret = _ open_osfhandle (long) getstdhandle (std_output_handle) that generates the console ), _ o_text); // getstdhandle gets the console handle. If there is no allocconsole (), obtain the standard input/output window handle fp = _ fdopen (nret, "W "); // fdopen () converts the nret file description to the corresponding file pointer and returns * stdout = * FP; setvbuf (stdout, null, _ ionbf, 0 ); // output stream}
The following describes how to right-click a menu in Win32. The steps are as follows:
1: first define three IDM Resources in the header file. These three parameters are very important and will be used when listening for menu click events.
#define IDM_AAA 200#define IDM_BBB 201#define IDM_CCC 202
2. define a global variable
static HMENU hMenu;
3. Add the code in the init () method:
hMenu=CreatePopupMenu();AppendMenu(hMenu,MF_STRING,IDM_AAA,_T("&AAA"));AppendMenu(hMenu,MF_SEPARATOR,0,NULL);AppendMenu(hMenu,MF_STRING,IDM_BBB,_T("&BBB"));AppendMenu(hMenu,MF_STRING,IDM_CCC,_T("&CCC"));
4. Add the right-click response code in wm_rbuttondown of the callback function wndproc.
case WM_RBUTTONDOWN:{ printf("Right"); POINT point; point.x=LOWORD(lParam); point.y=HIWORD(lParam); ClientToScreen(hWnd,&point); TrackPopupMenu(hMenu,TPM_RIGHTALIGN,point.x,point.y,0,hWnd,NULL); break;}
You can also set the status of this field:
CheckMenuItem(hMenu,IDM_AAA,MF_CHECKED);
5. Add the response from the selected menu to the wm_command of the callback function wndproc.
To facilitate the test, add the following code:
cout<<wParam<<endl;
Right-click and view the output table. The selected macro-defined value is displayed. The switch type of this value can be processed without mentioning the table.