Download JAW User Guide

Transcript
UINT uMsg,
WPARAM wParam,
LPARAM lParam);
private:
void sendMouseMessage(int message, int x, int y);
};
#endif
In addition to reporting the mouse events in the implementation of MouseEventHandler,
the native window can be dragged by pressing the left mouse button. To realize this feature
we register WM_MOVE and move the window to its new position with SetWindowPos().
// MouseEventHandler.cpp
#include "MouseEventHandler.h"
// ----------------- Selector -------------------------------WindowHandler *
selectWindowHandler(JNIEnv * env, jobject obj, int select)
{
return new MouseEventHandler(env, obj);
}
// ----------------- class MouseEventHandler ---------------// Constructor, initialize base class
MouseEventHandler::MouseEventHandler(JNIEnv * env,
jobject obj)
: WindowHandler(env, obj)
{}
// Select which windows message will call evMsg()
bool MouseEventHandler::wantMsg(UINT uMsg)
{
return (uMsg == WM_CREATE ||
WM_LBUTTONDOWN ||
WM_LBUTTONUP ||
WM_LBUTTONDBLCLK ||
WM_MOVE ||
WM_PAINT ||
WM_DESTROY);
}
// Event procedure
// Return false, if message is handled by this procedure,
// true to invoke DefWindowProc()
bool MouseEventHandler::evMsg(HWND hWnd, UINT message,
WPARAM wParam , LPARAM lParam)
21