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 » context meuns without resources/CExtPopupMenuWnd Collapse All
Subject Author Date
Raha Mohtasham Nov 21, 2007 - 5:53 AM

hi,

is there any sample for creating context menus on the fly (Without using any Resources)?

As simple as:
______
| Item1 | (Item1 was clicked)
| -------- |
| Item2 | (Item2 was clicked)
| Item3 | (Item3 was clicked)
|_____|


Thanks

RM

Technical Support Nov 21, 2007 - 12:20 PM

You can do this using the three methods below

1) The CExtPopupMenuWnd::CreatePopupMenu()

2) CExtPopupMenuWnd::ItemInsertCommand() or CExtPopupMenuWnd::ItemInsert(). You can use the CExtPopupMenuWnd::TYPE_SEPARATOR and CExtPopupMenuWnd::TYPE_POPUP constants as command identifiers for inserting separators and popup sub menu items.

3) CExtPopupMenuWnd::TrackPopupMenu()

Generally the context menu initialization may look like below:


HWND hWnd = . . . // target window for sending commands from popup menu
CExtPopupMenuWnd * pPopup = new CExtPopupMenuWnd;
      if( ! pPopup->CreatePopupMenu( hWnd ) )
      {
            delete pPopup;
            return . . .
      }
      pPopup->ItemInsert( . . . )
      pPopup->ItemInsert( . . . )
      pPopup->ItemInsert( . . . )
      . . .
      if( ! pPopup->TrackPopupMenu( . . . ) )
      {
            delete pPopup;
            return . . .
      }