Loading ...
Sorry, an error occurred while loading the content.

Re: Revising how to get a popup menu's handle

Expand Messages
  • Piotr Kaluski
    Any news? No rush, just in case you have it... --Piotr ... why ... or
    Message 1 of 2 , Nov 29, 2005
    • 0 Attachment
      Any news?

      No rush, just in case you have it...

      --Piotr

      --- In perlguitest@yahoogroups.com, "rafelafrance"
      <rafelafrance@y...> wrote:
      >
      > I've had to revise my in-house libraries to accomodate certian
      > problems with getting a popup menu's handle. I've been using thse
      > changes for a while here so they're more robust than my original
      > submission.
      >
      > It all comes down to this: I have to send a VK_DOWN or UP and trap
      > the WM_MENUSELECT rather than a WM_INITMENUPOPUP event in certian
      > situations.
      >
      > 1) When a popup is created with the "menu key" on the keyboard
      > instead of a right-click with the mouse. no WM_INITMENUPOPUP
      >
      > 2) Even some times when a right-click is done the WM_INITMENUPOPUP
      > doesn't seem to be sent. I have no source so I can't tell when or
      why
      > for this but it's interesting.
      >
      > Anyway. Here's my code in raw form so you all can get an idea of
      > what I'm doing to work around the issue. We're back to the
      > more "hideous" solution but it's rock solid... so far. I'll try &
      > roll it into XS module ASAP and submit a formal patch with minimal
      or
      > no impact on my preivious submission.
      >
      > void popupHandleDown( int wait )
      > {
      > if ( wait > 0 )
      > {
      > Sleep( wait );
      > }
      >
      > keybd_event( VK_DOWN, 0, 0, 0);
      > keybd_event( VK_DOWN, 0, KEYEVENTF_KEYUP, 0 );
      >
      > if ( wait > 0 )
      > {
      > Sleep( wait );
      > }
      >
      > if ( g_hPopup == 0 )
      > {
      > UnhookWindowsHookEx( g_hHook );
      > }
      > }
      >
      > __declspec(dllexport)
      > HMENU GetPopupHandleXY( HWND hwnd, int x, int y, int wait )
      > {
      > g_hPopup = 0;
      >
      > if ( SetHook( hwnd ) == NULL )
      > {
      > return 0;
      > }
      >
      > int mickey_x = MulDiv( x, 0x10000, GetSystemMetrics
      > (SM_CXSCREEN) );
      > int mickey_y = MulDiv( y, 0x10000, GetSystemMetrics
      > (SM_CYSCREEN) );
      > mouse_event( MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE |
      > MOUSEEVENTF_RIGHTDOWN,
      > mickey_x, mickey_y, 0, 0 );
      > mouse_event( MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0 );
      >
      > popupHandleDown( wait );
      > return g_hPopup;
      > }
      >
      > __declspec(dllexport)
      > HMENU GetPopupHandleKey( HWND hwnd, int wait )
      > {
      > g_hPopup = 0;
      >
      > if ( SetHook( hwnd ) == NULL )
      > {
      > return 0;
      > }
      >
      > keybd_event( VK_APPS, 0, 0, 0);
      > keybd_event( VK_APPS, 0, KEYEVENTF_KEYUP, 0 );
      >
      > popupHandleDown( wait );
      > return g_hPopup;
      > }
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.