home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / edectl / edgedlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-16  |  3.5 KB  |  149 lines

  1. // EdgeDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Edge.h"
  6. #include "EdgeDlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CEdgeDlg dialog
  16.  
  17. CEdgeDlg::CEdgeDlg(CWnd* pParent /*=NULL*/)
  18.     : CDialog(CEdgeDlg::IDD, pParent)
  19. {
  20.     //{{AFX_DATA_INIT(CEdgeDlg)
  21.     //}}AFX_DATA_INIT
  22.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  23.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  24. }
  25.  
  26. void CEdgeDlg::DoDataExchange(CDataExchange* pDX)
  27. {
  28.     CDialog::DoDataExchange(pDX);
  29.     //{{AFX_DATA_MAP(CEdgeDlg)
  30.     DDX_Control(pDX, IDC_TOP, m_top);
  31.     DDX_Control(pDX, IDC_RIGHT, m_right);
  32.     DDX_Control(pDX, IDC_LEFT, m_left);
  33.     DDX_Control(pDX, IDC_EDGESTYLE, m_edgestyle);
  34.     DDX_Control(pDX, IDC_BOTTOM, m_bottom);
  35.     DDX_Control(pDX, IDC_ECMAIN, m_ecmain);
  36.     //}}AFX_DATA_MAP
  37. }
  38.  
  39. BEGIN_MESSAGE_MAP(CEdgeDlg, CDialog)
  40.     //{{AFX_MSG_MAP(CEdgeDlg)
  41.     ON_WM_PAINT()
  42.     ON_WM_QUERYDRAGICON()
  43.     ON_BN_CLICKED(IDEXAMPLE, OnExample)
  44.     ON_BN_CLICKED(IDHOWDOI, OnHowdoi)
  45.     ON_BN_CLICKED(IDC_BOTTOM, OnBottom)
  46.     ON_BN_CLICKED(IDC_LEFT, OnLeft)
  47.     ON_BN_CLICKED(IDC_RIGHT, OnRight)
  48.     ON_BN_CLICKED(IDC_TOP, OnTop)
  49.     ON_CBN_SELCHANGE(IDC_EDGESTYLE, OnSelchangeEdgestyle)
  50.     //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CEdgeDlg message handlers
  55.  
  56. BOOL CEdgeDlg::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_edgestyle.SetCurSel(1);
  66.     m_bottom.SetCheck(TRUE);
  67.     m_left.SetCheck(TRUE);
  68.     m_right.SetCheck(TRUE);
  69.     m_top.SetCheck(TRUE);
  70.     
  71.     return TRUE;  // return TRUE  unless you set the focus to a control
  72. }
  73.  
  74. // If you add a minimize button to your dialog, you will need the code below
  75. //  to draw the icon.  For MFC applications using the document/view model,
  76. //  this is automatically done for you by the framework.
  77.  
  78. void CEdgeDlg::OnPaint() 
  79. {
  80.     if (IsIconic())
  81.     {
  82.         CPaintDC dc(this); // device context for painting
  83.  
  84.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  85.  
  86.         // Center icon in client rectangle
  87.         int cxIcon = GetSystemMetrics(SM_CXICON);
  88.         int cyIcon = GetSystemMetrics(SM_CYICON);
  89.         CRect rect;
  90.         GetClientRect(&rect);
  91.         int x = (rect.Width() - cxIcon + 1) / 2;
  92.         int y = (rect.Height() - cyIcon + 1) / 2;
  93.  
  94.         // Draw the icon
  95.         dc.DrawIcon(x, y, m_hIcon);
  96.     }
  97.     else
  98.     {
  99.         CDialog::OnPaint();
  100.     }
  101. }
  102.  
  103. // The system calls this to obtain the cursor to display while the user drags
  104. //  the minimized window.
  105. HCURSOR CEdgeDlg::OnQueryDragIcon()
  106. {
  107.     return (HCURSOR) m_hIcon;
  108. }
  109.  
  110. void CEdgeDlg::OnExample() 
  111. {
  112.     CDialog dlg(IDD_EDGE_EXAMPLE);
  113.  
  114.     AfxMessageBox("This example was taken from Word 97", MB_OK | MB_ICONINFORMATION);
  115.  
  116.     dlg.DoModal();
  117. }
  118.  
  119. void CEdgeDlg::OnHowdoi() 
  120. {
  121.     CDialog dlg(IDD_EDGE_HOWDOI);
  122.     dlg.DoModal();
  123. }
  124.  
  125. void CEdgeDlg::OnBottom() 
  126. {
  127.     m_ecmain.SetEdgeBottom(m_bottom.GetCheck());
  128. }
  129.  
  130. void CEdgeDlg::OnLeft() 
  131. {
  132.     m_ecmain.SetEdgeLeft(m_left.GetCheck());    
  133. }
  134.  
  135. void CEdgeDlg::OnRight() 
  136. {
  137.     m_ecmain.SetEdgeRight(m_right.GetCheck());    
  138. }
  139.  
  140. void CEdgeDlg::OnTop() 
  141. {
  142.     m_ecmain.SetEdgeTop(m_top.GetCheck());    
  143. }
  144.  
  145. void CEdgeDlg::OnSelchangeEdgestyle() 
  146. {
  147.     m_ecmain.SetEdgeStyle(m_edgestyle.GetCurSel());    
  148. }
  149.