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 >
Wrap
Text File
|
1993-03-09
|
5KB
|
73 lines
/***********************************************************************\
* PC2.c *
* Copyright (C) by Stangl Roman, 1992 *
* This Code may be freely distributed, provided the Copyright isn't *
* removed. *
* *
* Pc2Hook.c Hook the input queue to filter WM_BUTTON1CLICK *
* messages to allow PC2 display a Popup-Menu when mouse *
* button 1 is clicked on the Desktop. *
* *
\***********************************************************************/
static char RCSID[]="@(#) $Header: Pc2Hook.c Version 1.01 03,1993 $ (LBL)";
#define _FILE_ "PC/2 - PC2Hook.c V1.01"
#include "PC2.h" /* User include files */
#include "Error.h"
HWND hwndDesktop; /* DESKTOP window handle */
HWND hwndPC2; /* PC2 client window handle */
QUERYRECFROMRECT QueryRect; /* Rectangle to query underlaying containers */
/*--------------------------------------------------------------------------------------*\
* This procedure saves the window handles of PC/2 main procedure for use within the *
* DLL. *
* Req: *
* hD ............ HWND of Desktop *
* hP ............ HWND of PC/2 client window *
* Returns: *
* none *
\*--------------------------------------------------------------------------------------*/
void EXPENTRY PC2DLL_SetHwnd(HWND hD, HWND hP)
{
hwndDesktop=hD;
hwndPC2=hP;
/* Initialize to query the topmost underlaying
container, that is partially hit by a rectangle
around the pointer */
QueryRect.cb=sizeof(QUERYRECFROMRECT);
QueryRect.fsSearch=CMA_PARTIAL | CMA_ZORDER;
}
/*--------------------------------------------------------------------------------------*\
* This procedure implements the hook of the input queue. . *
* Req: *
* PQMSG ......... Pointer to system QMSG structure *
* Returns: *
* FALSE ......... OS/2 should process QMSG in the normal way *
\*--------------------------------------------------------------------------------------*/
BOOL EXPENTRY PC2DLL_Hook(HAB hab, PQMSG pqmsg, ULONG option)
{
if((pqmsg->hwnd==hwndDesktop) && (pqmsg->msg==WM_BUTTON1CLICK))
{ /* User clicked on Desktop with mouse button 1 */
/* We construct a small rectangle around the
current position of the pointer */
QueryRect.rect.xLeft=pqmsg->ptl.x;
QueryRect.rect.xRight=pqmsg->ptl.x+1;
QueryRect.rect.yBottom=pqmsg->ptl.y;
QueryRect.rect.yTop=pqmsg->ptl.y+1;
if(WinSendMsg(hwndDesktop, CM_QUERYRECORDFROMRECT, MPFROMLONG(CMA_FIRST), &QueryRect)==NULL)
/* If no container is under the rectangle of the
mouse pointer, we can display our Popup-Menu.
The type of container is unknown, but because
we test only on the Desktop, the should usually
be the icons (but not the minimized programs,
which are windows with a different window handle). */
WinSendMsg(hwndPC2, WM_POPUPMENU, pqmsg->mp1, pqmsg->mp2);
}
return(FALSE); /* Process the message in the normal way */
}