Advertisement

WinProc and wParam

Started by January 10, 2004 11:01 AM
3 comments, last by Mr Lane 21 years, 1 month ago
I have split the code into several source files and now I dont seem to be able to at all catch key inputs from wParam. For example, if I hard code a global variable to be VK_ESCAPE, then it will take on the value (of course), but if i assign wParam as the value of that variable, pressing the ESC key while the window is running does not set the value to VK_ESCAPE (i know because the program does not quit). Can anyone possibly tell me why wParam might not be sending key messages? Thanks
Erm... the only thing I can think of, based on your post, is that you''re not processing the messages correctly. Since I quite honestly cannot understand your problem 100%, you might want to post some code.





"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Advertisement
Ok this is my input.c file. WinPro is called from CreateGLWindow, just like in the original NeHe code.

#include "Input.h"int keys[256];int getInput(MSG msg, input_t *input){	if (msg.message==WM_QUIT)		// Have We Received A Quit Message?	{		input->bQuit=TRUE;		return 1;			//Returing 1 will result in calling function	}						//Requesting a quit.		if (msg.message==WM_KEYDOWN)	{		if (keys[VK_ESCAPE]==TRUE)		{			input->bQuit=TRUE;			keys[VK_ESCAPE] = FALSE;			return 1;		}  		/*		if (keyNum==VK_UP)		{			input->bLeft=TRUE;		}		if (keyNum==VK_DOWN)		{			input->bDown=TRUE;		}		if (keyNum==VK_LEFT)		{			input->bLeft=TRUE;		}		if (keyNum==VK_RIGHT)		{			input->bRight=TRUE;		}*/	}	return 0;}LRESULT CALLBACK WndProc(	HWND	hWnd,			// Handle For This Window							UINT	uMsg,			// Message For This Window							WPARAM	wParam,			// Additional Message Information							LPARAM	lParam)			// Additional Message Information{	switch (uMsg)									// Check For Windows Messages	{/*		case WM_ACTIVATE:							// Watch For Window Activate Message		{			if (!HIWORD(wParam))					// Check Minimization State			{				active=TRUE;						// Program Is Active			}			else			{				active=FALSE;						// Program Is No Longer Active			}			return 0;								// Return To The Message Loop		}*/		case WM_SYSCOMMAND:							// Intercept System Commands		{			switch (wParam)							// Check System Calls			{				case SC_SCREENSAVE:					// Screensaver Trying To Start?				case SC_MONITORPOWER:				// Monitor Trying To Enter Powersave?				return 0;							// Prevent From Happening			}			break;									// Exit		}		case WM_CLOSE:								// Did We Receive A Close Message?		{			PostQuitMessage(0);						// Send A Quit Message			return 0;								// Jump Back		}		case WM_KEYDOWN:							// Is A Key Being Held Down?		{			keys[wParam] = TRUE;					// If So, Mark It As TRUE			return 0;								// Jump Back		}		case WM_KEYUP:								// Has A Key Been Released?		{			keys[wParam] = FALSE;					// If So, Mark It As FALSE			return 0;								// Jump Back		}		case WM_SIZE:								// Resize The OpenGL Window		{			ReSizeGLScene(LOWORD(lParam),HIWORD(lParam));  // LoWord=Width, HiWord=Height			return 0;								// Jump Back		}	}	// Pass All Unhandled Messages To DefWindowProc	return DefWindowProc(hWnd,uMsg,wParam,lParam);}


For some reason wParam does to seem to give any value to the array index, or to normal variable when i tried it.

[edited by - Mr Lane on January 10, 2004 12:37:32 PM]
Problem solved. The key array was declared in 2 locations. (yes you may laugh at me)
uhm . . . ha ha ha . . . (I don''t get it)
The Love Of Trees

This topic is closed to new replies.

Advertisement