Читать «Исчерпывающее руководство по написанию всплывающих подсказок» онлайн - страница 23

Роджер Джек

Рис.14. CTTDemoDlg

// TTDemoDlg.h : header file /////////////////////////////////////////////////////////////////////////////

// CTTDemoDlg dialog

#include "TitleTipListBox.h"

#include "ODListBox.h"

class CTTDemoDlg : public CDialog { // Construction public:

 CTTDemoDlg(CWnd* pParent = NULL); // standard constructor

// Dialog Data

 //{{AFX_DATA(CTTDemoDlg)

 enum { IDD = IDD_TTDEMO_DIALOG };

 // NOTE: the ClassWizard will add data members here

 //}}AFX_DATA

 // ClassWizard generated virtual function overrides

 //{{AFX_VIRTUAL(CTTDemoDlg)

protected:

 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support

 //}}AFX_VIRTUAL

 // Implementation

protected:

 HICON m_hIcon;

 CTitleTipListBox m_RegListBox; // Обычный список

 CODListBox m_ODListBox; // Список с пользовательской отрисовкой

 // Generated message map functions

 //{{AFX_MSG(CTTDemoDlg)

 virtual BOOL OnInitDialog();

 afx_msg void OnPaint();

 afx_msg HCURSOR OnQueryDragIcon();

 //}}AFX_MSG

 DECLARE_MESSAGE_MAP()

};

// TTDemoDlg.cpp : implementation file

#include "stdafx.h"

#include "TTDemo.h"

#include "TTDemoDlg.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

// CTTDemoDlg dialog

CTTDemoDlg::CTTDemoDlg(CWnd* pParent /*=NULL*/) : CDialog(CTTDemoDlg::IDD, pParent) {

 //{{AFX_DATA_INIT(CTTDemoDlg)

 // NOTE: the ClassWizard will add member initialization here

 //}}AFX_DATA_INIT

 // Note that LoadIcon does not require a subsequent DestroyIcon in Win32

 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

}

void CTTDemoDlg::DoDataExchange(CDataExchange* pDX) {

 CDialog::DoDataExchange(pDX);

 //{{AFX_DATA_MAP(CTTDemoDlg)

 // NOTE: the ClassWizard will add DDX and DDV calls here

 //}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(CTTDemoDlg, CDialog)

 //{{AFX_MSG_MAP(CTTDemoDlg)

 ON_WM_PAINT()

 ON_WM_QUERYDRAGICON()

 //}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

// CTTDemoDlg message handlers

BOOL CTTDemoDlg::OnInitDialog() {

 CDialog::OnInitDialog();

 // Set the icon for this dialog. The framework does this automatically

 // when the application's main window is not a dialog

 SetIcon(m_hIcon, TRUE); // Set big icon

 SetIcon(m_hIcon, FALSE); // Set small icon

 // Сабклассинг обычного элемента "список"

 HWND hwndRegListBox = ::GetDlgItem(GetSafeHwnd(), IDC_REGLISTBOX);

 ASSERT(hwndRegListBox);

 VERIFY(m_RegListBox.SubclassWindow(hwndRegListBox));

 // Сабклассинг списка с пользовательской отрисовкой

 HWND hwndODListBox = ::GetDlgItem(GetSafeHwnd(), IDC_ODLISTBOX);

 ASSERT(hwndODListBox);

 VERIFY(m_ODListBox.SubclassWindow(hwndODListBox));

 // Заполнение обоих списков строками

 static char* pszItemArray[] = {

  "The C++ Programming Language",

  "C++ Primer",

  "OLE Controls Inside Out",