Solved

MFC OCX

Posted on 1998-07-16
4
655 Views
Last Modified: 2013-11-20
I'm building an ActiveX control which contains three MFC common controls, two of which are to be tab stops.  If it matters, the three controls are a CStatic, a CEdit and a CButton.  I've got the drawing/painting code down fine, looks great, but it won't correctly handle the tab stops.  If I take the control into VB and embed it onto a form and add a VB command button, the focus is initially on my edit control, press tab, it moves to the VB command button, press tab again and all you get is a beep, no change in focus.  I've set the properties up in VB to make my OCX a tab stop, and set it's tab order.  I've made sure that in VC each of the sub-controls are tabstops as well.  What gives?
0
Comment
Question by:rayb
  • 2
  • 2
4 Comments
 
LVL 2

Author Comment

by:rayb
ID: 1319317
Edited text of question
0
 
LVL 7

Accepted Solution

by:
psdavis earned 20 total points
ID: 1319318
It's probably going to be related to the same type of tab-control problem that you will encounter when adding controls to a view.  If you can get your hands on MFC Developer's Workshop by Frank Crockett, he's got an article about "Tabbing Between Child Window Controls in a Non-Dialog box view".


He basically handles the WM_CHAR and will post a WM_SWITCHFOCUS (user defined) message if the tab key is pressed.

He's got

afx_msg LRESULT OnSwitchFocus( WPARAM wParam, LPARAM lParam )
{
CWnd* pFocusWnd = (CWnd*) wparam;
CWnd* pNextWnd = pFocusWnd->GetNextWindow( );

if( ! pNextWnd )
   pNextWnd = GetWindow( GW_CHILD );

if( pNextWnd )
{
   pNextWnd->SetFocus( );
   return 0L;
}

AfxMessageBox( "error... " );

return (LRESULT) 0;

Hope this helps!
0
 
LVL 2

Author Comment

by:rayb
ID: 1319319
Thanks!  Unfortunately, I've got to move on to another project immediately, so I can't check this out.  But I give you the points anyway as you provided good looking code and pointed out some reference material.
Thank you.
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1319320
Thanks, give me a yell if it doesn't work and I'll try the same here.

Phillip

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question