| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | PM |
CE{at}9> CHAR mess2[]="The mouse is inside the window";
*Whenever* you receive a WM_MOUSEMOVE message, the mouse is over your
window (unless you have called WinSetCapture(), in which case your window
is the only one that receives mouse messages, even if the pointer moves
outside your window).
The mouse co-ordinates will be adjusted for your window, so the when the
mouse is over the bottom left of your window, you will recieve the
coordinates 0, 0.
Here's a sample:
// compiled: icc /Kb+ /SS /B"/pm:pm" small3.c
#define INCL_WIN
#include
#include
#include
#define ID_WINDOW 1
MRESULT EXPENTRY MyWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
static char mesg[100];
RECTL rect;
HPS hps;
switch (msg) {
case WM_ERASEBACKGROUND:
return (MRESULT) (TRUE);
case WM_MOUSEMOVE:
sprintf(mesg, "%d, %d", SHORT1FROMMP(mp1), SHORT2FROMMP(mp1));
WinInvalidateRect(hwnd, NULL, FALSE); /* force draw */
break;
case WM_PAINT:
hps = WinBeginPaint(hwnd, 0, NULL);
WinQueryWindowRect(hwnd, &rect);
WinDrawText(hps, strlen(mesg), mesg, &rect, 0, 0,
DT_CENTER | DT_VCENTER | DT_TEXTATTRS | DT_ERASERECT);
WinEndPaint(hps);
break;
default:
return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
return 0;
}
int main(void)
{
HAB hab;
HMQ hmq;
HWND hwndClient;
HWND hwndFrame;
ULONG flCreate;
QMSG qmsg;
if (!(hab = WinInitialize(0)))
return 1;
if (!(hmq = WinCreateMsgQueue(hab, 0)))
return 1;
if (!WinRegisterClass(hab, (PSZ) "MyWindow", (PFNWP)
MyWindowProc, 0, 0))
return 1;
flCreate = FCF_SHELLPOSITION | FCF_SIZEBORDER | FCF_TASKLIST |
FCF_SYSMENU | FCF_TITLEBAR;
hwndFrame = WinCreateStdWindow(HWND_DESKTOP, WS_VISIBLE, &flCreate,
"MyWindow", NULL, 0, 0, ID_WINDOW, &hwndClient);
if (!hwndFrame || !hwndClient)
return 1;
while (WinGetMsg(hab, &qmsg, 0L, 0, 0))
WinDispatchMsg(hab, &qmsg);
WinDestroyWindow(hwndFrame);
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
return 0;
}
--- Maximus/2 2.01
* Origin: Beer bellies = great waist. (905)858-8488 (1:259/414)SEEN-BY: 12/2442 54/54 620/243 624/50 632/348 640/820 690/660 711/409 413 430 SEEN-BY: 711/807 808 809 934 942 712/353 623 713/888 800/1 @PATH: 259/414 400 99 98 3615/50 229/2 12/2442 711/409 54/54 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.