Click here to Skip to main content
15,886,110 members
Articles / Programming Languages / Visual C++ 9.0

Tabbed ActiveX Control Modified

Rate me:
Please Sign up or sign in to vote.
3.25/5 (4 votes)
9 Feb 2010CPOL2 min read 26.2K   905   9   3
A Property Sheet as an ActiveX control
TabbedAtxNewVer.JPG

Introduction

Let me tell you that this is not a new article. But this is a modified version of Muhammad Ahmed's article "Tabbed ActiveX control". So if you haven't gone through it, then do it now and then read the following.

Background

I came up with this version of the said article, while I was testing Muhammad's control on my own test container (MFC based client app) instead of the ActiveX Control Test Container provided by Microsoft. If you read his article and the comments thereon, you will find that some people (particularly IrishaS and Subash.k) faced weird problems while using the control. Even I faced the same when I recently tried it. Then I started digging the forums, articles on the related topics on the other sites and put some effort (believe me, at least half a day to figure out a particular solution) to get my own test container working with the control (I will call it as a "Property Sheet as an ActiveX control").

Using the Code

  • I have used VS 2005 to design/change the code attached here.
  • I am also providing the FormView based SDI client app (our own test container) to test the control.
  • You can test the MDI client app on your own.

Major Change Made to the Control

Note: Check the comment "!! Freezing - Solution for property sheets" authored by "Tihamer Levendovszky".
C++
BOOL CSimpleAdditionAtxCtrl::PreTranslateMessage(MSG* pMsg)        
{
    ::TranslateMessage(pMsg);
    ::DispatchMessage(pMsg); 
    return TRUE;    // notice about returning true instead of calling the parent version.
}

Other Changes that are Made to Make the Code More Understandable

  1. Now the ActiveX method SetFirstNumber gets as simple as this:
    C++
    void CSimpleAdditionAtxCtrl::SetFirstNumber(LONG Num1)      
    {
          AFX_MANAGE_STATE(AfxGetStaticModuleState());
          m_InputPage.SetIPageFirstNum(Num1);
    }

    I added a method in the CInputPage class that looks like:

    C++
    void CInputPage::SetIPageFirstNum(long num)
    {
          m_FirstNumber=num;
          UpdateData(FALSE);
    } 

    Note: Similarly I did it for the ActiveX method SetSecondNumber. Review the attached code for full information.

  2. I replaced the code UpdateData(TRUE); from the OnEnChangeEdit1 and OnEnChangeEdit2 event handlers respectively, which was not serving any purpose to the following line in order to enable the button only if the user inputs the value in any of the edit boxes.

    C++
    ((CButton*)(GetDlgItem(IDC_BUTTON1)))->EnableWindow();

    That's it.

Points of Interest

  • With the Dialog based client application/test container, this control doesn't work, i.e. it only works with SDI/MDI FormView type of applications. It is most appreciated if somebody could get this working.
  • The tab key, arrow key, ctrl keys, etc. are not functioning in the ActiveX control. For this, I tried implementing as described by Microsoft here. It worked fine but introduced the app freezing again while testing the control. So I dropped the idea. I wish somebody gets some time to check this out.

History

  • 9th February, 2010: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
Presently, I am working with C#, ASP.Net and Visual C++.Net, Oracle and Telephony SDKs.

email: habeeballah@gmail.com

Comments and Discussions

 
Generalmaybe just can work in child sty dlg ,not popup or Overlapped Pin
rgbbutterfly24-Apr-10 2:10
rgbbutterfly24-Apr-10 2:10 
GeneralIf you put this ocx on MFC dialog it still can't work Pin
rgbbutterfly24-Apr-10 1:56
rgbbutterfly24-Apr-10 1:56 
GeneralMy vote of 2 Pin
Alexandre GRANVAUD9-Feb-10 4:44
Alexandre GRANVAUD9-Feb-10 4:44 
...2

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.