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.

143 lines
3.7 KiB

  1. #ifndef __PRINT_CONFIG_PAGE_H_
  2. #define __PRINT_CONFIG_PAGE_H_
  3. #include "resource.h"
  4. //#include <atlsnap.h>
  5. #include "..\..\inc\atlsnap.h"
  6. #include <atlapp.h>
  7. #include <atlctrls.h>
  8. #include <faxmmc.h>
  9. #include <faxutil.h>
  10. #include <fxsapip.h>
  11. #include <RoutingMethodConfig.h>
  12. class CPrintConfigPage : public CSnapInPropertyPageImpl<CPrintConfigPage>
  13. {
  14. public :
  15. CPrintConfigPage(LONG_PTR lNotifyHandle, bool bDeleteHandle = false, TCHAR* pTitle = NULL ) :
  16. m_lNotifyHandle(lNotifyHandle),
  17. m_bDeleteHandle(bDeleteHandle), // Should be true for only page.
  18. m_pPrinterNames(NULL),
  19. m_hFax(NULL),
  20. m_fIsDialogInitiated(FALSE),
  21. m_fIsDirty(FALSE),
  22. m_dwNumOfPrinters(0)
  23. {}
  24. HRESULT Init(LPCTSTR lpctstrServerName, DWORD dwDeviceId);
  25. ~CPrintConfigPage()
  26. {
  27. DEBUG_FUNCTION_NAME(TEXT("CPrintConfigPage::~CPrintConfigPage"));
  28. if (m_pPrinterNames)
  29. {
  30. ReleasePrinterNames (m_pPrinterNames, m_dwNumOfPrinters);
  31. }
  32. if (m_hFax)
  33. {
  34. if (!FaxClose(m_hFax))
  35. {
  36. DWORD ec = GetLastError();
  37. DebugPrintEx(
  38. DEBUG_ERR,
  39. TEXT("FaxClose() failed on fax handle (0x%08X : %s). (ec: %ld)"),
  40. m_hFax,
  41. m_bstrServerName,
  42. ec);
  43. }
  44. m_hFax = NULL;
  45. }
  46. if (m_bDeleteHandle)
  47. {
  48. MMCFreeNotifyHandle(m_lNotifyHandle);
  49. }
  50. }
  51. enum { IDD = IDD_PRINT };
  52. BEGIN_MSG_MAP(CPrintConfigPage)
  53. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog )
  54. MESSAGE_HANDLER(WM_CONTEXTMENU, OnHelpRequest)
  55. MESSAGE_HANDLER(WM_HELP, OnHelpRequest)
  56. CHAIN_MSG_MAP(CSnapInPropertyPageImpl<CPrintConfigPage>)
  57. COMMAND_HANDLER(IDC_PRINTERS_COMBO, CBN_SELCHANGE, OnComboChanged)
  58. COMMAND_HANDLER(IDC_PRINTERS_COMBO, CBN_EDITCHANGE,OnComboChanged)
  59. END_MSG_MAP()
  60. HRESULT PropertyChangeNotify(long param)
  61. {
  62. return MMCPropertyChangeNotify(m_lNotifyHandle, param);
  63. }
  64. BOOL OnApply();
  65. LRESULT OnFieldChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  66. {
  67. if (!m_fIsDialogInitiated) //event receieved in too early stage
  68. {
  69. return 0;
  70. }
  71. else
  72. {
  73. m_fIsDirty = TRUE;
  74. SetModified(TRUE);
  75. return 0;
  76. }
  77. }
  78. LRESULT OnInitDialog(
  79. UINT uiMsg,
  80. WPARAM wParam,
  81. LPARAM lParam,
  82. BOOL& fHandled );
  83. LRESULT OnComboChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  84. LRESULT OnHelpRequest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  85. public:
  86. LONG_PTR m_lNotifyHandle;
  87. bool m_bDeleteHandle;
  88. private:
  89. HANDLE m_hFax; // Handle to fax server connection
  90. CComBSTR m_bstrServerName;
  91. DWORD m_dwDeviceId;
  92. CComBSTR m_bstrPrinter;
  93. DWORD m_dwNumOfPrinters;
  94. PPRINTER_NAMES m_pPrinterNames;
  95. //
  96. // Controls
  97. //
  98. CComboBox m_PrintersCombo;
  99. BOOL m_fIsDialogInitiated;
  100. BOOL m_fIsDirty;
  101. };
  102. HRESULT
  103. SetComboBoxItem (CComboBox combo,
  104. DWORD comboBoxIndex,
  105. LPCTSTR lpctstrFieldText,
  106. DWORD dwItemData,
  107. HINSTANCE hInst = NULL);
  108. HRESULT
  109. AddComboBoxItem (CComboBox combo,
  110. LPCTSTR lpctstrFieldText,
  111. DWORD dwItemData,
  112. HINSTANCE hInst = NULL);
  113. HRESULT
  114. SelectComboBoxItemData (CComboBox combo, DWORD_PTR dwItemData);
  115. #endif