Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Dumb mouse problem

This topic is 6086 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I made a program... and for some reason it ain''t recording the mouse coordinates properly... take a look at my code and tell me what''s wrong..i know this because I used a message box to get the coordinates each time the mouse moved but it doesn''t give the right value plus i tried creating a point wherever i clicked and that doesn''t work either... also is it possible to get the coordinates after clickin the left mouse button (ie in WM_LBUTTONDOWN) btw, mousex and mousey are global variables.
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
	static HGLRC hRC;					// rendering context

	static HDC hDC;						// device context

	int width, height;					// window width and height

		case WM_CREATE:					// window is being created

			hDC = GetDC(hwnd);			// get current window''s device context

			g_HDC = hDC;
			SetupPixelFormat(hDC);		// call our pixel format setup function

			// create rendering context and make it current

			hRC = wglCreateContext(hDC);
			wglMakeCurrent(hDC, hRC);

			return 0;

		case WM_CLOSE:					// windows is closing

			// deselect rendering context and delete it

			wglMakeCurrent(hDC, NULL);

			// send WM_QUIT to message queue


			return 0;

		case WM_SIZE:
			height = HIWORD(lParam);		// retrieve width and height

			width = LOWORD(lParam);

			if (height==0)					// don''t want a divide by zero


			glViewport(0, 0, width, height);	// reset the viewport to new dimensions

			glMatrixMode(GL_PROJECTION);		// set projection matrix current matrix

			glLoadIdentity();					// reset projection matrix

			// calculate aspect ratio of window


			glMatrixMode(GL_MODELVIEW);			// set modelview matrix

			glLoadIdentity();					// reset modelview matrix

			return 0;

		case WM_KEYDOWN:					// is a key pressed?

			keyPressed[wParam] = true;
			return 0;

		case WM_KEYUP:
			keyPressed[wParam] = false;
			return 0;

			MouseX = LOWORD(lParam);
			MouseY = HIWORD(lParam);
			return 0;
			return 0;

	return (DefWindowProc(hwnd, message, wParam, lParam));
"A computer and man are similar in all respects except for the fact that a computer doesn''t blame another computer for it''s mistakes." ~wUn LoVe tO aLl ThE mAlUs OuT tHeRe!~

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!