home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / WINBCK11.ZIP / WINHOOK.C < prev    next >
Text File  |  1991-10-18  |  2KB  |  64 lines

  1. /*------------------------------------------------------------------
  2.    This module is the input hook.  Since it is a system input hook,
  3.    it must reside in a DLL.
  4.    This hook checks if the 2nd button double clicks on the
  5.    title bar.  If it was, then put the window at the bottom.
  6.    After we get a WM_BUTTON2DBLCLK:
  7.        get the anchor block of the window that was double clicked
  8.        get the desktop window handle
  9.        get the parent of the window that was double clicked
  10.        if the parent of the window that was double clicked
  11.           is the desktop then we don't want it - we want the title bar
  12.        if the title bar was double-clicked then send the window
  13.           to the bottom of the pile
  14. -----------------------------------------------------------------*/
  15.  
  16. #define INCL_WINWINDOWMGR
  17. #define INCL_WININPUT
  18. #define INCL_WINFRAMEMGR
  19. #include <os2.h>
  20.  
  21.  
  22. int            _acrtused = 0;
  23. BOOL EXPENTRY WinHookProc( HAB, PQMSG, USHORT );
  24.  
  25. BOOL EXPENTRY WinHookProc( hab, pqmsg, usRemove )
  26. HAB            hab;
  27. PQMSG          pqmsg;
  28. USHORT         usRemove;
  29.   {
  30.   HWND        hwndDesktop;          /* desktop window handle    */
  31.   HWND        hwndTop;              /* top window handle    */
  32.   HWND        hwndTitle;            /* title bar  window handle    */
  33.   HAB         habWin;               /* anchor block of this window   */
  34.  
  35.     /* Only care if 2nd button double clicks */
  36.  
  37.   if( pqmsg->msg == WM_BUTTON2DBLCLK)
  38.   {
  39.  
  40.       /* get the anchor block of the window that was double clicked */
  41.       habWin = WinQueryAnchorBlock(pqmsg->hwnd);
  42.       /* get the desktop window handle */
  43.       hwndDesktop = WinQueryDesktopWindow(habWin,NULL);
  44.       /* get the parent of the window that was double clicked */
  45.       hwndTop = WinQueryWindow(pqmsg->hwnd,QW_PARENT,0);
  46.       /*------------------------------------------------------
  47.          if the parent of the window that was double clicked
  48.          is the desktop then we don't want it - we want the
  49.          title bar
  50.       -------------------------------------------------------*/
  51.       if (hwndTop != hwndDesktop)
  52.       {
  53.          hwndTitle = WinWindowFromID ( hwndTop,FID_TITLEBAR);
  54.          /* if the title bar was double-clicked then process */
  55.          if (hwndTitle == pqmsg->hwnd)
  56.                /* send the window to the bottom of the pile */
  57.                WinSetWindowPos(hwndTop,HWND_BOTTOM,0,0,0,0,SWP_ZORDER);
  58.       }
  59.   }
  60.   return(FALSE);
  61.  
  62. }
  63. 
  64.