Click here to Skip to main content
15,907,326 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: STUPID PROBLEM Pin
Sunnygirl12-Dec-02 10:07
Sunnygirl12-Dec-02 10:07 
GeneralRe: STUPID PROBLEM Pin
Ted Ferenc12-Dec-02 9:36
Ted Ferenc12-Dec-02 9:36 
GeneralRe: STUPID PROBLEM Pin
Sunnygirl12-Dec-02 9:43
Sunnygirl12-Dec-02 9:43 
GeneralRe: STUPID PROBLEM Pin
Ted Ferenc12-Dec-02 10:24
Ted Ferenc12-Dec-02 10:24 
GeneralRe: STUPID PROBLEM Pin
Michael Dunn12-Dec-02 9:49
sitebuilderMichael Dunn12-Dec-02 9:49 
GeneralRe: STUPID PROBLEM Pin
Sunnygirl12-Dec-02 10:08
Sunnygirl12-Dec-02 10:08 
GeneralRe: STUPID PROBLEM Pin
Sunnygirl12-Dec-02 10:22
Sunnygirl12-Dec-02 10:22 
GeneralDynamic context menus.... Pin
RedZenBird12-Dec-02 9:04
RedZenBird12-Dec-02 9:04 
This one is just kicking me hard......Maybe someone can help......I'm trying to get completely dynamic context menus to work.....What's strange is these approaches work in debug mode, but never work in release mode....The way it fails in release mode is that the menu is not displayed, and the result is always zero.

What gives?


The following snippettes work in debug mode, but NOT in release mode:

// snip #1

CMenu oMenu;
ASSERT( oMenu.CreatePopupMenu() );

// i have a collection of menu command items that I add to the
// dynamic menu here
//
CONTEXT_COMMANDS_ITER oMenuCommandsIter;
for ( oMenuCommandsIter = poCommands->begin();
oMenuCommandsIter != poCommands->end();
oMenuCommandsIter++ )
{
oMenu.AppendMenu( MF_STRING,
(*oMenuCommandsIter).first,
(*oMenuCommandsIter).second.c_str() );
}

ClientToScreen( &oPoint );
DWORD dwResult;
dwResult = oMenu.TrackPopupMenu( TPM_LEFTALIGN | TPM_RIGHTBUTTON |
TPM_NONOTIFY | TPM_RETURNCMD,
oPoint.x,
oPoint.y,
this );
// end snip #1

// snip #2

CMenu oMenu;
CMenu oPopup;
ASSERT( oMenu.CreateMenu() );
ASSERT( oPopup.CreatePopupMenu() );

oMenu.AppendMenu( MF_STRING, 0, "Ignored" );
oMenu.AppendMenu( MF_POPUP, (UINT)oPopup.m_hMenu, "Ignored" );

// i have a collection of menu command items that I add to the
// dynamic menu here
//
CONTEXT_COMMANDS_ITER oMenuCommandsIter;
for ( oMenuCommandsIter = poCommands->begin();
oMenuCommandsIter != poCommands->end();
oMenuCommandsIter++ )
{
oPopup.AppendMenu( MF_STRING,
(*oMenuCommandsIter).first,
(*oMenuCommandsIter).second.c_str() );
}

ClientToScreen( &oPoint );
DWORD dwResult;
dwResult = oPopup.TrackPopupMenu( TPM_LEFTALIGN | TPM_RIGHTBUTTON |
TPM_NONOTIFY | TPM_RETURNCMD,
oPoint.x,
oPoint.y,
this );
// end snip #2


The following approach works in debug and release mode, but I don't like it because it creates a dependancy on the resource fork.

CMenu oMenu;
VERIFY( oMenu.LoadMenu( IDR_MENU_HIGHLIGHTS ) );

CMenu* poPopup = oMenu.GetSubMenu( 0 );
ASSERT( poPopup != NULL );
int iCount = poPopup->GetMenuItemCount();

// since I loaded a menu from a resource, throw all the stuff away
// i don't want/need here
//
for ( int iLoop = 0; iLoop < iCount; iLoop++ )
{
poPopup->RemoveMenu( iLoop, MF_BYPOSITION );
}

