- assigned_to: nobody --> nenadstefanovic
How to check the "bug": create an SDI app with a form-
type View and add an edit-box control. Now compile
and run. Write something in the Edit box. Select it.
Open the "Edit" menu. The selection disappear. This
is probably not wanted if you have a form based app.
The solution (found in the WTL mailing list.. It was
written by rdheadrick2 but I have modified it a
little) http://groups.yahoo.com/group/wtl/message/4458
class CCommandBarCtrlImplFocus : public
CCommandBarCtrlImpl<CCommandBarCtrlImplFocus>
{
public:
CCommandBarCtrlImplFocus()
{
m_dwExtendedStyle |=
CBR_EX_ALTFOCUSMODE;
}
void TakeFocus()
{
if((m_dwExtendedStyle &
CBR_EX_ALTFOCUSMODE) && m_hWndFocus == NULL) {
m_hWndFocus = ::GetFocus();
}
}
BOOL PreTranslateMessage(MSG* pMsg)
{
if((pMsg->message == WM_KEYDOWN) && !
m_bMenuActive && IsWindow() && GetAnchorHighlight()) {
if (pMsg->wParam ==
VK_ESCAPE) {
SetAnchorHighlight
(FALSE);
SetHotItem(-1);
if(m_bUseKeyboardCues
&& m_bShowKeyboardCues) {
ShowKeyboardCues(false);
}
} else {
::SendMessage(m_hWnd,
pMsg->message, pMsg->wParam, pMsg->lParam);
}
return TRUE;
}
return FALSE;
}
};
and in the PreTranslateMessage of the mainfrm:
if (m_CmdBar.PreTranslateMessage(pMsg))
return TRUE;
Anonymous