printnew.h
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 12k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. /*++
  2. Copyright (c) 1990-1998,  Microsoft Corporation  All rights reserved.
  3. Module Name:
  4.     printnew.h
  5. Abstract:
  6.     This module contains the header information for the Win32
  7.     property sheet print common dialogs.
  8. Revision History:
  9.     11-04-97    JulieB    Created.
  10. --*/
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #ifdef WINNT
  15. //
  16. //  Include Files.
  17. //
  18. #include <dlgs.h>
  19. #include <initguid.h>
  20. #include <winprtp.h>
  21. //
  22. //  Constant Declarations.
  23. //
  24. //
  25. //  Dialog Constants.
  26. //
  27. #define IDD_PRINT_GENERAL          100
  28. #define IDD_PRINT_GENERAL_LARGE    101 
  29. #define IDI_COLLATE               ico1
  30. #define IDC_PRINTER_LIST          1000
  31. #define IDC_PRINTER_LISTVIEW      1001
  32. #define IDC_PRINT_TO_FILE         1002
  33. #define IDC_FIND_PRINTER          1003
  34. #define IDC_STATUS_TEXT           1004
  35. #define IDC_STATUS                1005
  36. #define IDC_LOCATION_TEXT         1006
  37. #define IDC_LOCATION              1007
  38. #define IDC_COMMENT_TEXT          1008
  39. #define IDC_COMMENT               1009
  40. #define IDC_RANGE_ALL             rad1
  41. #define IDC_RANGE_SELECTION       rad2
  42. #define IDC_RANGE_CURRENT         rad3
  43. #define IDC_RANGE_PAGES           rad4
  44. #define IDC_RANGE_EDIT            edt1
  45. #define IDC_RANGE_TEXT1           stc1
  46. #define IDC_RANGE_TEXT2           stc2
  47. #define IDC_COPIES                edt2
  48. #define IDC_COPIES_TEXT           stc3
  49. #define IDC_COLLATE               chx1
  50. #define IDC_STATIC                -1
  51. //
  52. //  Typedef Declarations.
  53. //
  54. typedef struct
  55. {
  56.     UINT           ApiType;
  57.     LPPRINTDLGEX   pPD;
  58.     DWORD          ProcessVersion;
  59.     DWORD          dwFlags;
  60.     UINT           FinalResult;
  61.     HRESULT        hResult;
  62.     BOOL           fApply;
  63.     BOOL           fOld;
  64.     DWORD          dwExtendedError;
  65.     HRESULT        hrOleInit;
  66. #ifdef UNICODE
  67.     LPPRINTDLGEXA  pPDA;
  68.     BOOL           fPrintTemplateAlloc;
  69. #endif
  70. } PRINTINFOEX, *PPRINTINFOEX;
  71. //
  72. //  Global Variables.
  73. //
  74. //
  75. //  PrintUI.
  76. //
  77. PF_PRINTDLGSHEETSPROPPAGES PrintUI_bPrintDlgSheetsPropPages = NULL;
  78. HMODULE hPrintUI = NULL;
  79. //
  80. //  Registry keys.
  81. //
  82. static const TCHAR c_szSettings[] = TEXT("Printers\Settings");
  83. static const TCHAR c_szViewMode[] = TEXT("ViewMode");
  84. //
  85. //  CPrintBrowser Class.
  86. //
  87. class CPrintBrowser : public IShellBrowser, 
  88.                       public ICommDlgBrowser2, 
  89.                       public IPrintDialogCallback, 
  90.                       public IPrintDialogServices
  91. {
  92. public:
  93.     // *** IUnknown methods ***
  94.     STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj);
  95.     STDMETHOD_(ULONG, AddRef) (THIS);
  96.     STDMETHOD_(ULONG, Release) (THIS);
  97.     // *** IOleWindow methods ***
  98.     STDMETHOD(GetWindow) (THIS_ HWND *lphwnd);
  99.     STDMETHOD(ContextSensitiveHelp) (THIS_ BOOL fEnterMode);
  100.     // *** IShellBrowser methods *** (same as IOleInPlaceFrame)
  101.     STDMETHOD(InsertMenusSB) (THIS_ HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths);
  102.     STDMETHOD(SetMenuSB) (THIS_ HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject);
  103.     STDMETHOD(RemoveMenusSB) (THIS_ HMENU hmenuShared);
  104.     STDMETHOD(SetStatusTextSB) (THIS_ LPCOLESTR lpszStatusText);
  105.     STDMETHOD(EnableModelessSB) (THIS_ BOOL fEnable);
  106.     STDMETHOD(TranslateAcceleratorSB) (THIS_ LPMSG lpmsg, WORD wID);
  107.     // *** IShellBrowser methods ***
  108.     STDMETHOD(BrowseObject) (THIS_ LPCITEMIDLIST pidl, UINT wFlags);
  109.     STDMETHOD(GetViewStateStream) (THIS_ DWORD grfMode, LPSTREAM *pStrm);
  110.     STDMETHOD(GetControlWindow) (THIS_ UINT id, HWND *lphwnd);
  111.     STDMETHOD(SendControlMsg) (THIS_ UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pret);
  112.     STDMETHOD(QueryActiveShellView) (THIS_ struct IShellView **ppshv);
  113.     STDMETHOD(OnViewWindowActive) (THIS_ struct IShellView *pshv);
  114.     STDMETHOD(SetToolbarItems) (THIS_ LPTBBUTTON lpButtons, UINT nButtons, UINT uFlags);
  115.     // *** ICommDlgBrowser2 methods ***
  116.     STDMETHOD(OnDefaultCommand) (THIS_ struct IShellView *ppshv);
  117.     STDMETHOD(OnStateChange) (THIS_ struct IShellView *ppshv, ULONG uChange);
  118.     STDMETHOD(IncludeObject) (THIS_ struct IShellView *ppshv, LPCITEMIDLIST lpItem);
  119.     STDMETHOD(Notify) (THIS_ struct IShellView *ppshv, DWORD dwNotifyType);
  120.     STDMETHOD(GetDefaultMenuText) (THIS_ struct IShellView *ppshv, WCHAR *pszText, INT cchMax);
  121.     STDMETHOD(GetViewFlags)(THIS_ DWORD *pdwFlags);
  122.     // *** IPrintDialogCallback methods ***
  123.     STDMETHOD(InitDone) (THIS);
  124.     STDMETHOD(SelectionChange) (THIS);
  125.     STDMETHOD(HandleMessage) (THIS_ HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pResult);
  126.     // *** IPrintDialogServices methods ***
  127.     STDMETHOD(GetCurrentDevMode) (THIS_ LPDEVMODE pDevMode, UINT *pcbSize);
  128.     STDMETHOD(GetCurrentPrinterName) (THIS_ LPTSTR pPrinterName, UINT *pcchSize);
  129.     STDMETHOD(GetCurrentPortName) (THIS_ LPTSTR pPortName, UINT *pcchSize);
  130.     // *** Our own methods ***
  131.     CPrintBrowser(HWND hDlg);
  132.     ~CPrintBrowser();
  133.     BOOL    OnInitDialog(WPARAM wParam, LPARAM lParam);
  134.     BOOL    OnChildInitDialog(HWND hDlg, WPARAM wParam, LPARAM lParam);
  135.     VOID    OnDestroyMessage();
  136.     BOOL    OnCommandMessage(WPARAM wParam, LPARAM lParam);
  137.     BOOL    OnChildCommandMessage(WPARAM wParam, LPARAM lParam);
  138.     BOOL    OnNotifyMessage(WPARAM wParam, LPNMHDR lpnmhdr);
  139.     BOOL    OnSelChange();
  140.     BOOL    OnChangeNotify(LONG lNotification, LPCITEMIDLIST *ppidl);
  141.     BOOL    OnAccelerator(HWND hwndActivePrint, HWND hwndFocus, HACCEL haccPrint, PMSG pMsg);
  142.     VOID    OnNoPrinters(HWND hDlg, UINT iId);
  143.     VOID    OnInitDone();
  144. private:
  145.     HRESULT CreatePrintShellView();
  146.     UINT    GetViewMode();
  147.     VOID    SetViewMode();
  148.     HRESULT CreateHookDialog();
  149.     BOOL    UpdateStatus(LPCITEMIDLIST pidl);
  150.     BOOL    SelectSVItem();
  151.     BOOL    GetCurrentPrinter();
  152.     VOID    InitPrintToFile();
  153.     VOID    InitPageRangeGroup();
  154.     VOID    InitCopiesAndCollate();
  155.     BOOL    SaveCopiesAndCollateInDevMode(LPDEVMODE pDM, LPTSTR pszPrinter);
  156.     BOOL    SetCopiesOnApply();
  157.     VOID    SaveDevMode();
  158.     BOOL    MergeDevMode(LPTSTR pszPrinterName);
  159.     BOOL    IsValidPageRange(LPTSTR pszString, UINT *pErrorId);
  160.     BOOL    ConvertPageRangesToString(LPTSTR pszString, UINT cchLen);
  161.     UINT    IntegerToString(DWORD Value, LPTSTR pszString, UINT cchLen);
  162.     VOID    ShowError(HWND hDlg, int Id, UINT MessageId, ...);
  163.     UINT    InsertDevicePage(LPCWSTR pszName, PDEVMODE pDevMode);
  164.     UINT    RemoveDevicePage();
  165.     UINT    RemoveAndInsertDevicePage(LPCWSTR pszName, PDEVMODE pDevMode);
  166.     BOOL    FitViewModeBest(HWND hwndListView);
  167.     VOID    SelectPrinterItem(LPITEMIDLIST pidlItem);
  168.     BOOL    IsCurrentPrinter(LPCITEMIDLIST pidl);
  169.     BOOL    OnRename(LPCITEMIDLIST *ppidl);
  170.     UINT cRef;                         // compobj refcount
  171.     HWND hwndDlg;                      // handle of this dialog
  172.     HWND hSubDlg;                      // handle of the hook dialog
  173.     HWND hwndView;                     // current view window
  174.     HWND hwndUpDown;                   // UpDown Control Window handle;
  175.     IShellView *psv;                   // shell view object
  176.     IShellFolderView *psfv;            // shell folder view object
  177.     IShellFolder *psfRoot;             // print folder shell folder
  178.     IShellDetails *psd;                // shell details object
  179.     LPITEMIDLIST pidlRoot;             // pidl for print folder
  180.     IPrinterFolder *ppf;               // printer folder private interface
  181.     HIMAGELIST himl;                   // system imagelist (small images)
  182.     PPRINTDLG_PAGE pPrintDlgPage;      // ptr to PRINTDLG_PAGE struct (printui)
  183.     PPRINTINFOEX pPI;                  // ptr to PRINTINFOEX struct
  184.     LPPRINTDLGEX pPD;                  // caller's PRINTDLGEX struct
  185.     IPrintDialogCallback *pCallback;   // ptr to app's callback interface
  186.     IObjectWithSite *pSite;            // ptr to app's SetSite interface
  187.     LPDEVMODE pDMInit;                 // ptr to the initial DEVMODE struct
  188.     LPDEVMODE pDMCur;                  // ptr to the current DEVMODE struct
  189.     LPDEVMODE pDMSave;                 // ptr to the last good DEVMODE struct
  190.     UINT cchCurPrinter;                // size, in chars, of pszCurPrinter
  191.     LPTSTR pszCurPrinter;              // ptr to name of current printer
  192.     DWORD nCopies;                     // number of copies
  193.     DWORD nPageRanges;                 // number of page ranges in pPageRange
  194.     DWORD nMaxPageRanges;              // max number of page ranges allowed
  195.     LPPRINTPAGERANGE pPageRanges;      // ptr to an array of page range structs
  196.     BOOL fCollateRequested;            // collate is requested
  197.     BOOL fSelChangePending;            // we have a selchange message pending
  198.     BOOL fFirstSel;                    // still need to set first selection
  199.     BOOL fAPWSelected;                 // add printer wizard is selected
  200.     BOOL fNoAccessPrinterSelected;     // a printer we do not have access to is selected
  201.     BOOL fDirtyDevicePages;            // Are device pages dirty
  202.     UINT nInitDone;                    // number of CDM_INITDONE messages
  203.     UINT nListSep;                     // number of characters in szListSep
  204.     TCHAR szListSep[20];               // list separator
  205.     UINT uRegister;                    // change notify register
  206.     TCHAR szScratch[MAX_PATH * 2];     // scratch buffer
  207.     
  208.     UINT uDefViewMode;                 // How the default view mode is mapped
  209. };
  210. //
  211. //  Context Help IDs.
  212. //
  213. DWORD aPrintExHelpIDs[] =
  214. {
  215.     grp1,                    NO_HELP,
  216.     IDC_PRINTER_LISTVIEW,    IDH_PRINT_PRINTER_FOLDER,
  217.     IDC_STATUS_TEXT,         IDH_PRINT_SETUP_DETAILS,
  218.     IDC_STATUS,              IDH_PRINT_SETUP_DETAILS,
  219.     IDC_LOCATION_TEXT,       IDH_PRINT_SETUP_DETAILS,
  220.     IDC_LOCATION,            IDH_PRINT_SETUP_DETAILS,
  221.     IDC_COMMENT_TEXT,        IDH_PRINT_SETUP_DETAILS,
  222.     IDC_COMMENT,             IDH_PRINT_SETUP_DETAILS,
  223.     IDC_PRINT_TO_FILE,       IDH_PRINT_TO_FILE,
  224.     IDC_FIND_PRINTER,        IDH_PRINT_FIND_PRINTER,
  225.     grp2,                    NO_HELP,
  226.     IDOK,                    IDH_PRINT_BTN,
  227.     0, 0
  228. };
  229. DWORD aPrintExChildHelpIDs[] =
  230. {
  231.     grp1,                    NO_HELP,
  232.     IDC_RANGE_ALL,           IDH_PRINT32_RANGE,
  233.     IDC_RANGE_SELECTION,     IDH_PRINT32_RANGE,
  234.     IDC_RANGE_CURRENT,       IDH_PRINT32_RANGE,
  235.     IDC_RANGE_PAGES,         IDH_PRINT32_RANGE,
  236.     IDC_RANGE_EDIT,          IDH_PRINT32_RANGE,
  237.     IDC_RANGE_TEXT1,         IDH_PRINT32_RANGE,
  238.     IDC_RANGE_TEXT2,         IDH_PRINT32_RANGE,
  239.     grp2,                    NO_HELP,
  240.     IDC_COPIES,              IDH_PRINT_COPIES,
  241.     IDC_COPIES_TEXT,         IDH_PRINT_COPIES,
  242.     IDC_COLLATE,             IDH_PRINT_COLLATE,
  243.     IDI_COLLATE,             IDH_PRINT_COLLATE,
  244.     0, 0
  245. };
  246. //
  247. //  Function Prototypes.
  248. //
  249. HRESULT
  250. PrintDlgExX(
  251.     PPRINTINFOEX pPI);
  252. HRESULT
  253. Print_ReturnDefault(
  254.     PPRINTINFOEX pPI);
  255. BOOL
  256. Print_LoadLibraries();
  257. VOID
  258. Print_UnloadLibraries();
  259. BOOL
  260. Print_LoadIcons();
  261. BOOL
  262. Print_InvokePropertySheets(
  263.     PPRINTINFOEX pPI,
  264.     LPPRINTDLGEX pPD);
  265. BOOL_PTR
  266. Print_GeneralDlgProc(
  267.     HWND hDlg,
  268.     UINT uMsg,
  269.     WPARAM wParam,
  270.     LPARAM lParam);
  271. BOOL_PTR
  272. Print_GeneralChildDlgProc(
  273.     HWND hDlg,
  274.     UINT uMsg,
  275.     WPARAM wParam,
  276.     LPARAM lParam);
  277. LRESULT
  278. Print_MessageHookProc(
  279.     int nCode,
  280.     WPARAM wParam,
  281.     LPARAM lParam);
  282. BOOL
  283. Print_InitDialog(
  284.     HWND hDlg,
  285.     WPARAM wParam,
  286.     LPARAM lParam);
  287. HRESULT
  288. Print_ICoCreateInstance(
  289.     REFCLSID rclsid,
  290.     REFIID riid,
  291.     LPVOID *ppv);
  292. BOOL
  293. Print_SaveDevNames(
  294.     LPTSTR pCurPrinter,
  295.     LPPRINTDLGEX pPD);
  296. VOID
  297. Print_GetPortName(
  298.     LPTSTR pCurPrinter,
  299.     LPTSTR pBuffer,
  300.     int cchBuffer);
  301. HANDLE
  302. Print_GetDevModeWrapper(
  303.     LPTSTR pszDeviceName,
  304.     HANDLE hDevMode);
  305. BOOL
  306. Print_NewPrintDlg(
  307.     PPRINTINFO pPI);
  308. #ifdef UNICODE
  309.   HRESULT
  310.   ThunkPrintDlgEx(
  311.       PPRINTINFOEX pPI,
  312.       LPPRINTDLGEXA pPDA);
  313.   VOID
  314.   FreeThunkPrintDlgEx(
  315.       PPRINTINFOEX pPI);
  316.   VOID
  317.   ThunkPrintDlgExA2W(
  318.       PPRINTINFOEX pPI);
  319.   VOID
  320.   ThunkPrintDlgExW2A(
  321.       PPRINTINFOEX pPI);
  322. #endif
  323. #endif   // WINNT
  324. #ifdef __cplusplus
  325. };  // extern "C"
  326. #endif