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 » Question regarding CExtPopupMenuWnd (v2.30) Collapse All
Subject Author Date
Krustys Donuts Jun 29, 2005 - 2:45 PM

In the documentation, users are instructed to

1. Create the popup object dynamically
2. Initialize menu items by calling LoadMenu, *or* by calling InsertItem for each item.

I’ve found that this isn’t entirely accurate. If I don’t call LoadMenu, then InsertItem doesn’t actually add anything to the menu. However, if I do call LoadMenu, then InsertItem works. However, my problem is that my context menus are entirely dynamically generated (they do not rely on the command manager). Currently, the only way I’ve been able to get this to work is to create a dummy menu, load it with LoadMenu, then delete the first item, and finally insert my item using ItemInsert.

The interesting thing is that ItemInsertSpecPopup *does* work without calling LoadMenu first. ItemInsertCommand does *not* work.

Here’s what my code looks like right now:

CExtPopupMenuWnd* p = new CExtPopupMenuWnd();
VERIFY( p->CreatePopupMenu( GetParent()->GetSafeHwnd()));
p->g_bMenuExpanding = false;
// add the selections menu
if( selectionsEnabled) {
	p->ItemInsert( ContextCommands::SelectAll, -1, "Select all", 0, GetSafeHwnd());
	p->ItemInsert( ContextCommands::DeselectAll, -1, "Deselect all", 0, GetSafeHwnd());
	p->ItemInsert( ContextCommands::InvertSelection, -1, "Invert selection", 0, GetSafeHwnd());
	// add separator
	p->ItemInsert();
}
ClientToScreen( &point);
p->TrackPopupMenu( 0, point.x, point.y);


I hope you can see what I’m doing wrong!

Thank you!

Krustys Donuts Jun 29, 2005 - 2:49 PM

Sorry, I got a bit confused between projects... the code above actually crashes (I thought it was a blank context menu). I followed the steps outlined in the documentation, though.

Krustys Donuts Jun 29, 2005 - 3:00 PM

Sorry, I figured it out. ItemInsertCommand actually does work correctly. Can you please change the docs to reflect this? ItemInsertCommand should be called if you don’t use LoadMenu... not ItemInsert.

Technical Support Jun 30, 2005 - 5:17 AM

Yes, we will need to update the documentation. Additionally we should note: you can download the latest source code where the CExtPopupMenu::LoadMenu() method is also able to create a pop-up menu which is not based on the command manager. This method has a new parameter that is bNoRefToCmdManager.