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 » CExtPopupMenu question Collapse All
Subject Author Date
tera tera Jan 13, 2009 - 3:02 AM

Hello.


I want to make a dynamic menu with an icon.

Please teach a method.





    CPoint cPointPop;        ///< PopupMenu表示位置


    CMuPopupMenuWnd *pPopup = new CNxfPopupSelElem;


    pPopup->CreatePopupMenu(

        //GetSafeHwnd()

        AfxGetMainWnd()->GetSafeHwnd()

    );


    CMenu menuWidthCommands;

    CMenu popupMenu;

    CMenu popupMenu2;

    BOOL bCreate;


    bCreate = menuWidthCommands.CreateMenu();

    bCreate = popupMenu.CreatePopupMenu ();

    bCreate = popupMenu2.CreatePopupMenu ();


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

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


    bCreate = popupMenu2.AppendMenu ( MF_STRING, 32125 , "cc" );

    bCreate = popupMenu2.AppendMenu ( MF_STRING, 32126 , "dd" );


    bCreate = popupMenu.AppendMenu ( MF_POPUP, ( UINT ) popupMenu2.Detach (), "メニュー" );

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


    pPopup->UpdateFromMenu(

        //GetSafeHwnd() ,

        AfxGetMainWnd()->GetSafeHwnd() ,

        &menuWidthCommands

    );


    ::GetCursorPos( &cPointPop );


    pPopup->TrackPopupMenu (

        TPMX_NO_HIDE_RARELY |     // すべてPopupMenuが表示される形で起動する。

        TPM_RIGHTBUTTON |        

        TPM_TOPALIGN |

        TPM_LEFTALIGN ,

        cPointPop.x ,

        cPointPop.y

    );


 

tera tera Jan 14, 2009 - 2:10 AM

 


 CExtCmdProfile * pProfile;

 if ( m_csProfileName == "" ){

  m_csProfileName = g_CmdManager->ProfileNameFromWnd( AfxGetMainWnd()->GetSafeHwnd() );

 }

    pProfile = g_CmdManager->ProfileGetPtr( m_csProfileName );

 if ( pProfile == NULL ){

        ASSERT(FALSE);

        return FALSE;

 }


    m_bmpNormal.LoadBMP_Resource( MAKEINTRESOURCE( uidBmp )) ;

 m_bmpNormal.Make32();

 m_bmpNormal.AlphaColor( clrTrans, RGB(0,0,0), 0 );


    CExtCmdItem _cmd;

    _cmd.m_nCmdID = uid;


    ASSERT( CExtCmdManager::IsCommand( _cmd.m_nCmdID ) );

    _cmd.TipsLoad();

    pProfile->CmdSetup   ( _cmd , false );

    pProfile->CmdSetIcon ( _cmd.m_nCmdID, this , true );