Re: Detect mouse click and coordinates (C++)
- From: "Ron Francis" <rfrancis@xxxxxxxxxxxx>
- Date: Wed, 14 Feb 2007 10:04:32 +1030
Using a mouse with DOS is an old memory now.
I did write a drawing program for DOS once, using the mouse, but that was
using the Basic language and I was able to set the screen to a graphics mode
so I didn't have to concern myself with text sizes.
Good luck with it.
Regards,
Ron Francis
www.RonaldFrancis.com
"Ash44455666" <Ash44455666@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9931E1B4-D9D3-4A2D-A3AA-CC86DC4B5222@xxxxxxxxxxxxxxxx
"Ron Francis" wrote:
Here is a very brief outline of what you would have to do, but I don't
think
this would help you much in a console program.
You may get something from it though.
In the Windows SDK you set up something similar to your main() function
like
this ...
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
In that you set up your window by filling out a structure
WNDCLASS wndclass (or WNDCLASSEX) , where the member
"wndclass.lpfnWndProc " is a pointer to your callback function that
receives messages
then you create a window using
hWnd = CreateWindow( szAppName, szAppName, dwStyle, CW_USEDEFAULT, 0,
xScreen, yScreen , NULL, NULL, hInstance, NULL) ;
(Excuse my variables, I just wanted to show you what the function looked
like.)
After creating your window, you have a message loop which directs Windows
messages to your callback function
while( GetMessage( &msg, NULL, 0, 0 ) ) {
TranslateMessage( &msg );
DispatchMessage( &msg );
}
Only after all that can you start catching messages and your callback
function it would look a little like this ...
LRESULT CALLBACK MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam ){
switch (uMsg) {
case WM_MOUSEMOVE:
//do stuff here
// the coordinates of the mouse are given to you in the
LPARAM
parameter.
}
return 1;
}
You should be able to download the Platform SDK from the Microsoft site.
I know nothing of DevC++ though, so I don't know what is applicable to
you.
Hope some of this helps.
Regards,
Ron Francis
www.RonaldFrancis.com
This really helps Ron, thanks once more :)
If I can't get even that to happen (God forbid) perhaps I can get the
mouse
Coordinates this way..
POINT pos;
GetCursorPos(&pos);
int x = pos.x; x = x / 8
int y = pos.y; y = y / 12
cout << "Mouse Coordinates: " << x << ", " << y << endl;
system("pause");
Of course, how much I divide x and y for depends on the current size
setting
of each letter on DOS, in this case 8 wide by 12 high.
.
- Follow-Ups:
- Re: Detect mouse click and coordinates (C++)
- From: Gary Chanson
- Re: Detect mouse click and coordinates (C++)
- References:
- Re: Detect mouse click and coordinates (C++)
- From: Ron Francis
- Re: Detect mouse click and coordinates (C++)
- From: Ron Francis
- Re: Detect mouse click and coordinates (C++)
- From: Ash44455666
- Re: Detect mouse click and coordinates (C++)
- Prev by Date: Re: sizeable window without a system menu?
- Next by Date: RE: ICON not correct
- Previous by thread: Re: Detect mouse click and coordinates (C++)
- Next by thread: Re: Detect mouse click and coordinates (C++)
- Index(es):
Relevant Pages
|