I'm confused. Are you asking to send mouse input to another application, or are you asking how to receive it?
If you want to receive it, in DefWindowProc's switch() just put case WM_LBUTTONDOWN, WM_RBUTTONDOWN or WM_MBUTTONDOWN (left, right, middle button in that order). Then you can use WM_xBUTTONUP for when they unclick.
e.g, the WindowProcedure from a drawing app I wrote a couple of months ago (with a large amount of help from someone on this forum called "Hammurabi):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
// This function is called by DispatchMessage()
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) {
switch (message) {
case WM_MOUSEMOVE: // If the mouse moves across the screen
wmMouseMove(hwnd, wp, lp);
break;
case WM_LBUTTONDOWN: // Left button down
wmLButtonDown(hwnd, wp, lp);
break;
case WM_LBUTTONUP: // Left button up
wmLButtonUp(hwnd, wp, lp);
break;
case WM_DESTROY:
PostQuitMessage(0); // Send WM_QUIT
break;
case WM_KEYDOWN: // Catch key presses
wmKeyDown(hwnd, wp, lp);
break;
default:
return DefWindowProc(hwnd, message, wp, lp);
}
return 0;
}
|
If you're looking to send input to another application, it can only be done with SendInput(). I asked this very same question once but no-one knew a way of doing it other than SendInput(), which didn't work for me for some reason. Not even because Vista (>:[) doesn't allow it; it wouldn't compile.
Anyway, try SendInput() or WM_xBUTTONDOWN/UP, depending on what question you're asking.