Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » CExtPopupMenuWnd question Collapse All
Subject Author Date
tera tera Nov 5, 2008 - 7:35 PM

Hello.


It was made a menu dynamically.

However, it is not started in the form that all the menus were displayed.





Please teach a way displayed entirely.

Please answer it as soon as possible.




    CExtPopupMenuWnd * pPopup;

    CPoint             cPointPop;


    pPopup = new CExtPopupMenuWnd;

    pPopup->CreatePopupMenu( AfxGetMainWnd()->GetSafeHwnd() );


    CMenu menuWidthCommands;

    CMenu popupMenu;

    BOOL bCreate;

    bCreate = menuWidthCommands.CreateMenu();

    bCreate = popupMenu.CreatePopupMenu ();

    bCreate = popupMenu.AppendMenu ( MF_STRING, 32123 /*ID_SEPARATOR*/ , "aaaa" );

    bCreate = popupMenu.AppendMenu ( MF_STRING, 32124 /*ID_SEPARATOR*/ , "bbbb" );

    bCreate = menuWidthCommands.AppendMenu ( MF_POPUP, ( UINT ) popupMenu.Detach (), "_POPUP_" );


    pPopup->UpdateFromMenu(

        //GetSafeHwnd() ,

        AfxGetMainWnd()->GetSafeHwnd() ,

        &menuWidthCommands

    );


    ::GetCursorPos( &cPointPop );


    pPopup->TrackPopupMenu (

        TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_LEFTALIGN ,

        cPointPop.x ,

        cPointPop.y

    );

Technical Support Nov 6, 2008 - 12:56 PM

First of all, you are using the TPM_*** in invocation of the CExtPopupMenuWnd::TrackPopupMenu() method. This is not correct. This method uses its own TPMX_*** flags instead of defined in Win32 TPM_*** flags. You should use the TPMX_NO_HIDE_RARELY flag to make all the commands visible initially.


Technical Support Nov 6, 2008 - 12:55 PM

All the command descriptions are de-allocated by thecommand manager at shut down automatically. You should not see any memory leaks. But if your code allocates some command identifier dynamically, this code is invoked many times and you stop de-allocating it, you will need to check whether the command identifier is already allocated. In this case you should invoke the g_CmdManager->CmdAllocPtr( . . . ) code first. If it returns NULL, the specified command identifier is already allocated and you can invoke the g_CmdManager->CmdGetPtr( . . . ) to get a pointer to the already allocated the CExtCmdItem() object.

tera tera Nov 6, 2008 - 6:01 PM

 


Thank you for an answer


 

tera tera Nov 5, 2008 - 7:38 PM

At the time of the end, will it be necessary to erase menu ID every time?


   g_CmdManager->CmdRemove( __PROF_UIS_PROJECT_CMD_PROFILE_NAME , 32123 );

   g_CmdManager->CmdRemove( __PROF_UIS_PROJECT_CMD_PROFILE_NAME , 32124 );