DrvListBoxDlg.cpp
上传用户:davidcaozc
上传日期:2007-01-01
资源大小:13k
文件大小:3k
- // DrvListBoxDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "resource.h"
- #include "DrvListBox.h"
- #include "DrvListBoxDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDrvListBoxDlg dialog
- CDrvListBoxDlg::CDrvListBoxDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CDrvListBoxDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDrvListBoxDlg)
- // 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 CDrvListBoxDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDrvListBoxDlg)
- DDX_Control(pDX, IDC_COMBOBOXEXS, m_DrvListBoxS);
- DDX_Control(pDX, IDC_COMBOBOXEXL, m_DrvListBoxL);
- //}}AFX_DATA_MAP
- // pick up selected root path
- if( pDX->m_bSaveAndValidate )
- {
- int s;
- s = m_DrvListBoxS.GetCurSel();
- if( s != CB_ERR )
- m_DrvListBoxSResult = ( const char * )m_DrvListBoxS.GetItemDataPtr( m_DrvListBoxS.GetCurSel());
- s = m_DrvListBoxL.GetCurSel();
- if( s != CB_ERR )
- m_DrvListBoxLResult = ( const char * )m_DrvListBoxS.GetItemDataPtr( m_DrvListBoxL.GetCurSel());
- }
- }
- BEGIN_MESSAGE_MAP(CDrvListBoxDlg, CDialog)
- //{{AFX_MSG_MAP(CDrvListBoxDlg)
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDrvListBoxDlg message handlers
- BOOL CDrvListBoxDlg::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
-
- VERIFY( m_DrvListBoxS.LoadItems( false ) >= 0 );
- VERIFY( m_DrvListBoxL.LoadItems( true ) >= 0 );
-
- 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 CDrvListBoxDlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
- // The system calls this to obtain the cursor to display while the user drags
- // the minimized window.
- HCURSOR CDrvListBoxDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }