Menus creation problem
-
Hi fellows. I created an app that have 2 menus. The code for these menus are below:
hMenu1 = CreateMenu(); hMenu2 = CreateMenu(); hSubMenu1 = CreateMenu(); hSubMenu2 = CreateMenu(); unsigned int uiParams[5]; unsigned int uiNums[5]; unsigned int uiSize = 5; char cNames[][256] = {"&Menu", "&Estudo Anatômico", "M&odelo com Transparência", "", "&Sair"}; uiParams[0] = MF_STRING|MF_POPUP; uiParams[1] = uiParams[2] = uiParams[4] = MF_STRING; uiParams[3] = MF_SEPARATOR; uiNums[0] = 0; uiNums[1] = 1; uiNums[2] = 2; uiNums[3] = 3; uiNums[4] = 4; MenuCreator(hMenu1, hSubMenu1, uiParams, uiNums, cNames, uiSize); SetMenu(hwnd, hMenu1); DrawMenuBar(hwnd); char cNames2[][256] = {"&Controles", "&Habilitar/Desabilitar Controles"}; uiParams[0] = MF_STRING|MF_POPUP; uiParams[1] = MF_STRING; uiNums[0] = 5; uiNums[1] = 6; uiSize = 2; MenuCreator(hMenu2, hSubMenu2, uiParams, uiNums, cNames2, uiSize); SetMenu(hwnd, hMenu2);
I have a function that create menus dynamically. Here it is:void MenuCreator(HMENU hParentMenu, HMENU hChildMenu, unsigned int uiBehaviors[], unsigned int uiIDItems[], char cNameItems[][256], unsigned int uiSize) { if(hParentMenu == NULL || (hParentMenu == NULL && hChildMenu != NULL)) { MessageBox(NULL, "Menu pai não pode ser nulo", "Erro", MB_OK|MB_ICONERROR); return; } if(hParentMenu != NULL && hChildMenu != NULL) { for(int i = 1 ; i < uiSize ; i++)AppendMenu(hChildMenu, uiBehaviors[i], uiIDItems[i], cNameItems[i]); AppendMenu(hParentMenu, uiBehaviors[0], (unsigned int)hChildMenu, cNameItems[0]); return; } if(hParentMenu != NULL && hChildMenu == NULL) { for(int i = 0 ; i < uiSize ; i++) { AppendMenu(hChildMenu, uiBehaviors[i], uiIDItems[i], cNameItems[i]); } return; } }
when I insert the first menu, works fine. When I insert the other, the first menu isn't there, just the second. What I want to do is to have 2 or more menus at the same time, like File|Edit|View. What's going on? Thanks -
Hi fellows. I created an app that have 2 menus. The code for these menus are below:
hMenu1 = CreateMenu(); hMenu2 = CreateMenu(); hSubMenu1 = CreateMenu(); hSubMenu2 = CreateMenu(); unsigned int uiParams[5]; unsigned int uiNums[5]; unsigned int uiSize = 5; char cNames[][256] = {"&Menu", "&Estudo Anatômico", "M&odelo com Transparência", "", "&Sair"}; uiParams[0] = MF_STRING|MF_POPUP; uiParams[1] = uiParams[2] = uiParams[4] = MF_STRING; uiParams[3] = MF_SEPARATOR; uiNums[0] = 0; uiNums[1] = 1; uiNums[2] = 2; uiNums[3] = 3; uiNums[4] = 4; MenuCreator(hMenu1, hSubMenu1, uiParams, uiNums, cNames, uiSize); SetMenu(hwnd, hMenu1); DrawMenuBar(hwnd); char cNames2[][256] = {"&Controles", "&Habilitar/Desabilitar Controles"}; uiParams[0] = MF_STRING|MF_POPUP; uiParams[1] = MF_STRING; uiNums[0] = 5; uiNums[1] = 6; uiSize = 2; MenuCreator(hMenu2, hSubMenu2, uiParams, uiNums, cNames2, uiSize); SetMenu(hwnd, hMenu2);
I have a function that create menus dynamically. Here it is:void MenuCreator(HMENU hParentMenu, HMENU hChildMenu, unsigned int uiBehaviors[], unsigned int uiIDItems[], char cNameItems[][256], unsigned int uiSize) { if(hParentMenu == NULL || (hParentMenu == NULL && hChildMenu != NULL)) { MessageBox(NULL, "Menu pai não pode ser nulo", "Erro", MB_OK|MB_ICONERROR); return; } if(hParentMenu != NULL && hChildMenu != NULL) { for(int i = 1 ; i < uiSize ; i++)AppendMenu(hChildMenu, uiBehaviors[i], uiIDItems[i], cNameItems[i]); AppendMenu(hParentMenu, uiBehaviors[0], (unsigned int)hChildMenu, cNameItems[0]); return; } if(hParentMenu != NULL && hChildMenu == NULL) { for(int i = 0 ; i < uiSize ; i++) { AppendMenu(hChildMenu, uiBehaviors[i], uiIDItems[i], cNameItems[i]); } return; } }
when I insert the first menu, works fine. When I insert the other, the first menu isn't there, just the second. What I want to do is to have 2 or more menus at the same time, like File|Edit|View. What's going on? ThanksProblem solved, I was create 2 main menus. So, when I insert the other main menu it was overlapping the other. I deleted the other main menu and add the items in only 1 main menu
-
Hi fellows. I created an app that have 2 menus. The code for these menus are below:
hMenu1 = CreateMenu(); hMenu2 = CreateMenu(); hSubMenu1 = CreateMenu(); hSubMenu2 = CreateMenu(); unsigned int uiParams[5]; unsigned int uiNums[5]; unsigned int uiSize = 5; char cNames[][256] = {"&Menu", "&Estudo Anatômico", "M&odelo com Transparência", "", "&Sair"}; uiParams[0] = MF_STRING|MF_POPUP; uiParams[1] = uiParams[2] = uiParams[4] = MF_STRING; uiParams[3] = MF_SEPARATOR; uiNums[0] = 0; uiNums[1] = 1; uiNums[2] = 2; uiNums[3] = 3; uiNums[4] = 4; MenuCreator(hMenu1, hSubMenu1, uiParams, uiNums, cNames, uiSize); SetMenu(hwnd, hMenu1); DrawMenuBar(hwnd); char cNames2[][256] = {"&Controles", "&Habilitar/Desabilitar Controles"}; uiParams[0] = MF_STRING|MF_POPUP; uiParams[1] = MF_STRING; uiNums[0] = 5; uiNums[1] = 6; uiSize = 2; MenuCreator(hMenu2, hSubMenu2, uiParams, uiNums, cNames2, uiSize); SetMenu(hwnd, hMenu2);
I have a function that create menus dynamically. Here it is:void MenuCreator(HMENU hParentMenu, HMENU hChildMenu, unsigned int uiBehaviors[], unsigned int uiIDItems[], char cNameItems[][256], unsigned int uiSize) { if(hParentMenu == NULL || (hParentMenu == NULL && hChildMenu != NULL)) { MessageBox(NULL, "Menu pai não pode ser nulo", "Erro", MB_OK|MB_ICONERROR); return; } if(hParentMenu != NULL && hChildMenu != NULL) { for(int i = 1 ; i < uiSize ; i++)AppendMenu(hChildMenu, uiBehaviors[i], uiIDItems[i], cNameItems[i]); AppendMenu(hParentMenu, uiBehaviors[0], (unsigned int)hChildMenu, cNameItems[0]); return; } if(hParentMenu != NULL && hChildMenu == NULL) { for(int i = 0 ; i < uiSize ; i++) { AppendMenu(hChildMenu, uiBehaviors[i], uiIDItems[i], cNameItems[i]); } return; } }
when I insert the first menu, works fine. When I insert the other, the first menu isn't there, just the second. What I want to do is to have 2 or more menus at the same time, like File|Edit|View. What's going on? ThanksThe application must call the "DrawMenuBar" function whenever a menu changes, whether or not the menu is in a displayed window.