home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / dpdlg / dirpickd.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-12  |  3.9 KB  |  139 lines

  1. // DirPickDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "DirPick.h"
  6. #include "DirPickDlg.h"
  7. #include "picture.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CDirPickDlg dialog
  17.  
  18. CDirPickDlg::CDirPickDlg(CWnd* pParent /*=NULL*/)
  19.     : CDialog(CDirPickDlg::IDD, pParent)
  20. {
  21.     //{{AFX_DATA_INIT(CDirPickDlg)
  22.     //}}AFX_DATA_INIT
  23.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  24.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  25. }
  26.  
  27. void CDirPickDlg::DoDataExchange(CDataExchange* pDX)
  28. {
  29.     CDialog::DoDataExchange(pDX);
  30.     //{{AFX_DATA_MAP(CDirPickDlg)
  31.     DDX_Control(pDX, IDC_BFC, m_bfc);
  32.     DDX_Control(pDX, IDC_BFP, m_bfp);
  33.     DDX_Control(pDX, IDC_CAPTION, m_caption);
  34.     DDX_Control(pDX, IDC_DGBD, m_dgbd);
  35.     DDX_Control(pDX, IDC_RFSA, m_rfsa);
  36.     DDX_Control(pDX, IDC_ROFSD, m_rofsd);
  37.     DDX_Control(pDX, IDC_ROOT, m_root);
  38.     DDX_Control(pDX, IDC_FOLDER, m_folder);
  39.     DDX_Control(pDX, IDC_PATH, m_path);
  40.     DDX_Control(pDX, IDC_MYICON, m_icon);
  41.     DDX_Control(pDX, IDC_DPDLG, m_dpdlg);
  42.     //}}AFX_DATA_MAP
  43. }
  44.  
  45. BEGIN_MESSAGE_MAP(CDirPickDlg, CDialog)
  46.     //{{AFX_MSG_MAP(CDirPickDlg)
  47.     ON_WM_PAINT()
  48.     ON_WM_QUERYDRAGICON()
  49.     ON_BN_CLICKED(IDHOWDOI, OnHowdoi)
  50.     //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CDirPickDlg message handlers
  55.  
  56. BOOL CDirPickDlg::OnInitDialog()
  57. {
  58.     CDialog::OnInitDialog();
  59.  
  60.     // Set the icon for this dialog.  The framework does this automatically
  61.     //  when the application's main window is not a dialog
  62.     SetIcon(m_hIcon, TRUE);            // Set big icon
  63.     SetIcon(m_hIcon, FALSE);        // Set small icon
  64.     
  65.     m_caption.SetWindowText(m_dpdlg.GetCaption());
  66.     m_bfc.SetCheck( (m_dpdlg.GetBrowseForComputer()) ? 1 : 0);
  67.     m_bfp.SetCheck( (m_dpdlg.GetBrowseForPrinter()) ? 1 : 0);
  68.     m_dgbd.SetCheck( (m_dpdlg.GetDontGoBelowDomain()) ? 1 : 0);
  69.     m_rfsa.SetCheck( (m_dpdlg.GetReturnFSAncestors()) ? 1 : 0);
  70.     m_rofsd.SetCheck( (m_dpdlg.GetReturnOnlyFSDirs()) ? 1 : 0);
  71.     m_root.SetCurSel(m_dpdlg.GetRoot());
  72.     m_root.SetDroppedWidth(200);
  73.  
  74.     return TRUE;  // return TRUE  unless you set the focus to a control
  75. }
  76.  
  77. // If you add a minimize button to your dialog, you will need the code below
  78. //  to draw the icon.  For MFC applications using the document/view model,
  79. //  this is automatically done for you by the framework.
  80.  
  81. void CDirPickDlg::OnPaint() 
  82. {
  83.     if (IsIconic())
  84.     {
  85.         CPaintDC dc(this); // device context for painting
  86.  
  87.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  88.  
  89.         // Center icon in client rectangle
  90.         int cxIcon = GetSystemMetrics(SM_CXICON);
  91.         int cyIcon = GetSystemMetrics(SM_CYICON);
  92.         CRect rect;
  93.         GetClientRect(&rect);
  94.         int x = (rect.Width() - cxIcon + 1) / 2;
  95.         int y = (rect.Height() - cyIcon + 1) / 2;
  96.  
  97.         // Draw the icon
  98.         dc.DrawIcon(x, y, m_hIcon);
  99.     }
  100.     else
  101.     {
  102.         CDialog::OnPaint();
  103.     }
  104. }
  105.  
  106. // The system calls this to obtain the cursor to display while the user drags
  107. //  the minimized window.
  108. HCURSOR CDirPickDlg::OnQueryDragIcon()
  109. {
  110.     return (HCURSOR) m_hIcon;
  111. }
  112.  
  113. void CDirPickDlg::OnHowdoi() 
  114. {
  115.     CDialog dlg(IDD_DIRPICK_HOWDOI);
  116.     
  117.     dlg.DoModal();
  118. }
  119.  
  120. void CDirPickDlg::OnOK() 
  121. {
  122.     CString caption;
  123.     m_caption.GetWindowText(caption);
  124.     m_dpdlg.SetCaption(caption);
  125.     m_dpdlg.SetBrowseForComputer( (m_bfc.GetCheck() == 1) ? TRUE : FALSE);
  126.     m_dpdlg.SetBrowseForPrinter( (m_bfp.GetCheck() == 1) ? TRUE : FALSE);
  127.     m_dpdlg.SetDontGoBelowDomain( (m_dgbd.GetCheck() == 1) ? TRUE : FALSE);
  128.     m_dpdlg.SetReturnFSAncestors( (m_rfsa.GetCheck() == 1) ? TRUE : FALSE);
  129.     m_dpdlg.SetReturnOnlyFSDirs( (m_rofsd.GetCheck() == 1) ? TRUE : FALSE);
  130.     m_dpdlg.SetRoot(m_root.GetCurSel());
  131.  
  132.     if (m_dpdlg.Show())
  133.     {
  134.         m_folder.SetWindowText(m_dpdlg.GetFolder());
  135.         m_path.SetWindowText(m_dpdlg.GetPath());
  136.         m_icon.SetIcon((HICON) m_dpdlg.GetIcon().GetHandle());
  137.     }
  138. }
  139.