Исчерпывающее руководство по написанию всплывающих подсказок | страница 26
> //{{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",
> "Inside OLE 2nd Edition",
> "Inside ODBC",
> "Code Complete",
> "Rapid Software Development",
> "The Design Of Everyday Things",
> "Object-Oriented Analysis And Design",
> "MFC Internals",
> "Animation Techniques In Win32",
> "Inside Visual C++",
> "Writing Solid Code",
> "Learn Java Now"
> };
> static int nItemArrayCount = sizeof(pszItemArray) / sizeof(pszItemArray[0]);
> for (int n = 0; n < nItemArrayCount; n++) {
> VERIFY(m_RegListBox.AddString(pszItemArray[n]) != LB_ERR);
> VERIFY(m_ODListBox.AddString(pszItemArray[n]) != LB_ERR);
> }
> return TRUE; // return TRUE unless you set the focus to a control
>}
>// If you add a minimize button to your dialog, you will need the code below
>// to draw the icon. For MFC applications using the document/view model,
>// this is automatically done for you by the framework.
>void CTTDemoDlg::OnPaint() {
> if (IsIconic()) {
> CPaintDC dc(this); // device context for painting
> SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);