about floating keyboard
-
Hello , I have a ownerdraw button on a dialog box which is created in an SDI application where buttons are members of dialog class and when evet i click the button i want the keyboard key event to be generated and that caracter should be displayed on the client area what should i do in sent message for this for example if i have A on my button when ever user clicks that button keyboards keyevent should generate and that should be passed and displayed on editview area i have a the function void MyDialog::OnButton49() { /* unsigned char arr[256]; int i= GetKeyboardType(1); GetKeyboardState(arr); GetKeyNameText(49,"a",1); //GetKeyboardLayoutList( GetLastError();*/ // this->GetParent()->SendMessage(WM_PAINT,nRepCnt,nFlags); //SetKeyboardState(; //Get // int i=GetKeyState(49); // if(i==1) GetParent()->SendMessage(WM_CAPTURECHANGED,49,1); //n_butFlag=49; } like this for displaying 'a' on in my dialog class Request to all to continue this
-
Hello , I have a ownerdraw button on a dialog box which is created in an SDI application where buttons are members of dialog class and when evet i click the button i want the keyboard key event to be generated and that caracter should be displayed on the client area what should i do in sent message for this for example if i have A on my button when ever user clicks that button keyboards keyevent should generate and that should be passed and displayed on editview area i have a the function void MyDialog::OnButton49() { /* unsigned char arr[256]; int i= GetKeyboardType(1); GetKeyboardState(arr); GetKeyNameText(49,"a",1); //GetKeyboardLayoutList( GetLastError();*/ // this->GetParent()->SendMessage(WM_PAINT,nRepCnt,nFlags); //SetKeyboardState(; //Get // int i=GetKeyState(49); // if(i==1) GetParent()->SendMessage(WM_CAPTURECHANGED,49,1); //n_butFlag=49; } like this for displaying 'a' on in my dialog class Request to all to continue this
Take a look at MSDN - Keyboard Input[^]. There you can find messages you can pass to the window that must think that someone pressed that specific key on the keyboard. You can send WM_KEYDOWN or WM_SYSKEYDOWN when the button is pressed, and WM_KEYUP or WM_SYSKEYUP when the button is released. For instance, you could do
void MyDialog::OnButton49()
{
GetParent()->SendMessage(WM_CAPTURECHANGED,49,1);
GetParent()->SendMessage(WM_KEYDOWN, VK_A, NULL);
GetParent()->SendMessage(WM_KEYUP, VK_A, NULL);
}I'm not sure about those VK_A (I'm at school now and I don't know the Virtual Key list by heart). You can also replace those NULLs by control codes that indicate if CTRL or AltGrp is pressed in addition. By the way, don't include too much commented lines. It looks nasty and it makes it unreadable. There is also a way to use one single function for all buttons (with a custom WindowProc), so that you don't have to make a function for each button on your virtual keyboard.