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.

155 lines
3.8 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. WBEMDLG.H
  5. Abstract:
  6. History:
  7. --*/
  8. #ifndef __WBEMTEST_DIALOG__H_
  9. #define __WBEMTEST_DIALOG__H_
  10. #include <windows.h>
  11. class CRefCountable
  12. {
  13. protected:
  14. long m_lRefCount;
  15. public:
  16. virtual long AddRef() {return ++m_lRefCount;}
  17. virtual long Release() {return --m_lRefCount;}
  18. };
  19. class CBasicWbemDialog : public CRefCountable
  20. {
  21. protected:
  22. HWND m_hDlg;
  23. HWND m_hParent;
  24. BOOL m_bDeleteOnClose;
  25. BOOL m_bModal;
  26. CRefCountable* m_pOwner;
  27. static HWND ms_hCurrentModeless;
  28. public:
  29. CBasicWbemDialog(HWND hParent = NULL);
  30. virtual ~CBasicWbemDialog();
  31. void SetDeleteOnClose() { m_bDeleteOnClose = TRUE;}
  32. void SetOwner(CRefCountable* pOwner);
  33. public:
  34. HWND GetHWND() {return m_hDlg;}
  35. BOOL EndDialog(int nResult);
  36. HWND GetDlgItem(int nID) {return ::GetDlgItem(m_hDlg, nID);}
  37. WORD GetCheck(int nID);
  38. void SetCheck(int nID, WORD wCheck);
  39. UINT GetDlgItemTextX(int nDlgItem, LPWSTR pStr, int nMaxCount);
  40. BOOL SetDlgItemText(int nID, LPSTR szStr)
  41. {return ::SetDlgItemText(m_hDlg, nID, szStr);}
  42. BOOL SetDlgItemText(int nID, UINT uTextId);
  43. BOOL SetDlgItemTextX(int nDlgItem, LPWSTR pStr);
  44. void AddStringToCombo(int nID, LPSTR szString, DWORD dwItemData=CB_ERR);
  45. void SetComboSelection (int nID, DWORD dwItemData);
  46. void AddStringToList(int nID, LPSTR szString);
  47. LRESULT GetLBCurSel(int nID);
  48. LPSTR GetLBCurSelString(int nID);
  49. LRESULT GetCBCurSel(int nID);
  50. LPSTR GetCBCurSelString(int nID);
  51. void CenterOnParent();
  52. BOOL PostUserMessage(HWND hWnd, WPARAM wParam, LPARAM lParam);
  53. int MessageBox(UINT uTextId, UINT uCaptionId, UINT uType);
  54. static int MessageBox(HWND hDlg, UINT uTextId, UINT uCaptionId, UINT uType);
  55. static BOOL IsDialogMessage(MSG* pmsg);
  56. static void EnableAllWindows(BOOL bEnable);
  57. protected:
  58. virtual INT_PTR CALLBACK DlgProc(
  59. HWND hDlg,
  60. UINT uMsg,
  61. WPARAM wParam,
  62. LPARAM lParam
  63. );
  64. virtual BOOL OnInitDialog() {return TRUE;}
  65. virtual BOOL OnCommand(WORD wNotifyCode, WORD wID) {return TRUE;}
  66. virtual BOOL OnUser(WPARAM wParam, LPARAM lParam)
  67. {return TRUE;}
  68. virtual BOOL OnOK();
  69. virtual BOOL OnCancel();
  70. virtual BOOL OnDoubleClick(int nID) {return TRUE;}
  71. virtual BOOL OnSelChange(int nID) {return TRUE;}
  72. virtual BOOL Verify() {return TRUE;}
  73. protected:
  74. static INT_PTR CALLBACK staticDlgProc(
  75. HWND hDlg,
  76. UINT uMsg,
  77. WPARAM wParam,
  78. LPARAM lParam
  79. );
  80. LRESULT MessageLoop();
  81. };
  82. class CWbemDialog : public CBasicWbemDialog
  83. {
  84. public:
  85. int m_ID;
  86. CWbemDialog(int tID, HWND hParent = NULL) : CBasicWbemDialog(hParent), m_ID(tID) {}
  87. virtual ~CWbemDialog(){}
  88. BOOL Create(BOOL bChild = TRUE);
  89. INT_PTR Run(HWND hParent = NULL, bool bPopup = false);
  90. };
  91. inline BOOL CWbemDialog::Create(BOOL bChild)
  92. {
  93. m_bModal = FALSE;
  94. m_hDlg = CreateDialogParam(GetModuleHandle(NULL),
  95. MAKEINTRESOURCE(m_ID),
  96. (bChild?m_hParent:NULL), &staticDlgProc,
  97. (LPARAM)(CBasicWbemDialog*)this);
  98. ShowWindow(m_hDlg, SW_NORMAL);
  99. return (m_hDlg != NULL);
  100. }
  101. inline INT_PTR CWbemDialog::Run(HWND hParent, bool bPopup)
  102. {
  103. if(hParent != NULL)
  104. m_hParent = hParent;
  105. //Create(TRUE);
  106. m_bModal = TRUE;
  107. HWND hCurrentFocus = GetFocus();
  108. if(!bPopup)
  109. EnableAllWindows(FALSE);
  110. INT_PTR ptr = DialogBoxParam(GetModuleHandle(NULL),
  111. MAKEINTRESOURCE(m_ID), m_hParent, &staticDlgProc,
  112. (LPARAM)(CBasicWbemDialog*)this);
  113. if(!bPopup)
  114. EnableAllWindows(TRUE);
  115. SetFocus(hCurrentFocus);
  116. return ptr;
  117. }
  118. #endif