Sign in to follow this  
jake_Ghost

Problem getting lower case characters for text box

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[i] == TRUE)
				{
					cprs_Text_I += i;
					key.keyDown[i] = false;
				}
			}
		}
		else
		{
			for (int i = 65; i < 91; i++)
			{
				if (key.keyDown[i] == TRUE)
				{
					cprs_Text_I += i;
					key.keyDown[i] = 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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this