home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Virtual Reality Zone
/
VRZONE.ISO
/
mac
/
PC
/
PCGLOVE
/
GLOVE
/
OBJGLV.ZIP
/
SRC
/
MOUSGEST.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-05-12
|
4KB
|
133 lines
//
// MousGest.cpp:
// Implementation of class GloveMouseGestures.
// Example use of Object Glove and Court Jesture.
//
// Purpose:
// Sends messages to other windows to emulate mouse clicks.
// DOES NOT ALWAYS WORK! I'm not sure why, I guess
// I need to send more $$ to Bill Gates or something.
//
// Compatibility:
// Windows only!
//
// Copyright 1993 Mark Thomas Pflaging
//
// Date: 3/22/93 (Release 3.0)
//
// Copyright 1993, Mark T. Pflaging
#include "mousgest.hpp"
TApplication * GloveMouseGestures::app;
POINT * GloveMouseGestures::position;
void GloveMouseGestures::Init(InitFile & ini, TApplication * here, char * sectionName)
{
setName(sectionName);
app = here;
suspended = False;
addId(ini.find(sectionName, "LeftButtonDown", "100 1 X X X X X *2 X X X"), LeftButtonDown);
addId(ini.find(sectionName, "LeftButtonDoubleClick", "100 1 X X X X X *0 X X X"), LeftButtonDoubleClick);
addId(ini.find(sectionName, "RightButtonDown", "100 1 X X X X X X *2 X X"), RightButtonDown);
addId(ini.find(sectionName, "RightButtonDoubleClick", "100 1 X X X X X X *0 X X"), RightButtonDoubleClick);
addId(ini.find(sectionName, "Suspend", "100 1 X X X X X X X X Start"), Suspend);
addId(ini.find(sectionName, "Quit", "100 1 X X X X X X X X 9"), Quit);
/***
for (int i = 0; i <= Twist; i ++) {
statusBits[i] = False;
}
***/
}
BOOL GloveMouseGestures::MyPostMessage(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
if ((hwnd == (app->MainWindow)->HWindow) || suspended) return False;
return (PostMessage(hwnd, umsg, wParam, lParam));
}
void GloveMouseGestures::Register(Gesture & arg, Boolean onOrOff)
{
static HWND lold_where, rold_where;
NumberedGestSet::Register(arg, onOrOff);
NumberedGesture & found = (NumberedGesture &)arg;
HWND where = WindowFromPoint(*position);
if (onOrOff) {
// Figure out what part of the window
// the cursor is now in.
LRESULT wParam = SendMessage(where, WM_NCHITTEST, 0, MAKELPARAM((WORD)position->x, (WORD)position->y));
switch (MouseGests(found.getId())) {
case LeftButtonDown:
lold_where = where;
SetActiveWindow(where);
if ((wParam == HTCLIENT)) {
ScreenToClient(where, position);
MyPostMessage(where, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(
(WORD)(position->x), (WORD)(position->y)
));
}
else {
MyPostMessage(where, WM_NCLBUTTONDOWN, wParam, MAKELPARAM((WORD)position->x, (WORD)position->y));
}
break;
case RightButtonDown:
rold_where = where;
SetActiveWindow(where);
if ((wParam == HTCLIENT)) {
ScreenToClient(where, position);
MyPostMessage(where, WM_RBUTTONDOWN,MK_RBUTTON, MAKELPARAM(
(WORD)(position->x), (WORD)(position->y)
));
}
else {
MyPostMessage(where, WM_NCRBUTTONDOWN, wParam, MAKELPARAM((WORD)position->x, (WORD)position->y));
}
break;
case LeftButtonDoubleClick:
SetActiveWindow(where);
if ((wParam == HTCLIENT)) {
ScreenToClient(where, position);
MyPostMessage(where, WM_LBUTTONDBLCLK, MK_LBUTTON, MAKELPARAM(
(WORD)(position->x), (WORD)(position->y)
));
}
else {
MyPostMessage(where, WM_NCLBUTTONDBLCLK, wParam, MAKELPARAM((WORD)position->x, (WORD)position->y));
}
break;
case RightButtonDoubleClick:
SetActiveWindow(where);
if ((wParam == HTCLIENT)) {
ScreenToClient(where, position);
MyPostMessage(where, WM_RBUTTONDBLCLK, MK_RBUTTON, MAKELPARAM(
(WORD)(position->x), (WORD)(position->y)
));
}
else {
MyPostMessage(where, WM_NCRBUTTONDBLCLK, wParam, MAKELPARAM((WORD)position->x, (WORD)position->y));
}
break;
case Suspend:
suspended = (suspended ? False : True);
break;
case Quit:
PostMessage((app->MainWindow)->HWindow, WM_CLOSE, 0, 0L);
}
}
if (!onOrOff) {
switch (MouseGests(found.getId())) {
case LeftButtonDown:
ScreenToClient(where, position);
MyPostMessage(lold_where, WM_LBUTTONUP,(WPARAM)0, MAKELPARAM(
(WORD)(position->x), (WORD)(position->y)
));
break;
case RightButtonDown:
ScreenToClient(where, position);
MyPostMessage(rold_where, WM_RBUTTONUP,(WPARAM)0, MAKELPARAM(
(WORD)(position->x), (WORD)(position->y)
));
break;
}
}
}