Solved

MFC OCX

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

760 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

22 Experts available now in Live!

Get 1:1 Help Now