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 / Languages / Managed C++ / March 2008

Tip: Looking for answers? Try searching our database.

WinForms Textbox in MFC CDialogBar

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Baer - 05 Mar 2008 16:20 GMT
I posted this on the msdn forums. Sorry for crossposting, but I haven't
received any answer and I want to try here before calling someone at
Microsoft.

We have an MFC application that supports both MFC and .NET plug-ins. If
plug-ins want to use docking dialogs, we embed UserControls in our CCtrlBar
derived classes. All of this works great except for the .NET TextBoxes. The
TextBoxes will display correctly and receive input; the only problem is that
they don't receive KeyDown events for "Enter" and "Escape" keys.

I have written a simple example with VC2005 that displays this problem by
embedding a multiline TextBox on a CDialogBar. The TextBox will not allow
for multiline input because the "Enter" KeyDown event is getting eaten
somewhere along the way. I posted the project at
http://en.wiki.mcneel.com/content/upload/files/WinFormsCtrlBar.zip
in case anyone is interested.

My question is:
How do I get a multiline WinForms textbox to work if it is a child of a
CDialogBar?

Any help would be appreciated. Thanks,
-Steve

Steve Baer
Robert McNeel & Associates
Frank Hickman - 06 Mar 2008 04:32 GMT
>I posted this on the msdn forums. Sorry for crossposting, but I haven't
>received any answer and I want to try here before calling someone at
[quoted text clipped - 23 lines]
> Steve Baer
> Robert McNeel & Associates

I'm not really sure what is gobbling up the return key but you can force the
control to handle it by adding the following to your OnKeyUp handler...

virtual void OnKeyUp( System::Windows::Forms::KeyEventArgs^ e ) override
{
   if ( e->KeyCode == System::Windows::Forms::Keys::Return )
   {
       if ( this->Multiline )
       {
           this->AppendText( L"\r\n" );
           e->Handled= true;
       }
   }
   int good_break_point = 0;
}

HTH
Signature

============
Frank Hickman
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.

Steve Baer - 06 Mar 2008 19:44 GMT
Hi Frank,
Yep that is one possible solution, but from the reports I've received from
plug-in developers there are other events not getting fired because of the
missing KeyDown. One developer has a single line textbox that receives
validation events in his standalone version when the enter key is pressed,
but does not get that event when embedded in one of our CCtrlBars. I was
trying to keep the sample as simple as possible and only point out the
obvious problem with multiline textboxes.

Thanks for looking though. I do appreciate it.

-Steve

Steve Baer
Robert McNeel & Associates

>>I posted this on the msdn forums. Sorry for crossposting, but I haven't
>>received any answer and I want to try here before calling someone at
[quoted text clipped - 42 lines]
>
> HTH
Frank Hickman - 08 Mar 2008 06:10 GMT
> Hi Frank,
> Yep that is one possible solution, but from the reports I've received from
[quoted text clipped - 11 lines]
> Steve Baer
> Robert McNeel & Associates

Hmm, I would hazard a guess that your problem is related to the problem of
handling the return/escape key in a dialog box.  Have you attempted to trap
the message from the message loop before anything else can get a hold of it?

Signature

============
Frank Hickman
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.


Rate this thread:







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.