TrackPopupMenu

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Jason (mite51_at_hotmail.com)
Date: 04/20/04


Date: Tue, 20 Apr 2004 14:36:59 -0700

MSDN docs for CMenu:: says the lpRect argument ....

    Points to a RECT structure or CRect object that contains the screen
coordinates of a rectangle within which the user can click without
dismissing the pop-up menu. If this parameter is 0, the pop-up menu is
dismissed if the user clicks outside the pop-up menu. This must be 0 for
Windows 3.0.

I have supplied a Rect because I dont want the menu dismissed until
something is clicked. I supply the rect but the menu still gets dismissed as
if no rect was supplied, any ideas how I can get my popup menu to stick
around?

Jason

//---------------------------------------------------
     CRect rect(0,0,99999,99999);

     CMenu* pSubMenu = CMenu::FromHandle( lpmi.hSubMenu );
     CWnd* pWindowOwner = CWnd::FromHandle( menuOwnerWindow );

     BOOL ret = pSubMenu->TrackPopupMenu( TPM_LEFTALIGN,
      menuItemRect.left, menuItemRect.bottom, pWindowOwner, &rect );

     if ( !ret )
     {
      ErrorDescription( GetLastError() );
     }