Rectangular selection cause focus lost using MFC feature pack

76 views
Skip to first unread message

yonken

unread,
Feb 17, 2012, 1:54:58 AM2/17/12
to scintilla...@googlegroups.com
Hi All,

I am using Visual Studio 2010 with MFC feature pack, here's the problem I met:

1. Use the Create Project and follow the wizard to create a tabbed MDI application.

2. Replace the base class of the generated view class from CView to CScintillaView (a wrapper class for MFC, written by Naughter).

3. Add some necessary code such as LoadLibrary() to load the scintilla dll.

4. Now hold down the Alt key and drag the mouse to select a rectangular block of text, upon the time you release the Alt key, the editor lost the focus and you can see that the menu have the focus.

Can this be avoided by some mean?

Thanks

Neil Hodgson

unread,
Feb 17, 2012, 3:34:19 AM2/17/12
to scintilla...@googlegroups.com
yonken:

> 4. Now hold down the Alt key and drag the mouse to select a rectangular
> block of text, upon the time you release the Alt key, the editor lost the
> focus and you can see that the menu have the focus.

Doesn't occur in SciTE (which doesn't use MFC) in either the main
window or in a dialog although pressing and releasing Alt without
mouse down does select a menu. Probably best to make a copy of the
project and substitute a standard edit control and see if it occurs
for it as well. If it doesn't then use Spy++ to see how each control
handles the keyboard messages.

Neil

Message has been deleted

Kenny Liu

unread,
Feb 18, 2012, 2:18:33 AM2/18/12
to scintilla...@googlegroups.com
I try to create a new project that use classic standard MDI application (not using MFC feature pack) and use CEditView instead, and the problem is gone for good.

Now I know it's basically because of the new class CMDIFrameWndEx (derives from CMDIFrameWnd), here's some code from the member function CMDIFrameWndEx::PreTranslateMessage:

BOOL CMDIFrameWndEx::PreTranslateMessage(MSG* pMsg)
{
BOOL bProcessAccel = TRUE;

switch(pMsg->message)
{
    case WM_SYSKEYUP:
{
if (m_Impl.m_pMenuBar != NULL && (pMsg->wParam == VK_MENU || (pMsg->wParam == VK_F10 && !isCtrlPressed && !isShiftPressed && !bIMEActive)))
{
if (m_Impl.m_pMenuBar == GetFocus())
{
SetFocus();
}
else
{
if ((pMsg->lParam &(1 << 29)) == 0)
{
m_Impl.m_pMenuBar->SetFocus();
}
}
return TRUE;
}
}
}

As a matter of fact, simply try notepad and it works as expected as well.

If only scintilla can have a special notification that fires when the rectangular selection finish, then probably we can "eat" the WM_SYSKEYUP message?

Otherwise there must be another way to capture this message from the base class of main frame and return TRUE before it get the be handled by CMDIFrameWndEx?

Thanks,
Kenny 

Neil Hodgson

unread,
Feb 18, 2012, 5:17:21 PM2/18/12
to scintilla...@googlegroups.com
Kenny Liu:

> If only scintilla can have a special notification that fires when the
> rectangular selection finish, then probably we can "eat" the WM_SYSKEYUP
> message?

If you subclass Scintilla you can track the states of the mouse
button and Alt key.

Neil

Reply all
Reply to author
Forward
0 new messages