Win32 API C ++ Menu Bar

I am trying to learn some basic win32 api. I see to add items to the menu tutorials that are mentioned in order 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 there is a File and Help menu, and inside they have an Exit and an About. But all they have is a switch 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 do they add files and help menu panels as well as menu items and exits without using createmenu (), etc.? What does IDM_ABOUT and IDM_EXIT mean? Do they have those in the menu, but just put them in a switch statement, adding them to the menu? What are wmId and wmEvent and why is the switch enabled wmId? What actually adds these items to the menu bar?

, ++ Win32 VS2013

, , - , , win32 api ++.

+4
1

. , , . *.rc. " ". , "". // . .

, WPARAM wParam. wmEvent , .

IDM_ABOUT - , #define IDM_ABOUT 101 ( ). , . .

WinApi, 10 20 , , Google, .

, , Visual Studio . , . , F4, " ".

, "& File New", ID_FILE_NEWFILE, " ".

IDM_ABOUT. Windows Procedure, .

:

  • message WM_COMMAND
  • wParam -
  • lParam
+4

All Articles