Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Abstract:
  4. @doc
  5. @module GenDlg.cpp | Implementation of the generic dialog
  6. @end
  7. Author:
  8. Adi Oltean [aoltean] 07/22/1999
  9. Revision History:
  10. Name Date Comments
  11. aoltean 07/22/1999 Created
  12. --*/
  13. /////////////////////////////////////////////////////////////////////////////
  14. // Includes
  15. #include "stdafx.hxx"
  16. #include "resource.h"
  17. #include "AboutDlg.h"
  18. #include "GenDlg.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CVssTestGenericDlg dialog
  26. CVssTestGenericDlg::CVssTestGenericDlg(UINT nIDTemplate, CWnd* pParent /*=NULL*/)
  27. : CDialog(nIDTemplate, pParent)
  28. {
  29. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  30. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  31. }
  32. CVssTestGenericDlg::~CVssTestGenericDlg()
  33. {
  34. }
  35. void CVssTestGenericDlg::DoDataExchange(CDataExchange* pDX)
  36. {
  37. CDialog::DoDataExchange(pDX);
  38. //{{AFX_DATA_MAP(CVssTestGenericDlg)
  39. //}}AFX_DATA_MAP
  40. }
  41. BEGIN_MESSAGE_MAP(CVssTestGenericDlg, CDialog)
  42. //{{AFX_MSG_MAP(CVssTestGenericDlg)
  43. ON_WM_SYSCOMMAND()
  44. ON_WM_PAINT()
  45. ON_WM_QUERYDRAGICON()
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CVssTestGenericDlg message handlers
  50. BOOL CVssTestGenericDlg::OnInitDialog()
  51. {
  52. /*
  53. CVssFunctionTracer ft( VSSDBG_VSSTEST, L"CVssTestGenericDlg::OnInitDialog" );
  54. USES_CONVERSION;
  55. try
  56. {
  57. */
  58. CDialog::OnInitDialog();
  59. // Add "About..." menu item to system menu.
  60. // IDM_ABOUTBOX must be in the system command range.
  61. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  62. ASSERT(IDM_ABOUTBOX < 0xF000);
  63. CMenu* pSysMenu = GetSystemMenu(FALSE);
  64. if (pSysMenu != NULL)
  65. {
  66. CString strAboutMenu;
  67. strAboutMenu.LoadString(IDS_ABOUTBOX);
  68. if (!strAboutMenu.IsEmpty())
  69. {
  70. pSysMenu->AppendMenu(MF_SEPARATOR);
  71. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  72. }
  73. }
  74. // Set the icon for this dialog. The framework does this automatically
  75. // when the application's main window is not a dialog
  76. SetIcon(m_hIcon, TRUE); // Set big icon
  77. SetIcon(m_hIcon, FALSE); // Set small icon
  78. /*
  79. }
  80. VSS_STANDARD_CATCH(ft)
  81. */
  82. return TRUE; // Return TRUE unless you set the focus to a control.
  83. // Anyway it does not matter because derived classes ignore it.
  84. }
  85. void CVssTestGenericDlg::OnSysCommand(UINT nID, LPARAM lParam)
  86. {
  87. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  88. {
  89. CAboutDlg dlgAbout;
  90. dlgAbout.DoModal();
  91. }
  92. else
  93. {
  94. CDialog::OnSysCommand(nID, lParam);
  95. }
  96. }
  97. // If you add a minimize button to your dialog, you will need the code below
  98. // to draw the icon. For MFC applications using the document/view model,
  99. // this is automatically done for you by the framework.
  100. void CVssTestGenericDlg::OnPaint()
  101. {
  102. if (IsIconic())
  103. {
  104. CPaintDC dc(this); // device context for painting
  105. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  106. // Center icon in client rectangle
  107. int cxIcon = GetSystemMetrics(SM_CXICON);
  108. int cyIcon = GetSystemMetrics(SM_CYICON);
  109. CRect rect;
  110. GetClientRect(&rect);
  111. int x = (rect.Width() - cxIcon + 1) / 2;
  112. int y = (rect.Height() - cyIcon + 1) / 2;
  113. // Draw the icon
  114. dc.DrawIcon(x, y, m_hIcon);
  115. }
  116. else
  117. {
  118. CDialog::OnPaint();
  119. }
  120. }
  121. // The system calls this to obtain the cursor to display while the user drags
  122. // the minimized window.
  123. HCURSOR CVssTestGenericDlg::OnQueryDragIcon()
  124. {
  125. return (HCURSOR) m_hIcon;
  126. }