Click here to Skip to main content
15,891,529 members
Articles / Desktop Programming / MFC

Encapsulating interacting controls

Rate me:
Please Sign up or sign in to vote.
4.32/5 (9 votes)
31 Aug 20035 min read 52.2K   1K   19  
How to get controls to interact with each other without help from their parent dialog box.
#if !defined(AFX_TESTDIALOG_H__9BC8EAF3_D4F9_11D7_A638_002018641C4D__INCLUDED_)
#define AFX_TESTDIALOG_H__9BC8EAF3_D4F9_11D7_A638_002018641C4D__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// TestDialog.h : header file
//

#include "CustomWnd.h"

/////////////////////////////////////////////////////////////////////////////
// CRH_TestDialog dialog

class CRH_TestDialog : public CDialog
{
// Construction
public:
    CRH_TestDialog(CWnd* pParent = NULL);   // standard constructor

// Dialog Data
    //{{AFX_DATA(CRH_TestDialog)
    enum { IDD = IDD_CRH_TESTDIALOG };
    CSliderCtrl	m_Slider1;
    CSliderCtrl	m_Slider2;
    int		m_s1;
    int		m_s2;
    //}}AFX_DATA


// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CRH_TestDialog)
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    //}}AFX_VIRTUAL

// Implementation
protected:

    // Generated message map functions
    //{{AFX_MSG(CRH_TestDialog)
    virtual BOOL OnInitDialog();
    afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()

    afx_msg LRESULT OnCRH_CUSTOMWND_VALUE_HAS_CHANGED(WPARAM wparam, LPARAM lparam);

    CRH_CustomWnd v1CRH_CustomWnd;
    CRH_CustomWnd v2CRH_CustomWnd;
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_TESTDIALOG_H__9BC8EAF3_D4F9_11D7_A638_002018641C4D__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Retired
United Kingdom United Kingdom
I've been programming computers since about 1968. I started at school with Algol 60 on an Elliott 803. From there I progressed through the Z80 and other microprocessors to the PC, DOS and Windows, Pascal, C and C++.

My other interests include astronomy and classical music. All of my contributions to Code Project have arisen from programs I've written in these areas.

Comments and Discussions