Solved

MFC OCX

Posted on 1998-07-16
4
652 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

816 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now