Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello there,

I have an issue related to the usage of the bitmap enabled Dialog window. I have created a keyboard type layout and I wish to get the input through keyboard also. When I use the mouse, I am able to get the button(s) pressed and also all the buttons are working fine - the other images DEFAULT, SELECTED, DISABLED... all get loaded and work since I am using the function m_BtnBtn1Ctrl.LoadBitmaps. But then, any key pressed on keyboard and the corresponding character on the screen isn't able to do the same as I have been able to do it with clicking of the mouse (and using the Loadbitmaps() function).

I am using these 3 functions to achieve the same action and effect as that of using a mouse:

- LoadBitmap()
- SetBitmap()
- Invalidate()

But these don't seem to give the pressed button effect though internally they work. Can some one please help me with this?

Thanks and regards
Sayonee

C#
BOOL KeyBoard_press::PreTranslateMessage(MSG* pMsg)
{
    // TODO: Add your specialized code here and/or call the base class
    CString strTemp;
    if (pMsg->message == WM_KEYDOWN)
    {
        if ( pMsg->wParam == 0x41 || pMsg->wParam == 0x61) //check for both 'a' and 'A'
            OnBtnBtn1();
        if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_DELETE ||
            pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_TAB ||
            pMsg->wParam == VK_UP || pMsg->wParam == VK_DOWN || GetKeyState (VK_CONTROL))
            {
                ::TranslateMessage (pMsg);
                ::DispatchMessage (pMsg);
                return TRUE;                // DO NOT process further
            }
    }
    return CDialog::PreTranslateMessage(pMsg);
}


[edit]removed bolding[/edit]
Posted
Updated 27-Aug-10 8:01am
v3
Comments
Niklas L 24-Aug-10 4:24am    
Are you hitting your PreTranslateMessage at all? Could it be a focus issue? I.e. messages going to the wrong window/control?

I guess it has something to do with focus? Try SetFocus().

Rozis
 
Share this answer
 
nope tried everything ..sorry this reply of mine is late and my work had kept me busy instead I was "focussing" :doh: on some other issues any code example will help me ..thanks again
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900