Jump to content
  • Advertisement
Sign in to follow this  
jake_Ghost

Problem getting lower case characters for text box

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

My window class calls my updatetext function every frame to see if the user has typed anything. They only thing that doesnt work properly is the lower case characters. Right now, if they have the shift key pressed, it will make the letters capital... heres the source.
void cTextBox :: UpdateText(Keys &key)
{
	if (cprb_Visible_I && !cprb_Disabled_I && cprb_Focus_I)
	{
		if (key.keyDown[VK_BACK] == TRUE)
		{
			cprs_Text_I = cprs_Text_I.substr(0,cprs_Text_I.length() - 1);
			key.keyDown[VK_BACK] = false;
		}
		else if (cprs_Text_I.length() >= cpri_MaxChar_I)
		{
		}
		else if (key.keyDown[VK_SHIFT] == TRUE)
		{
			for (int i = 65; i < 91; i++)
			{
				if (key.keyDown == TRUE)
				{
					cprs_Text_I += i;
					key.keyDown = false;
				}
			}
		}
		else
		{
			for (int i = 65; i < 91; i++)
			{
				if (key.keyDown == TRUE)
				{
					cprs_Text_I += i;
					key.keyDown = false;
				}
			}
		}
	}
}

As you can see, i have no clue on how to make the characters lower case. Jake

Share this post


Link to post
Share on other sites
Advertisement
im not sure exactly how you are getting the keys but this may help



MessageHandler (UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_CHAR: //<--- catch this

myConsole->OnKeyDown(wParam); //<--- send to your keys?
switch(wParam)
{
case VK_F1:
{
PostQuitMessage(0);
break;
}
}
break;
case WM_CLOSE:
PostQuitMessage(0);
return true;
break;

//CLOSE WINDOW
case WM_DESTROY:
PostQuitMessage(0);
return true;
break;

//NOT HANDLED - LET WINDOWS HANDLE
default:
return false;
break;
}
// WE HANDLED THE MESSAGE
return true;
}



you would be interested in the WM_CHAR part which catches all the key state changes for you..

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!