artoon
artoon

Reputation: 739

MFC interface with tabControl

I have a window with different control and a TabControl which contains some TabPage. Each TabPage is associated with a class. The code for this class must be able to act on controls of the main window.

I tried in a TabPage class to create a pointer to the main window and the associated set method but I can not create element type of the main window.

How should I do?

class CMedialexieDlg : public CDialogEx { public:

CTabCtrl        m_TabControl; /*!< TabControl de la fenetre */
TabPage1        tabPage1; /*!< Onglet des contacts */
TabPage2        tabPage2; /*!< Onglet des groupes */
TabPage3        tabPage3; /*!< Onglet des ventes */
CTreeCtrl       m_TreeControlContact; /*!< TreeControl regroupant les differents contacts */
CTreeCtrl   m_TreeControlGroupe; /*!< TreeControl regroupant les differents groupes et contacts */

... }

and in the class TabPage1

void TabPage1::OnClickedTbp1ButtonAnuler() { m_TreeControlGroupe.EnableWindows(false); }

Upvotes: 0

Views: 208

Answers (1)

Nik Bougalis
Nik Bougalis

Reputation: 10613

First of all, you really should show some code demonstrating what you tried to do, instead of (poorly) describing it to us and leaving us guessing.

With that said, why can't you use AfxGetMainWnd() to get a pointer to your main window?

One thing to note: you should be careful as directly manipulating other windows can cause subtle problems/bugs that are difficult to track down; it can also can cause headaches if you later try to make your application multi-threaded. You should prefer exchanging messages.

Upvotes: 1

Related Questions