Click here to Skip to main content
15,920,633 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralOwner drawn popup menu and its border Pin
tabor256-Oct-04 2:29
tabor256-Oct-04 2:29 
GeneralRe: Owner drawn popup menu and its border Pin
Iain Clarke, Warrior Programmer6-Oct-04 4:25
Iain Clarke, Warrior Programmer6-Oct-04 4:25 
GeneralRe: Owner drawn popup menu and its border Pin
tabor256-Oct-04 5:03
tabor256-Oct-04 5:03 
GeneralSelecting a bitmap into two mem DC's at the same time Pin
Garth Watkins6-Oct-04 2:22
Garth Watkins6-Oct-04 2:22 
Generalexe file not run properly Pin
nirmit6-Oct-04 2:08
nirmit6-Oct-04 2:08 
GeneralRe: exe file not run properly Pin
ThatsAlok6-Oct-04 2:44
ThatsAlok6-Oct-04 2:44 
GeneralRe: exe file not run properly Pin
David Crow6-Oct-04 3:58
David Crow6-Oct-04 3:58 
GeneralPop-up Menu Pin
Rage6-Oct-04 2:03
professionalRage6-Oct-04 2:03 
Hi CPians,

I have a problem with the following : I have a menu with two items, the second one being ID_OPEN_NORMAL.
I basically would like to change the item string it at runtime, which I do as follows:

CPoint point;                                            
::GetCursorPos(&point);	
CMenu menu; 

DWORD dwSelectionMade;                                       
VERIFY(menu.LoadMenu(IDR_MENU1) );  
CMenu *pmenuPopup = menu.GetSubMenu(0);
ASSERT(pmenuPopup != NULL);



CString menustring;
CString str="Hello World";

if (!str.IsEmpty())
{
	menustring = "Open "+str;
	pmenuPopup->ModifyMenu(ID_OPEN_NORMAL,MF_BYCOMMAND,MF_STRING,menustring);
}
else
{
	pmenuPopup->RemoveMenu(ID_OPEN_NORMAL,MF_BYCOMMAND);
}



dwSelectionMade = pmenuPopup->TrackPopupMenu( (TPM_LEFTALIGN|TPM_LEFTBUTTON|
	TPM_NONOTIFY|TPM_RETURNCMD),
	point.x, point.y, this
	);                                

pmenuPopup->DestroyMenu(); 


The menu appears and the modified item string shows "Open Hello" as expected. However, dwSelectionMade contains 0 (instead of ID_OPEN_NORMAL) when I select the "Open Hello" item (so I cannot track the user's choice correctly afterwards) as if the user did not select any menu item.
It works OK for the first item, which I do not change dynamically (e.g. dwSlectionMade does contain the ID of the selected item).

Can anyone point out what I am doing wrong ?

Thanks,

~RaGE();
GeneralRe: Pop-up Menu Pin
Garth Watkins6-Oct-04 2:51
Garth Watkins6-Oct-04 2:51 
GeneralRe: Pop-up Menu Pin
Rage6-Oct-04 3:59
professionalRage6-Oct-04 3:59 
GeneralRe: Pop-up Menu Pin
Iain Clarke, Warrior Programmer6-Oct-04 4:54
Iain Clarke, Warrior Programmer6-Oct-04 4:54 
GeneralRe: Pop-up Menu Pin
Rage6-Oct-04 21:07
professionalRage6-Oct-04 21:07 
GeneralProble with OnTimer() Pin
Leyu6-Oct-04 1:36
Leyu6-Oct-04 1:36 
GeneralRe: Proble with OnTimer() Pin
toxcct6-Oct-04 1:57
toxcct6-Oct-04 1:57 
GeneralRe: Proble with OnTimer() Pin
Nathan Holt at EMOM6-Oct-04 5:28
Nathan Holt at EMOM6-Oct-04 5:28 
GeneralRe: Proble with OnTimer() Pin
toxcct6-Oct-04 6:35
toxcct6-Oct-04 6:35 
GeneralRe: Proble with OnTimer() Pin
Nathan Holt at EMOM6-Oct-04 7:02
Nathan Holt at EMOM6-Oct-04 7:02 
GeneralRe: Proble with OnTimer() Pin
Iain Clarke, Warrior Programmer6-Oct-04 5:32
Iain Clarke, Warrior Programmer6-Oct-04 5:32 
GeneralRe: Proble with OnTimer() Pin
LittleYellowBird6-Oct-04 5:36
LittleYellowBird6-Oct-04 5:36 
GeneralRe: Proble with OnTimer() Pin
Leyu6-Oct-04 8:01
Leyu6-Oct-04 8:01 
GeneralRe: Proble with OnTimer() Pin
BlackDice6-Oct-04 10:59
BlackDice6-Oct-04 10:59 
Generalexe file not run properly out side of vc++ environment Pin
nirmit6-Oct-04 1:09
nirmit6-Oct-04 1:09 
GeneralRe: exe file not run properly out side of vc++ environment Pin
toxcct6-Oct-04 1:25
toxcct6-Oct-04 1:25 
GeneralRe: exe file not run properly out side of vc++ environment Pin
nirmit6-Oct-04 2:54
nirmit6-Oct-04 2:54 
GeneralRe: exe file not run properly out side of vc++ environment Pin
David Crow6-Oct-04 4:03
David Crow6-Oct-04 4:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.