c winapi kein menu aus resource datei



  • Das icon funktioniert.wird angezeigt als exe icon.der code ist wie aus allen online tutorials.hab die syntax gecheckt.trotzdem kein menu.hat einer n code der funzt bitte


  • Mod

    Zeig mal was DU hast.
    Du kannst tausendmal sagen, dass alles richtig und gechecked wurde.

    Bei Deiner Orthographie Und Stil glaube ich Dir nicht. ­čśë



  • was n jetz ortographie.ne man bin newb.also check ma einer von euch wenn ihr zeit habt den code:

    unbnannt.c

    #include "main.h"
    
    /////////////////////////////////////////////////////////////////
    //
    // Men├╝ Deutsch
    //
    
    IDR_MENU1 MENU
    BEGIN
        POPUP "Datei"
        BEGIN
            MENUITEM "├ľffnen",           ID_FILE_OPEN
            MENUITEM "Speichern",        ID_FILE_SAVE   GRAYED
            MENUITEM SEPARATOR
            MENUITEM "Ende",             ID_FILE_EXIT
        END
        POPUP "Sprache"
        BEGIN
            POPUP "Sprachen"
            BEGIN
         MENUITEM "Deutsch",      ID_OPTIONS_OPTIONS_OPTION1  CHECKED
         MENUITEM "Englisch",     ID_OPTIONS_OPTIONS_OPTION2
            END
        END
        MENUITEM "├ťber",                 ID_ABOUT
    END
    
    /////////////////////////////////////////////////////////////////
    //
    // Men├╝ Englisch
    //
    
    IDR_MENU2 MENU
    BEGIN
        POPUP "File"
        BEGIN
            MENUITEM "Open",             ID_FILE_OPEN
            MENUITEM "Save",             ID_FILE_SAVE   GRAYED
            MENUITEM SEPARATOR
            MENUITEM "Exit",             ID_FILE_EXIT
        END
        POPUP "Languages"
        BEGIN
            POPUP "Languages"
            BEGIN
         MENUITEM "German",       ID_OPTIONS_OPTIONS_OPTION1
         MENUITEM "English",      ID_OPTIONS_OPTIONS_OPTION2  CHECKED
            END
        END
        MENUITEM "About",                ID_ABOUT
    END
    
    /////////////////////////////////////////////////////////////////
    //
    //Icon
    //
    
    My_ICON              ICON        "console.ico"
    
    /////////////////////////////////////////////////////////////////
    //
    //Stringtabelle Deutsch
    //
    STRINGTABLE
    BEGIN
            ID_STRING_OPEN,      "Der Dialog ├ľffnen"
            ID_STRING_SAVE,      "Der Dialog Speichern"
            ID_STRING_ABOUT,     "Ein Men├╝-Beispiel\nCoded by J.Wolf"
    END
    
    /////////////////////////////////////////////////////////////////
    //
    //Stringtabelle Englisch
    //
    STRINGTABLE
    BEGIN
            ID_STRING_OPEN_E,      "The Dialog Open"
            ID_STRING_SAVE_E,      "The Dialog Save"
            ID_STRING_ABOUT_E,     "A Menu-Example\nCoded by J.Wolf"
    END
    

    resource.c

    #if defined(UNICODE) && !defined(_UNICODE)
        #define _UNICODE
    #elif defined(_UNICODE) && !defined(UNICODE)
        #define UNICODE
    #endif
    
    #include <windows.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    #include <main.h>
    
    LPCSTR MainClassName = "Ein Men├╝-Beispiel";
    
    LRESULT CALLBACK WndProc(HWND hWnd,UINT iMsg,HINSTANCE hInst,
                             WPARAM wParam, LPARAM lParam);
    
    //Globale Variable fuer Programm-Instanz
    HINSTANCE hInst;
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                       LPCSTR szCmdLine, int iCmdShow)
    {
       WNDCLASSEX wcex;
       MSG imsg;
       HWND hWnd;
    
       wcex.cbSize = sizeof(WNDCLASSEX);
       wcex.style = 0;
       wcex.lpfnWndProc = WndProc;
       wcex.cbClsExtra = 0;
       wcex.cbWndExtra = 0;
       wcex.hInstance = hInstance;
       wcex.hIcon = LoadIcon(GetModuleHandle(NULL),
                                    MAKEINTRESOURCE(MY_ICON));
       wcex.hCursor         = LoadCursor(NULL, IDC_ARROW);
       wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
       wcex.lpszMenuName  = MAKEINTRESOURCE(IDR_MENU1);
       wcex.lpszClassName = MainClassName;
       wcex.hIconSm         = (HICON)LoadImage(GetModuleHandle(NULL),
                                            MAKEINTRESOURCE(MY_ICON),
                                            IMAGE_ICON, 16, 16, 0);
    
       if(!RegisterClassEx(&wcex))
          {
           MessageBox(NULL, "Windows Registrations Fehler", "Error!",
                      MB_ICONEXCLAMATION | MB_OK);
           return 0;
          }
    
        hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, MainClassName,
                              "Men├╝ Beispiel",
                              WS_OVERLAPPEDWINDOW|WS_VISIBLE,
                              CW_USEDEFAULT, CW_USEDEFAULT,
                              300,150,NULL,NULL,hInstance, NULL);
    
    //globale Programm-Instanz initialisieren
    hInst = hInstance;
    
        if(hWnd == NULL)
        {
              MessageBox(NULL, "Fehler beim Erstellen des Fensters!",
              "Error!",        MB_ICONEXCLAMATION | MB_OK);
              return 0;
        }
    
    while(GetMessage(&imsg,NULL,0,0))
       {
          TranslateMessage(&imsg);
          DispatchMessage(&imsg);
       }
       return wmsg.wParam;
    }
    
    LRESULT CALLBACK WndProc(HWND hWnd,UINT iMsg,
                             WPARAM wParam, LPARAM lParam)
    {
       char string[255];
       HMENU hMenu = GetMenu(hWnd);
       UINT uState = GetMenuState(hMenu,
                                  ID_OPTIONS_OPTIONS_OPTION1,
                                  MF_BYCOMMAND);
    
    switch (iMsg)
          {
             case WM_CLOSE:
                DestroyWindow(hWnd);
                break;
             case WM_DESTROY:
                PostQuitMessage(0);
                return 0;
             case WM_COMMAND:
                switch(LOWORD(wParam))
                   {
                     case ID_FILE_OPEN:
                     if(uState & MFS_CHECKED){
                     LoadString(GetModuleHandle(NULL),
                                ID_STRING_OPEN,
                                string, sizeof(string));
                                }
                     else{
                     LoadString(GetModuleHandle(NULL),
                                ID_STRING_OPEN_E,
                                string, sizeof(string));
                     }
                     MessageBox(hWnd,string,
                                "Dialog",MB_ICONINFORMATION);
                     break;
                     case ID_FILE_SAVE:
                     if(uState & MFS_CHECKED){
                     LoadString(GetModuleHandle(NULL),
                                ID_STRING_SAVE,
                                string, sizeof(string));
                                }
                     else{
                     LoadString(GetModuleHandle(NULL),
                                ID_STRING_SAVE_E,
                                string, sizeof(string));
                     }
                     MessageBox(hWnd,string,
                                "Dialog",MB_ICONINFORMATION);
                     break;
                     case ID_OPTIONS_OPTIONS_OPTION1:
                   SetMenu(hWnd, LoadMenu(hInst,
                           MAKEINTRESOURCE(IDR_MENU1)));
                   break;
                   case ID_OPTIONS_OPTIONS_OPTION2:
                   SetMenu(hWnd, LoadMenu(hInst,
                           MAKEINTRESOURCE(IDR_MENU2)));
                  break;
                   case ID_\1:
                     if(uState & MFS_CHECKED){
                     LoadString(GetModuleHandle(NULL),
                                ID_STRING_ABOUT,
                                string, sizeof(string));
                                }
                     else{
                     LoadString(GetModuleHandle(NULL),
                                ID_STRING_ABOUT_E,
                                string, sizeof(string));
                     }
                   MessageBox(hWnd,string,"Dialog",
                              MB_ICONINFORMATION);
                   break;
                   case ID_FILE_EXIT:
                      DestroyWindow(hWnd);
                      break;
             }
            break;
          }
       return DefWindowProc(hWnd,iMsg,wParam,lParam);
    }
    

    main.h

    #include <windows.h>
    
    //Stringtabelle: Deutsch
    #define ID_STRING_OPEN                  1
    #define ID_STRING_SAVE                  2
    #define ID_STRING_ABOUT                 5
    //Stringtabelle: Englisch
    #define ID_STRING_OPEN_E                 6
    #define ID_STRING_SAVE_E                 7
    #define ID_STRING_ABOUT_E                8
    //Men├╝: Deutsch
    #define IDR_MENU1                       101
    //Men├╝: Englisch
    #define IDR_MENU2                       102
    
    #define ID_ICON                         111
    
    #define ID_FILE_OPEN                    40001
    #define ID_FILE_SAVE                    40002
    #define ID_FILE_EXIT                    40003
    #define ID_OPTIONS_OPTIONS_OPTION1      40004
    #define ID_OPTIONS_OPTIONS_OPTION2      40005
    #define ID_ABOUT                        65535
    

    icon wird als exe datei symbol gezeigt aber menu nicht.ich will bloss das endlich mal die sch... resourcendatei mal funktioniert.wie gesagt.icon wird angezeigt ,ist aber nicht im c code also muss der pc doch doch was erkennen.helt mir bitte



  • Lerne erstmal deinen Code vern├╝nftig zu formatieren (ist keine Raketenwissenschaft). Dann liest es evtl. auch Einer.



  • code formatieren.was.scheiss drauf hab n menu das auf rc basis funktioniert in den examples im devcpp gefunden


Log in to reply