Skip to main content
GameDev.net gamedev.net
🔒 Locked

WM_CHAR does not trigger

Started by DarkNebula Apr 24, 2004 at 5:28 PM 3 replies 350+ views
Original Post
DarkNebula
DarkNebula
I put the WM_CHAR in my winproc but no key triggers it. Wondering what is going on... I am using the NeHe Basecode, a little modified, because I added some things to it...
LRESULT CALLBACK WindowProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	// Get The Window Context

	GL_Window* window = (GL_Window*)(GetWindowLong (hWnd, GWL_USERDATA));

	switch (uMsg)														// Evaluate Window Message

	{
        case WM_CHAR:
        {
			window->keys->LastChar = wParam;
			MessageBox(NULL, (char*)window->keys->LastChar, "moo", MB_OK);
			return 0;
        }
- DarkNebula Galatron.net - The massively multiplayer real time strategy!
Sneftel
Sneftel
Do any other window messages get handled by your switch statement?


"Sneftel is correct, if rather vulgar." --Flarelocke
DarkNebula
DarkNebula
Here is the whole thing:

LRESULT CALLBACK WindowProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
// Get The Window Context

GL_Window* window = (GL_Window*)(GetWindowLong (hWnd, GWL_USERDATA));

switch (uMsg) // Evaluate Window Message

{
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

}
return 0; // Return


case WM_CREATE: // Window Creation

{
CREATESTRUCT* creation = (CREATESTRUCT*)(lParam); // Store Window Structure Pointer

window = (GL_Window*)(creation->lpCreateParams);
SetWindowLong (hWnd, GWL_USERDATA, (LONG)(window));
}
return 0; // Return


case WM_CLOSE: // Closing The Window

TerminateApplication(window); // Terminate The Application

return 0; // Return


case WM_SIZE: // Size Action Has Taken Place

switch (wParam) // Evaluate Size Action

{
case SIZE_MINIMIZED: // Was Window Minimized?

window->isVisible = false; // Set isVisible To false

return 0; // Return


case SIZE_MAXIMIZED: // Was Window Maximized?

window->isVisible = true; // Set isVisible To true

ReshapeGL (LOWORD (lParam), HIWORD (lParam)); // Reshape Window - LoWord=Width, HiWord=Height

return 0; // Return


case SIZE_RESTORED: // Was Window Restored?

window->isVisible = true; // Set isVisible To true

ReshapeGL (LOWORD (lParam), HIWORD (lParam)); // Reshape Window - LoWord=Width, HiWord=Height

return 0; // Return

}
break; // Break


case WM_MOUSEMOVE:
{
window->mouse->x = LOWORD(lParam);
window->mouse->y = window->init.height-HIWORD(lParam);
return 0;
}

case WM_LBUTTONDOWN:
{
window->mouse->LButtonClick=true;
window->mouse->LButtonUp=false;
return 0;
}

case WM_CHAR:
{
window->keys->LastChar = wParam;
MessageBox(NULL, (char*)window->keys->LastChar, "moo", MB_OK);
return 0;
}

case WM_LBUTTONUP:
{
window->mouse->LButtonClick=false;
window->mouse->LButtonUp=true;
return 0;
}

case WM_KEYDOWN: // Update Keyboard Buffers For Keys Pressed

if ((wParam >= 0) && (wParam <= 255)) // Is Key (wParam) In A Valid Range?

{
window->keys->keyDown [wParam] = true; // Set The Selected Key (wParam) To true

return 0; // Return

}
break; // Break


case WM_KEYUP: // Update Keyboard Buffers For Keys Released

if ((wParam >= 0) && (wParam <= 255)) // Is Key (wParam) In A Valid Range?

{
window->keys->keyDown [wParam] = false; // Set The Selected Key (wParam) To false

return 0; // Return

}
break; // Break*/


case WM_TOGGLEFULLSCREEN: // Toggle FullScreen Mode On/Off

g_createFullScreen = (g_createFullScreen == true) ? false : true;
PostMessage (hWnd, WM_QUIT, 0, 0);
break; // Break

}

return DefWindowProc (hWnd, uMsg, wParam, lParam); // Pass Unhandled Messages To DefWindowProc

}


- DarkNebula
Galatron.net - The massively multiplayer real time strategy!
arm
arm
Make sure that the message loop calls TranslateMessage before it calls DispatchMessage.

Edit:

MSG msg;

while(GetMessage(&msg,0,0,0))
{
TranslateMessage(&msg); // <- Here
DispatchMessage(&msg);
}

lol, I just noticed the "moo" string.


[edited by - arm on April 24, 2004 7:06:56 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.