Need help tabbing on control hosted in CAxDialogImpl 
Author Message
 Need help tabbing on control hosted in CAxDialogImpl

Hi.

I'm subclassing from CAXDialogImpl to create a dialog that hosts a
single ActiveX control.  For purposes of discussion, let's say the
single ActiveX control contains three edit boxes.  To get tabbing to
work inside the ActiveX control, I'm implementing my own variation of
DoModal so my dialog will forward messages to the control (code
included below).

Things are working pretty well, except after I tab through the three
edit boxes on the ActiveX control, and I press tab again, the focus
does not cycle back to the first edit box, but remains on the third
edit box.

As an experiment, I tried adding a button  to the dialog outside of
the single ActiveX control. Then, the first time I tab to the ActiveX
control, tabbing cycles through its three edit boxes.  On the next
tab, focus moves to the button on the dialog.  The next tab returns
focus to the ActiveX control, but the focus is on the third edit box,
not the first, as I would like it to be.  The next tab then moves the
focus to the button on the dialog.

Any ideas for how I can get the cycling to work?

Thanks very much.

Jeff

template <class T, int nCtrlID> int BaseDlg<T, nCtrlID>::my_do_modal()
{
        // nCtrlID is the ID of the single ActiveX control to be hosted

        m_bModal = TRUE;
        m_hwndModalParent = ::GetActiveWindow();
        m_bDestroyed = FALSE; // m_bDestroyed will be set in my_end_dialog

        Create( m_hwndModalParent );
        ::EnableWindow( m_hwndModalParent, FALSE );
        ShowWindow( SW_SHOW );

        MSG msg;
        while( !m_bDestroyed && GetMessage( &msg, NULL, 0, 0 ) ){

                BOOL bForwarded = FALSE;

                if( msg.message != WM_FORWARDMSG &&
                ( ( msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST ) ||
                  ( msg.message >= WM_MOUSEFIRST && msg.message <= WM_MOUSELAST )))
                {
                    HWND hwndCtl = GetDlgItem( nCtrlID );

                    if( ::SendMessage( hwndCtl,
                                       WM_FORWARDMSG,
                                       0, (LPARAM)( &msg )) == 1 )
                        bForwarded = TRUE;
                }

                if( !bForwarded )
                {
                        if( !IsWindow() || !IsDialogMessage( &msg ))
                                DispatchMessage( &msg );
                }      
        }

        return m_nRetval; // set in my_end_dialog();

Quote:
}



Tue, 18 Nov 2003 09:48:38 GMT  
 Need help tabbing on control hosted in CAxDialogImpl
Does the ActiveX control work fine in test container?

yhhuang
ICQ:91074870



Tue, 18 Nov 2003 15:04:14 GMT  
 Need help tabbing on control hosted in CAxDialogImpl

Quote:

> Does the ActiveX control work fine in test container?

> yhhuang
> ICQ:91074870

Thanks a lot for the response.

Good question about the Test Container.  In the case where the ActiveX
control is the only control in Test Container, the behavior is the
same as on CAxDialogImpl: after tabbing through the three edit boxes
on the control, the focus remains in the third edit box on subsequent
tabs.

However, if I add another control to Test Container (so now we have
both my ActiveX control and another control in the Container), then
the behavior is better than CAxDialogImpl.  After tabbing through the
three edit boxes on the control, on the next tab the focus moves to
the other control.  On the tab after that, focus returns to the first
edit box in my control.  This is exactly what I'm looking for.

I think there might be something going on here with UI Activate and UI
Deactivate.  I'm not all that familiar with the interactions between a
control and its container, but I'm going to dig into the Test
Container source and see what I can figure out.

Thanks again, and I'm interested to hear any other input.

Jeff



Wed, 19 Nov 2003 03:05:27 GMT  
 Need help tabbing on control hosted in CAxDialogImpl
Recommend one series of MSJ articles to you:
"Write ActiveX Controls Using Custom Interfaces Provided by ATL 3.0" Part
I, II, III
MSJ Feb, Mar, Apr 1999

"Extending ATL 3.0 Control Containment to Help You Wrtie Real-world
Containers"
MSJ Dec, 1999.

Hope it helps.

yhhuang
ICQ:91074870



Fri, 21 Nov 2003 11:46:10 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Tabs does not work in webbrowser control hosted by CAxWindow in CAxDialogImpl

2. CAxDialogImpl host Full Control Fail

3. Problem with CAxDialogImpl and hosting multiple ActiveX Controls

4. CAxDialogImpl doesn't fully host...

5. Need help with tabbing to custom control

6. MFC - Tab Control, help needed!

7. Need help with trying to get the host name from the ip number using gethostbyaddr

8. Need help: regular MFC DLL to host ActiveX ?

9. HELP: Hosting ActiveX controls and Windows

10. HELP: hosting WebBrowser control

11. ActiveX control in CAxDialogImpl

12. Composite control hosted by a composite control.

 

 
Powered by phpBB® Forum Software