Archived

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

Using WM_CHAR???

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

ok im new to using opengl and i wanted to have my program take in a string and then display it....very simple...how would i go about doing this...i know i have to use WM_CHAR but could someone give an example how to write and use it for this purpose...im very confused about this and any help would be greatly appreciated

Share this post


Link to post
Share on other sites
case WM_CHAR:
{
while(!keys[VK_RETURN])
{
stream+=getch();
glPrint("%s",stream);
if(keys[VK_RETURN])
{
BarcodeLookUp(stream);
stream=" ";
}
return 0;
}

i have no clue how to just input a string from the user to be displayed and then passed on into a function later on....anyone know how to do this...just take in input from the user and dispay it...i really need the help...

Share this post


Link to post
Share on other sites
ok i guess im talking to myself but thats cool...cause i guess no one really knows how to do this....*sarcasm....but i did get it to print when the keyboard is hit...but all its printing is zeros...

case VK_DOWN:
{
keys[256] = TRUE;
glPrint("%d",keys[VK_DOWN]);
}

case VK_UP:
{
keys[256] = FALSE;
}

Share this post


Link to post
Share on other sites
Well, I'll try to answer it. You want to use the WM_CHAR message from Windows to get input from the user? Simple.


char sMessage[1024];

LRESULT CALLBACK WndProc(HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{

switch(msg)
{

case WM_CHAR:
{

// Set the key pressed as down...

bKeys[wParam] = TRUE;

// Check for the Enter key...

if(bKeys[VK_RETURN]) memset(sMessage, 0, sizeof(char) * 1024);

// Add any key press to the message...

if(strlen(sMessage) < 1024) strcat(sMessage, (char)wParam);

// Set the key pressed as up...

bKeys[wParam] = FALSE;

}

}

}
You don't necessarily have to empty the string when the Enter key is detected. You could send it to a function which prints it on a console or something. Get a Windows programming book, or search on Google or MSDN for stuff on Windows messages, etc...



Coding Stuff ->  [ iNsAn1tY Games | DarkVertex | How To Do CSG | Direct3D Vs. OpenGL | Google ]
Fun Stuff    ->  [ Evil T-Shirts | Stick-Based Comedy | You're Already Here | The Best Film Reviews ]


[edited by - iNsAn1tY on June 3, 2003 7:54:35 AM]

Share this post


Link to post
Share on other sites
I think that what he''s saying is how to receive text input via OpenGL functions.

Sorry to break it to you, but OpenGL doesn''t support input at all. It was initially designed to be a graphics only API to be cross-platform, unlike DirectX. You should try using GLUT (GL utility toolkit), which is a library of functions designed to work together with OpenGL and add some additional functionality to it, like keyboard input. It''s much easier to learn OpenGL using GLUT rather than jumping directly to mixing it with Win32. You can get GLUT on the OpenGL website (www.opengl.org)

Share this post


Link to post
Share on other sites