I'm trying to learn some basic win32 api. I see to add items to the menu bar tutorials have mentioned to use something like:
hMenubar = CreateMenu();
hMenu = CreateMenu();
AppendMenuW(hMenu, MF_STRING, IDM_FILE_NEW, L"&New");
AppendMenuW(hMenu, MF_STRING, IDM_FILE_OPEN, L"&Open");
AppendMenuW(hMenu, MF_SEPARATOR, 0, NULL);
AppendMenuW(hMenu, MF_STRING, IDM_FILE_QUIT, L"&Quit");
AppendMenuW(hMenubar, MF_POPUP, (UINT_PTR)hMenu, L"&File");
But in the default project for C++ Desktop in VS2013 has a File and Help menubar and inside they have Exit and About. But all they do is have a switch like this in WndProc:
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
I have a few questions. How is it they add the file and help menu bars, as well as the about and exit items in the menubars without using the createmenu() and such? WHat does IDM_ABOUT and IDM_EXIT mean? They have those in the menus, but does just putting them in the switch statement add them to the menubars? What is wmId and wmEvent and why is the switch on wmId? What is actually adding those items to the menu bar?
If you need to see more code of my program it's just a non blank C++ Win32 Project in VS2013
Thanks for any answers provided, and it would be appreicated if someone could point me in the direction of a good current as possible win32 api C++ tutorial.
and it would be appreicated if someone could point me in the direction of a good current as possible win32 api C++ tutorial
Any book by Charles Petzold. – PaulMcKenzie