Ressource



  • Warum hat mein Fenster immernoch kein Menü?
    Ich habe wndclass.lpszMenuName = szAppName ; gesetzt
    und ein Menü über den Ressource Editor hinzugefügt mit Datei und bearbeiten punkte.
    Aber das Menü wird nicht angezeigt waruM?



  • Sollte funzen, haste mal den Code parat???



  • #include <windows.h>
    #include "resource.h"
    
    LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
    
    int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                        PSTR szCmdLine, int iCmdShow)
    {
         static TCHAR szAppName[] = TEXT ("Menü") ;
         HWND         hwnd ;
         MSG          msg ;
         WNDCLASS     wndclass ;
    
         wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
         wndclass.lpfnWndProc   = WndProc ;
         wndclass.cbClsExtra    = 0 ;
         wndclass.cbWndExtra    = 0 ;
         wndclass.hInstance     = hInstance ;
         wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
         wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
         wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
         wndclass.lpszMenuName  = szAppName ;
         wndclass.lpszClassName = szAppName ;
    
         if (!RegisterClass (&wndclass))
         {    // UNICODE-Compilierung ist die einzige realistische Fehlermöglichkeit 
              MessageBox (NULL, TEXT ("Programm arbeitet mit Unicode und setzt Windows NT voraus!"), 
                          szAppName, MB_ICONERROR) ;
              return 0 ;
         }
    
          hwnd = CreateWindow (szAppName,                 // Name der Fensterklasse
                      szAppName,                         // Fenstertitel
                      WS_OVERLAPPEDWINDOW,                // Fensterstil
                      CW_USEDEFAULT,                      // X-Position des Fensters
                      CW_USEDEFAULT,                      // Y-Position des Fensters
                      CW_USEDEFAULT,                      // Fensterbreite
                      CW_USEDEFAULT,                      // Fensterhöhe
                      NULL,                               // übergeordnetes Fenster
                      NULL,                               // Menü
                      hInstance,                          // Programm-Kopiezähler (Programm-ID)
                      NULL) ;                             // zusätzliche Parameter
    
         ShowWindow (hwnd, iCmdShow) ;
         UpdateWindow (hwnd) ;
    
         while (GetMessage (&msg, NULL, 0, 0))
         {
              TranslateMessage (&msg) ;
              DispatchMessage (&msg) ;
         }
         return msg.wParam ;
    }
    
    LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    
         switch (message)
         {
         case WM_CREATE:
              return 0 ;
         case WM_DESTROY:
              PostQuitMessage (0) ;
              return 0 ;
         }
         return DefWindowProc (hwnd, message, wParam, lParam) ;
    }
    




  • Die Resource heißt ja auch IDR_MENU1 mach mal wnd.lpszMenuName = (LPCSTR)IDR_MENU1;



  • danke sehr



  • ➡ MAKEINTRESOURCE() 😉 .


Anmelden zum Antworten