Context menu problem
-
Hi everyone !! I've a dialog based application in which I've added a context menu. I had previously defined a menu similar to file menu which works fine. Recently I added a context menu for one of the dialogs. It is not working :(( I checked the resource file for any duplicate id's and corrected that also but nothing seems to be helping me. Here is what I did. 1. Added a context menu in Resource->Menu. 2. Added a context menu command handler for that dialog. 3. Added command handler for each of the ID in this menu. When I compile, build and run the application it gives no errors but the commands from this context menu are not working. :(( When I try implementing a context menu with another project it works fine. :confused: Please help Thanks, Gajendra
Can you show a snippet code
_**
**_
WhiteSky
-
Can you show a snippet code
_**
**_
WhiteSky
This is in message maps: ON_COMMAND(ID_DIR_REVN_MENU, On_Dir_Revn_Menu) ----------------------------------------------------------------------- I've customised the display of context menu to deligate to another function. The context menu code is loaded properly and displayed. // called from the original OnContextMenu void CFPLN_PAGE_Dialog::On_Fpln_Revn_Menu(CPoint point) { point.x = 90; point.y = 95; ClientToScreen(&point); CMenu m_Fpln_Revn_Menu, *m_Ptr_ContextMenu; m_Fpln_Revn_Menu.LoadMenu(IDR_FPLN_REVN_MENU); m_Ptr_ContextMenu = m_Fpln_Revn_Menu.GetSubMenu(0); ASSERT(m_Fpln_Revn_Menu); m_Ptr_ContextMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, point.x, point.y, AfxGetMainWnd()); } ----------------------------------------------------------------------- Then the command handler code is: void CFPLN_PAGE_Dialog::On_Dir_Revn_Menu() { // TODO: Add your command handler code here AfxMessageBox("dir revn menu"); } Is this ok for you to guess something...? Let me know if you want to know more about the problem. You can mail to me: "gajendra.kashyap@valtech.co.in" Thanks, Gajendra
-
This is in message maps: ON_COMMAND(ID_DIR_REVN_MENU, On_Dir_Revn_Menu) ----------------------------------------------------------------------- I've customised the display of context menu to deligate to another function. The context menu code is loaded properly and displayed. // called from the original OnContextMenu void CFPLN_PAGE_Dialog::On_Fpln_Revn_Menu(CPoint point) { point.x = 90; point.y = 95; ClientToScreen(&point); CMenu m_Fpln_Revn_Menu, *m_Ptr_ContextMenu; m_Fpln_Revn_Menu.LoadMenu(IDR_FPLN_REVN_MENU); m_Ptr_ContextMenu = m_Fpln_Revn_Menu.GetSubMenu(0); ASSERT(m_Fpln_Revn_Menu); m_Ptr_ContextMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, point.x, point.y, AfxGetMainWnd()); } ----------------------------------------------------------------------- Then the command handler code is: void CFPLN_PAGE_Dialog::On_Dir_Revn_Menu() { // TODO: Add your command handler code here AfxMessageBox("dir revn menu"); } Is this ok for you to guess something...? Let me know if you want to know more about the problem. You can mail to me: "gajendra.kashyap@valtech.co.in" Thanks, Gajendra
Whats problem with this code it work,when you run this code you see a contextmenu in 90x95(create a menu in resource and event handler and run ...not problem)but you need to use
CPoint point; GetCursorPos(&point); //for get current position instead point.x&point.y=value.
_**
**_
WhiteSky
-
Whats problem with this code it work,when you run this code you see a contextmenu in 90x95(create a menu in resource and event handler and run ...not problem)but you need to use
CPoint point; GetCursorPos(&point); //for get current position instead point.x&point.y=value.
_**
**_
WhiteSky
The problem is that the commands from context menu are not working. The corresponding mapped function is not called when something is selected in the menu. Gaj
-
The problem is that the commands from context menu are not working. The corresponding mapped function is not called when something is selected in the menu. Gaj
Are you sure ids are unique it seems you code doesnt has a problem
_**
**_
WhiteSky
-
Are you sure ids are unique it seems you code doesnt has a problem
_**
**_
WhiteSky
Yes the IDs are unique. I've ResOrgAddin tool to check that. I got the problem just a few mins back. I don't know if I can load an image here but the I'll try to explain the design. I've a main dialog for the application, lets call this parent. I've several child dialogs which are displayed overlayed on this parent dialog. I implemented context menu only for one of the child dialog... it did not work as expected. Although the context menu was displayed the commands were not getting generated ... Surprising. Now I implemented the contextmenu on the parent dialog and it works as expected jst need to control the display on right dialog. I don't think it is the right way to do... but it is working. If i could send and handle the commands from the right dialog on which context menu is displayed would be the best situation. Let me know your valuable opinion. :) Thanks, Gaj
-
Yes the IDs are unique. I've ResOrgAddin tool to check that. I got the problem just a few mins back. I don't know if I can load an image here but the I'll try to explain the design. I've a main dialog for the application, lets call this parent. I've several child dialogs which are displayed overlayed on this parent dialog. I implemented context menu only for one of the child dialog... it did not work as expected. Although the context menu was displayed the commands were not getting generated ... Surprising. Now I implemented the contextmenu on the parent dialog and it works as expected jst need to control the display on right dialog. I don't think it is the right way to do... but it is working. If i could send and handle the commands from the right dialog on which context menu is displayed would be the best situation. Let me know your valuable opinion. :) Thanks, Gaj
Im wondering you are using same code in two place parent and child in parent its working and in child its not working you can show context_menu but you cant run items in this menu on child menu.I tested like you step to step and it worked
_**
**_
WhiteSky
-
Im wondering you are using same code in two place parent and child in parent its working and in child its not working you can show context_menu but you cant run items in this menu on child menu.I tested like you step to step and it worked
_**
**_
WhiteSky
Can you explain me your design if it differs from mine in some way? thanks for your help. Gajendra
-
Can you explain me your design if it differs from mine in some way? thanks for your help. Gajendra
well im writting a program (a parent dialog and a child) and then: (1)Create a menu in resource and declare handler for items in main class (2) im creating a button and insert these codes to it
CMenu m_Fpln_Revn_Menu, *m_Ptr_ContextMenu; CPoint point; GetCursorPos(&point); m_Fpln_Revn_Menu.LoadMenu(IDR_MENU1); m_Ptr_ContextMenu = m_Fpln_Revn_Menu.GetSubMenu(0); m_Ptr_ContextMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, point.x, point.y, AfxGetMainWnd());
(3) and running my program (4)when im clicking this button i can see a context_menu and when i click on items these works (5) then im writting like these codes for child dialog and its working Now you have this prolem with all your programs or only this program_**
**_
WhiteSky
-
well im writting a program (a parent dialog and a child) and then: (1)Create a menu in resource and declare handler for items in main class (2) im creating a button and insert these codes to it
CMenu m_Fpln_Revn_Menu, *m_Ptr_ContextMenu; CPoint point; GetCursorPos(&point); m_Fpln_Revn_Menu.LoadMenu(IDR_MENU1); m_Ptr_ContextMenu = m_Fpln_Revn_Menu.GetSubMenu(0); m_Ptr_ContextMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, point.x, point.y, AfxGetMainWnd());
(3) and running my program (4)when im clicking this button i can see a context_menu and when i click on items these works (5) then im writting like these codes for child dialog and its working Now you have this prolem with all your programs or only this program_**
**_
WhiteSky
I have problem with only this one becuase it works on others. I can't reveal the complete code to you :sigh: But its ok, I think I know the solution what needs to be done. Thanks much for your time and help. :) Regards, Gajendra
-
I have problem with only this one becuase it works on others. I can't reveal the complete code to you :sigh: But its ok, I think I know the solution what needs to be done. Thanks much for your time and help. :) Regards, Gajendra
if you create a new menu and repeat this stage whats happen?same problem
_**
**_
WhiteSky
-
if you create a new menu and repeat this stage whats happen?same problem
_**
**_
WhiteSky
Till now I had only single context menu for that dialog. Will try to add another one for another dialog and lets see then. Regards, Gajendra