home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / p / pc2.zip / SOURCE.ZIP / SOURCE / PC2HOOK.C < prev    next >
Text File  |  1993-03-09  |  5KB  |  73 lines

  1. /***********************************************************************\
  2.  *                                PC2.c                                *
  3.  *                 Copyright (C) by Stangl Roman, 1992                 *
  4.  * This Code may be freely distributed, provided the Copyright isn't   *
  5.  * removed.                                                            *
  6.  *                                                                     *
  7.  * Pc2Hook.c    Hook the input queue to filter WM_BUTTON1CLICK         *
  8.  *              messages to allow PC2 display a Popup-Menu when mouse  *
  9.  *              button 1 is clicked on the Desktop.                    *
  10.  *                                                                     *
  11. \***********************************************************************/
  12.  
  13. static char RCSID[]="@(#) $Header: Pc2Hook.c Version 1.01 03,1993 $ (LBL)";
  14.  
  15. #define         _FILE_  "PC/2 - PC2Hook.c V1.01"
  16.  
  17. #include        "PC2.h"                 /* User include files */
  18. #include        "Error.h"
  19.  
  20. HWND    hwndDesktop;                    /* DESKTOP window handle */
  21. HWND    hwndPC2;                        /* PC2 client window handle */
  22. QUERYRECFROMRECT        QueryRect;      /* Rectangle to query underlaying containers */
  23.  
  24. /*--------------------------------------------------------------------------------------*\
  25.  * This procedure saves the window handles of PC/2 main procedure for use within the    *
  26.  * DLL.                                                                                 *
  27.  * Req:                                                                                 *
  28.  *      hD ............ HWND of Desktop                                                 *
  29.  *      hP ............ HWND of PC/2 client window                                      *
  30.  * Returns:                                                                             *
  31.  *      none                                                                            *
  32. \*--------------------------------------------------------------------------------------*/
  33. void EXPENTRY   PC2DLL_SetHwnd(HWND hD, HWND hP)
  34. {
  35. hwndDesktop=hD;
  36. hwndPC2=hP;
  37.                                         /* Initialize to query the topmost underlaying
  38.                                            container, that is partially hit by a rectangle
  39.                                            around the pointer */
  40. QueryRect.cb=sizeof(QUERYRECFROMRECT);
  41. QueryRect.fsSearch=CMA_PARTIAL | CMA_ZORDER;
  42. }
  43.  
  44. /*--------------------------------------------------------------------------------------*\
  45.  * This procedure implements the hook of the input queue.        .                      *
  46.  * Req:                                                                                 *
  47.  *      PQMSG ......... Pointer to system QMSG structure                                *
  48.  * Returns:                                                                             *
  49.  *      FALSE ......... OS/2 should process QMSG in the normal way                      *
  50. \*--------------------------------------------------------------------------------------*/
  51. BOOL EXPENTRY   PC2DLL_Hook(HAB hab, PQMSG pqmsg, ULONG option)
  52. {
  53. if((pqmsg->hwnd==hwndDesktop) && (pqmsg->msg==WM_BUTTON1CLICK))
  54.     {                                   /* User clicked on Desktop with mouse button 1 */
  55.                                         /* We construct a small rectangle around the
  56.                                            current position of the pointer */
  57.     QueryRect.rect.xLeft=pqmsg->ptl.x;
  58.     QueryRect.rect.xRight=pqmsg->ptl.x+1;
  59.     QueryRect.rect.yBottom=pqmsg->ptl.y;
  60.     QueryRect.rect.yTop=pqmsg->ptl.y+1;
  61.     if(WinSendMsg(hwndDesktop, CM_QUERYRECORDFROMRECT, MPFROMLONG(CMA_FIRST), &QueryRect)==NULL)
  62.                                         /* If no container is under the rectangle of the
  63.                                            mouse pointer, we can display our Popup-Menu.
  64.                                            The type of container is unknown, but because
  65.                                            we test only on the Desktop, the should usually
  66.                                            be the icons (but not the minimized programs,
  67.                                            which are windows with a different window handle). */
  68.         WinSendMsg(hwndPC2, WM_POPUPMENU, pqmsg->mp1, pqmsg->mp2);
  69.     }
  70. return(FALSE);                          /* Process the message in the normal way */
  71. }
  72.  
  73.