Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2007

Tip: Looking for answers? Try searching our database.

mfc host app and keyboard navigation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Josh Cooley - 16 Mar 2007 22:40 GMT
I have a problem with keyboard navigation using winforms and an MFC based
host application.  Do you see any problems calling PreProcessMessage as a
work around?

Here is the solution I came up with:

// override CWinApp::PreTranslateMessage
bool HandleMessage(MSG* pMsg);
BOOL CMfcHostDialogApp::PreTranslateMessage(MSG* pMsg)
{
    if (HandleMessage(pMsg))
        return TRUE;
    return CWinApp::PreTranslateMessage(pMsg);
}

// attempt to handle messages for managed controls
using namespace System;
using namespace System::Windows::Forms;

bool HandleMessage(MSG* pMsg)
{
    if (pMsg != NULL && pMsg->hwnd != NULL)
    {
        Control^ control = Control::FromHandle(IntPtr(pMsg->hwnd));
        if (control != nullptr)
            return control->PreProcessMessage(Message::Create(IntPtr(pMsg->hwnd),
pMsg->message, IntPtr((void*)pMsg->wParam), IntPtr(pMsg->lParam)));
    }
    return false;
}

// end sample code

I can send a full sample solution if necessary.
Bryan Phillips - 17 Mar 2007 06:08 GMT
What problem are you trying to work around?

--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog:  http://bphillips76.spaces.live.com

> I have a problem with keyboard navigation using winforms and an MFC based
> host application.  Do you see any problems calling PreProcessMessage as a
[quoted text clipped - 30 lines]
>
> I can send a full sample solution if necessary.
Josh Cooley - 17 Mar 2007 19:37 GMT
I need to be able to tab between controls on winforms based dialogs.  I also
need to use keyboard accelerators on winforms based dialogs.  Keyboard
navigation is broken when the dialogs are created modeless in an MFC app.

> What problem are you trying to work around?
>
[quoted text clipped - 37 lines]
> >
> > I can send a full sample solution if necessary.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.