Trouble with popup menu

I use the code below to popup a menu i have, however, only the very left side of it shows, about 10 pixels in width. Is there something Im doing worng on my menu?

Thanks,
  jer

HMENU hMenu;      // Menu Handle
      CMenu mMenu;      // Graph popup menu

    // Get the menu for the popup from the resource file
    mMenu.LoadMenu( IDR_GRAPHPOPUP );
      hMenu = mMenu.GetSafeHmenu();

    if( !hMenu ){
        return;
      }
 
    // Convert the mouse point to screen coordinates since that is what
    // TrackPopup expects.
    ::ClientToScreen( GetSafeHwnd(), (LPPOINT)&point );
 
    // Draw and track the "floating" popup  
    TrackPopupMenuEx( hMenu, NULL, point.x,
            point.y, GetSafeHwnd(), NULL );
 
    // Destroy the menu since were are done with it.
    DestroyMenu( hMenu );

      CFormView::OnRButtonDown(nFlags, point);
pipeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vinayak KumbarSr Program ManagerCommented:
Hi,

Try this out.

CMenu menu;
menu.LoadMenu(IDR_MAINFRAME);

CMenu *popup = NULL;
popup = menu.GetSubMenu(0);
popup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, point.x, point.y, this, NULL);

here IDR_MAINFRAME can be any menu from resource editor.
U need not do ClientToScreen()... The above code is working file.

Hope it solves Ur Problem
VinExpert
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

U can map the WM_CONTEXTMENU message to Ur CFormView class and put the abouve code.

Cheers,
VinExpert
0
pipeAuthor Commented:
Eeek. Still have the problem and now the menu doe snot appear in the correct place.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Vinayak KumbarSr Program ManagerCommented:
Hi,

If u still want to continue with Ur own code

here is the modified code and put it in OnContextMenu() function

HMENU hMenu; // Menu Handle
CMenu mMenu; // Graph popup menu

// Get the menu for the popup from the resource file
mMenu.LoadMenu( IDR_MENU1 );
hMenu = mMenu.GetSafeHmenu();
hMenu = ::GetSubMenu(hMenu, 0);

if( !hMenu )
{
      return;
}

// Draw and track the "floating" popup  
TrackPopupMenuEx( hMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON, point.x, point.y, this->GetSafeHwnd(), NULL );
      
// Destroy the menu since were are done with it.
DestroyMenu( hMenu );

I have removed ClientToScreen Convertion and added GetSubMenu(). Try it out.

VinExpert
0
pipeAuthor Commented:
Almost there maybe??? It is back in the correct place now, but stil most of the menu never gets drawn. only a few pixels wide.

This is exactlly what I have:

void CMyappView::OnContextMenu(CWnd* pWnd, CPoint point){
      
      // The graph menu
      CMenu menu;

      // Load the menu.
      menu.LoadMenu(IDR_GRAPHPOPUP);
 
      // Pop the menu up
      menu.TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON, point.x,
            point.y, this, NULL);
      
}
0
Vinayak KumbarSr Program ManagerCommented:
Hi,
Where is GetSubMenu()?. I told to put that. It will solve Ur Problem.

VinExpert
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

If it has only one menu item, then also do the GetSubMenu(0). It is needed for TrackPopupMenu().

Try it out.
VinExpert
0
pipeAuthor Commented:
Im sorry, I forgot to tell you that GetSubMenu was returning NULL and wouldl crash it. So I took it out.
0
pipeAuthor Commented:
Ok, I got it now. My menu used to have only one Menu(nothing to the right).

Im not sure if I understand it, but I made it pop out to the right one, then started my menu there. If that is how you have to build your menu then I did not know that. If you submit again I will give you your points. Thanks.
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

So u got Ur problem solved. Good luck.

Regards,

VinExpert
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.