TestTPWDlg.cpp
上传用户:cuiyan8037
上传日期:2007-01-01
资源大小:215k
文件大小:3k
源码类别:
ListView/ListBox
开发平台:
Visual C++
- // TestTPWDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "TitledPicsWndTest.h"
- #include "TitledPicsWnd.h"
- #include "TestTPWDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CTestTPWDlg dialog
- CTestTPWDlg::CTestTPWDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CTestTPWDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CTestTPWDlg)
- m_strMouseEvents = _T("");
- m_strSelectionChange = _T("");
- //}}AFX_DATA_INIT
- }
- void CTestTPWDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CTestTPWDlg)
- DDX_Control(pDX, ID_PIC_FRAME, m_picFrame);
- DDX_Text(pDX, ID_LBL_MOUSEEVENTS, m_strMouseEvents);
- DDX_Text(pDX, ID_LBL_SELCHANGE, m_strSelectionChange);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CTestTPWDlg, CDialog)
- //{{AFX_MSG_MAP(CTestTPWDlg)
- ON_CONTROL(TPWN_SELCHANGE, ID_WND_PICLIST, OnSelChange)
- ON_CONTROL(TPWN_CLICK, ID_WND_PICLIST, OnClick)
- ON_CONTROL(TPWN_RCLICK, ID_WND_PICLIST, OnRClick)
- ON_CONTROL(TPWN_DBLCLK, ID_WND_PICLIST, OnDblClk)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CTestTPWDlg message handlers
- BOOL CTestTPWDlg::OnInitDialog()
- {
- CRect rctWindow ;
- CString strTemp ;
- HBITMAP hBmp ;
- HINSTANCE hInst ;
- int n ;
- CDialog::OnInitDialog();
- // Load file bitmaps.
- hInst = AfxGetInstanceHandle();
- for (n = 0 ; n < 9 ; n++)
- {
- strTemp.Format("BMP%d.BMP", n + 1);
- hBmp = (HBITMAP)LoadImage(hInst,(LPCTSTR)strTemp, IMAGE_BITMAP, 0, 0,
- LR_LOADFROMFILE);
- m_bmpPics[n].Attach(hBmp);
- }
- // Work out where to position the window.
- m_picFrame.GetWindowRect(&rctWindow);
- ScreenToClient(&rctWindow);
- m_pWndPicList = new CTitledPicsWnd ;
- m_pWndPicList->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, rctWindow, this,
- ID_WND_PICLIST);
- m_pWndPicList->StretchBitmaps();
- m_pWndPicList->SetSectionSize(84, 150);
- // Add the file bitmaps.
- for (n = 0 ; n < 9 ; n++)
- {
- strTemp.Format("Bitmap Number %d", n + 1);
- m_pWndPicList->Add(&m_bmpPics[n], strTemp);
- }
- // Add the resource bitmap.
- m_pWndPicList->Add(ID_BMP10,"Bitmap number 10");
- m_pWndPicList->SetSel(3);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CTestTPWDlg::OnSelChange(void)
- {
- int iIndex ;
- iIndex = m_pWndPicList->GetSel();
- m_strSelectionChange.Format("Selected item is now %d", iIndex);
- UpdateData(FALSE);
- }
- void CTestTPWDlg::OnClick(void)
- {
- m_strMouseEvents = "Item was left-clicked";
- UpdateData(FALSE);
- }
- void CTestTPWDlg::OnRClick(void)
- {
- m_strMouseEvents = "Item was right-clicked";
- UpdateData(FALSE);
- }
- void CTestTPWDlg::OnDblClk(void)
- {
- m_strMouseEvents = "Item was double-clicked";
- UpdateData(FALSE);
- }