Method AcPane::DisplayPopupPaneMenu() makes AutoCAD crash

Method AcPane::DisplayPopupPaneMenu() makes AutoCAD crash

Anonymous
Not applicable
814 Views
2 Replies
Message 1 of 3

Method AcPane::DisplayPopupPaneMenu() makes AutoCAD crash

Anonymous
Not applicable

I have a class MyPane deriver from AcPane. During ARX startup I add it to AutoCAD status bar. My goal is to display popup menu when I left-click on MyPane. There is an event

virtual void AcStatusBarItem::OnLButtonDown(UINT nFlags, CPoint point)
which allows me to do that.
 
Here is my code
void MyPane::OnLButtonDown(UINT nFlags, CPoint point)
{
CAcModuleResourceOverride resOverride; // I tried to define menu globally to get rid of CAcModuleResourceOverride from here. no luck
CMenu menu;
CMenu.LoadMenu(MAKEINTRESOURCE(IDM_SOME_MENU));
// no need for result right now
DisplayPopupPaneMenu(menu);
}
Last line makes AutoCAD crash with access violation error.
 
P.S. MyPane class has ACSB_POPUP style.
0 Likes
Accepted solutions (1)
815 Views
2 Replies
Replies (2)
Message 2 of 3

deepak.a.s.nadig
Alumni
Alumni

I am unable to recreate the crash at my end using the sample downloadable in the below link
https://adndevblog.typepad.com/autocad/2015/04/positioning-acpane-in-statusbar.html 

I have made the following changes to the sample (ensure ARXDBG tool is loaded)


         1) Display the the ARXDBG_MNU_APP of the ARXDBG tool :

 

void CPaneItem::OnLButtonDown(UINT nFlags, CPoint point)
{
	CMenu menu;
	CAcModuleResourceOverride();
	if (menu.LoadMenu(ARXDBG_MNU_APP)) {
		DisplayPopupPaneMenu(menu);
	}
}

          2) Set the ACSB_POPUP style to the pane item


Image after left button click on the pane item 

 

cMenu.JPG

0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

Thank you for your reply. I have found the reason which caused the problem.

In 'rc' file my menu was declared like this:

IDM_SOME_MENU MENU 
BEGIN
    MENUITEM "Item 1",                 ID_MENU_ITEM1
    MENUITEM "Item 2",                 ID_MENU_ITEM2
    MENUITEM "Item 3",                 ID_MENU_ITEM3
END

But it should look like this:

IDM_SOME_MENU MENU 
BEGIN
    POPUP "Some Menu"
    BEGIN
        MENUITEM "Item 1",                 ID_MENU_ITEM1
        MENUITEM "Item 2",                 ID_MENU_ITEM2
        MENUITEM "Item 3",                 ID_MENU_ITEM3
    END
END

With this kind of popup menu I finally could get it work properly.

0 Likes