// add the commands I want on the menu
//
CONTEXT_COMMANDS_ITER oMenuCommandsIter;
for ( oMenuCommandsIter = poCommands->begin();
oMenuCommandsIter != poCommands->end();
oMenuCommandsIter++ )
{
poPopup->AppendMenu( MF_STRING,
(*oMenuCommandsIter).first,
(*oMenuCommandsIter).second.c_str() );
}

ClientToScreen( &oPoint );
DWORD dwResult;
dwResult = poPopup->TrackPopupMenu( TPM_LEFTALIGN | TPM_RIGHTBUTTON |
TPM_NONOTIFY | TPM_RETURNCMD,
oPoint.x,
oPoint.y,
this );

ASSERT( oMenu.DestroyMenu() );


I've even tried to go so far as to use CreateMenuIndirect() from a memory template, which just seems like too much for what I'm trying to do...

Anyone have any hints for me?


Just trying to keep the forces of entropy at bay
GeneralRe: Dynamic context menus.... Pin
RedZenBird12-Dec-02 13:19
RedZenBird12-Dec-02 13:19 
GeneralRe: Dynamic context menus.... Pin
Member 9612-Dec-02 13:22
Member 9612-Dec-02 13:22 
GeneralRe: Dynamic context menus.... Pin
RedZenBird12-Dec-02 13:45
RedZenBird12-Dec-02 13:45 
GeneralCombo box cur sel index Pin
jimNLX12-Dec-02 8:13
jimNLX12-Dec-02 8:13 
GeneralRe: Combo box cur sel index Pin
valikac12-Dec-02 13:04
valikac12-Dec-02 13:04 
GeneralRe: Combo box cur sel index Pin
Anonymous13-Dec-02 3:47
Anonymous13-Dec-02 3:47 
GeneralRe: Combo box cur sel index Pin
Anonymous13-Dec-02 13:49
Anonymous13-Dec-02 13:49 
QuestionAnti-Virus Style File/Folder Selection Control? Pin
James Wood12-Dec-02 7:39
James Wood12-Dec-02 7:39 
Questionworking with .csv files? Pin
trustno112-Dec-02 6:40
trustno112-Dec-02 6:40 
AnswerRe: working with .csv files? Pin
Nitron12-Dec-02 7:14
Nitron12-Dec-02 7:14 
QuestionNow I know how to send HTML (of any size) directly to the HTMLView, but the first time it don't work properly, could you take a look at it? Pin
Joan M12-Dec-02 5:57
professionalJoan M12-Dec-02 5:57 
AnswerRe: Now I know how to send HTML (of any size) directly to the HTMLView, but the first time it don't work properly, could you take a look at it? Pin
Ravi Bhavnani12-Dec-02 6:50
professionalRavi Bhavnani12-Dec-02 6:50 
GeneralRe: Now I know how to send HTML (of any size) directly to the HTMLView, but the first time it don't work properly, could you take a look at it? Pin
Joan M12-Dec-02 7:03
professionalJoan M12-Dec-02 7:03 
GeneralRe: Now I know how to send HTML (of any size) directly to the HTMLView, but the first time it don't work properly, could you take a look at it? Pin
Ravi Bhavnani12-Dec-02 7:11
professionalRavi Bhavnani12-Dec-02 7:11 
GeneralRe: Now I know how to send HTML (of any size) directly to the HTMLView, but the first time it don't work properly, could you take a look at it? Pin
Joan M12-Dec-02 7:22
professionalJoan M12-Dec-02 7:22 
GeneralRe: Now I know how to send HTML (of any size) directly to the HTMLView, but the first time it don't work properly, could you take a look at it? Pin
Joan M12-Dec-02 7:31
professionalJoan M12-Dec-02 7:31 
GeneralGetting Assert error with CFileDialog::DoModal Pin
Luis E. Cuadrado12-Dec-02 5:23
Luis E. Cuadrado12-Dec-02 5:23 

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.