• Advertisement

Archived

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

Dumb mouse problem

This topic is 5810 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

 
			switch(message)
	{
		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;
			break;

		case WM_CLOSE:					// windows is closing


			// deselect rendering context and delete it

			wglMakeCurrent(hDC, NULL);
			wglDeleteContext(hRC);

			// send WM_QUIT to message queue

			PostQuitMessage(0);

			return 0;
			break;

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

			width = LOWORD(lParam);

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

			{
				height=1;					
			}

			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

			gluPerspective(54.0f,(GLfloat)width/(GLfloat)height,1.0f,1000.0f);

			glMatrixMode(GL_MODELVIEW);			// set modelview matrix

			glLoadIdentity();					// reset modelview matrix


			return 0;
			break;

		case WM_KEYDOWN:					// is a key pressed?

			keyPressed[wParam] = true;
			return 0;
			break;

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

		case WM_MOUSEMOVE:
			
			
			MouseX = LOWORD(lParam);
			MouseY = HIWORD(lParam);
			return 0;
			break;
		case WM_LBUTTONDOWN:
			
			
		
			return 0;
			break;
			
		default:
			break;
	}

	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

  • Advertisement