prevent window from getting focus

  • Thread starter Thread starter David Ellis
  • Start date Start date
D

David Ellis

I am working on a replacement to the on-screen keyboard that comes with Win
XP. I would like to emulate the following behaviors that it has:

1. The caption bar and menu bar are active. I need to be able to click on
the caption and drag the window around and use the menus.
2 When the mouse is moved over the "keyboard" window. I need focus to go
back to whatever window had the focus prior to the keyboard getting focus.
3. When the mouse is clicked on the "keyboard", I need to send a message to
the window with the focus so that the appropriate keystroke occurs.
4. When "keyboard" is clicked, I do not want the keyboard to get the focus.

I have accomplished 1-3. I have tried using a main window that has the
caption, menu, etc. with a child window which is the actual "keyboard".
However, when I click on the keyboard, the main window gets the focus for a
moment and the keyboard changes to the active state for a moment and then
changes back. How can I keep the window from being activated at all?

I have also tried using a single window created with the WS_EX_NOACTIVE
extended style. When I do this the menus do not work. I click on one an it
does not open.

Can anyone point me in the right direction?

Dave
 
David said:
I am working on a replacement to the on-screen keyboard that comes with Win
XP. I would like to emulate the following behaviors that it has:

1. The caption bar and menu bar are active. I need to be able to click on
the caption and drag the window around and use the menus.
2 When the mouse is moved over the "keyboard" window. I need focus to go
back to whatever window had the focus prior to the keyboard getting focus.
3. When the mouse is clicked on the "keyboard", I need to send a message to
the window with the focus so that the appropriate keystroke occurs.
4. When "keyboard" is clicked, I do not want the keyboard to get the focus.

I have accomplished 1-3. I have tried using a main window that has the
caption, menu, etc. with a child window which is the actual "keyboard".
However, when I click on the keyboard, the main window gets the focus for a
moment and the keyboard changes to the active state for a moment and then
changes back. How can I keep the window from being activated at all?

I have also tried using a single window created with the WS_EX_NOACTIVE
extended style. When I do this the menus do not work. I click on one an it
does not open.

Can anyone point me in the right direction?

Dave

I don't know if this'll help or not, but i have class CKeyButton that is
derived from CButton that does an on screen keyboard. Unlike you i am
using one button per key.

<code>
void CKeyButton::OnLButtonDown(UINT nFlags, CPoint point)
{
if( !m_message )
{
keybd_event( m_vk,m_vk,0,0 );
keybd_event( m_vk,m_vk, KEYEVENTF_KEYUP,0 );
}
else
::PostMessage( ::GetActiveWindow(), m_message, 0, 0 );
}

int CKeyButton::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT
message)
{
return MA_NOACTIVATE;
}

void CKeyButton::OnLButtonDblClk(UINT nFlags, CPoint point)
{
keybd_event( m_vk,m_vk,0,0 );
keybd_event( m_vk,m_vk, KEYEVENTF_KEYUP,0 );
}
</code>

i think they key may be "return MA_NOACTIVATE"

keith d. zimmerman, mcsd
 
MA_NOACTIVATE was what I needed.

Thanks

keith d. zimmerman said:
I don't know if this'll help or not, but i have class CKeyButton that is
derived from CButton that does an on screen keyboard. Unlike you i am
using one button per key.

<code>
void CKeyButton::OnLButtonDown(UINT nFlags, CPoint point)
{
if( !m_message )
{
keybd_event( m_vk,m_vk,0,0 );
keybd_event( m_vk,m_vk, KEYEVENTF_KEYUP,0 );
}
else
::PostMessage( ::GetActiveWindow(), m_message, 0, 0 );
}

int CKeyButton::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT
message)
{
return MA_NOACTIVATE;
}

void CKeyButton::OnLButtonDblClk(UINT nFlags, CPoint point)
{
keybd_event( m_vk,m_vk,0,0 );
keybd_event( m_vk,m_vk, KEYEVENTF_KEYUP,0 );
}
</code>

i think they key may be "return MA_NOACTIVATE"

keith d. zimmerman, mcsd
 
Back
Top