HOWTO: Using Class Wrappers to Access Windows Common Controls in ATLID: Q223439
|
When accessing Windows Common Controls in an MFC dialog box, you can use the thin class wrappers provided by MFC to simplify the task. Unfortunately, ATL does not "officially" provide this functionality.
Normally, this would require you to create your own classes or communicate with the controls by using messages. Thankfully, there is another option. In the ATLCON sample included with Visual C++, you will find ATLControls.h, which has created thin wrapper classes for the Windows Standard and Common Controls. These wrapper classes can be used to access controls on an ATL dialog box or ATL composite control.
Because these classes are not officially in ATL, they are only supported in the context of the sample included with this article. Should you need to, it is a straight-forward process to change the source code of your project's version of ATLControls.h.
The first step is to copy the ATLControls.h file to your project. This can be done as follows:
//***** Adds untested wrapper classes for Win32 common controls.
//***** Used for CTabCtrl. Found in "ATLCON sample (ATL)".
#include "AtlControls.h"
//***** AtlControls.h classes are part of the ATLControls namespace
using namespace ATLControls;
class CForm: ... {
CTabCtrl m_TabCtrl; //*****
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
// Give a Tab Control on the dialog with ID: IDC_TabCtrl
m_TabCtrl = GetDlgItem(IDC_TabCtrl); //*****
// We can now use m_TabCtrl to manipulate the Tab Control.
...
}
Additional query words: CAnimateCtrl, CButton, CComboBox, CComboBoxEx, CDateTimePickerCtrl, CDragListBox, CEdit, CFlatScrollBar, CHeaderCtrl, CHotKeyCtrl, CImageList, CIPAddressCtrl, CListBox, CListViewCtrl, CMonthCalendarCtrl, CPagerCtrl, CProgressBarCtrl, CReBarCtrl, CRichEditCtrl, CScrollBar, CStatic, CStatusBarCtrl, CTabCtrl, CToolBarCtrl, CToolInfo, CToolTipCtrl, CTrackBarCtrl, CTreeItem, CTreeViewCtrl, CTreeViewCtrlEx, CUpDownCtrl.
Keywords : kbsample kbCtrl kbATL300
Version : WINDOWS:3.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: April 21, 1999