none
cancel the help and file button in windows api RRS feed

  • Question

  • I have a question!How to cancel the file and help button when I CreateWindow in windows api C++?
    Monday, September 23, 2019 3:02 AM

All replies

  • Hello,

    Thank you for posting here.

    >>How to cancel the file and help button when I CreateWindow in windows api C++?

    Set lpszMenuName as NULL when registering window classes, there will be no menu.

    ATOM MyRegisterClass(HINSTANCE hInstance)
    {
        WNDCLASSEXW wcex;
    
        wcex.cbSize = sizeof(WNDCLASSEX);
    
        wcex.style          = CS_HREDRAW | CS_VREDRAW;
        wcex.lpfnWndProc    = WndProc;
        wcex.cbClsExtra     = 0;
        wcex.cbWndExtra     = 0;
        wcex.hInstance      = hInstance;
        wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WINDOWSPROJECT3));
        wcex.hCursor        = LoadCursor(nullptr, IDC_ARROW);
        wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
    	wcex.lpszMenuName   = NULL;//MAKEINTRESOURCEW(IDC_WINDOWSPROJECT3);
        wcex.lpszClassName  = szWindowClass;
        wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
    
        return RegisterClassExW(&wcex);
    }

    Best Regards,

    Suarez Zhou

    Monday, September 23, 2019 5:15 AM
  • Hello,

    you can create your own menu without file new and help menu items.

    https://stackoverflow.com/questions/30135494/win32-api-c-menu-bar

    https://docs.microsoft.com/en-us/windows/win32/menurc/menus

    Or in WndProc you catch the WM_COMMAND of IDM_FILE_NEW and IDM_ABOUT and do nothing.

    switch (message)
        {
        case WM_COMMAND:
            wmId    = LOWORD(wParam);
            wmEvent = HIWORD(wParam);
            // Parse the menu selections:
            switch (wmId)
            {
            case IDM_ABOUT:
            case IDM_FILE_NEW:
                //do nothing
                break;
    ...
    

    Regards, Guido

    Monday, September 23, 2019 6:17 AM