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.

226 lines
6.3 KiB

  1. /*
  2. * DATAUSER.H
  3. * Data Object User Chapter 6
  4. *
  5. * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  6. *
  7. * Kraig Brockschmidt, Software Design Engineer
  8. * Microsoft Systems Developer Relations
  9. *
  10. * Internet : kraigb@microsoft.com
  11. * Compuserve: >INTERNET:kraigb@microsoft.com
  12. */
  13. #ifndef _DATAUSER_H_
  14. #define _DATAUSER_H_
  15. #include "../syshead.h"
  16. #include "../my3216.h"
  17. #include "../bookpart.h"
  18. #include "stpwatch.h"
  19. //Menu Resource ID and Commands
  20. #define IDR_MENU 1
  21. // #define IDM_OBJECTUSEDLL 100
  22. // #define IDM_OBJECTUSEEXE 101
  23. // #define IDM_OBJECTDATASIZESMALL 102
  24. // #define IDM_OBJECTDATASIZEMEDIUM 103
  25. // #define IDM_OBJECTDATASIZELARGE 104
  26. #define IDM_OBJECTQUERYGETDATA 105
  27. #define IDM_OBJECTGETDATA_TEXT 106
  28. #define IDM_OBJECTGETDATA_BITMAP 107
  29. // #define IDM_OBJECTGETDATA_METAFILEPICT 108
  30. #define IDM_OBJECTEXIT 109
  31. #define IDM_OBJECTGETDATAHERE_TEXT 110
  32. #define IDM_OBJECTGETDATAHERE_BITMAP 111
  33. #define IDM_OBJECTGETDATAHERE_NULLTEXT 112
  34. #define IDM_OBJECTGETDATAHERE_NULLBITMAP 113
  35. #define IDM_USE16BITSERVER 120
  36. #define IDM_USE32BITSERVER 121
  37. #define IDM_OBJECTGETCANON 122
  38. // Reserve Range..
  39. #define IDM_OBJECTSETDATA 400
  40. // ....
  41. // reserved through 464
  42. #define IDM_OBJECTSETDATAPUNK_TEXT 500
  43. #define IDM_OBJECTSETDATAPUNK_BITMAP 501
  44. #define IDM_MEASUREMENT_1 140
  45. #define IDM_MEASUREMENT_50 141
  46. #define IDM_MEASUREMENT_300 142
  47. #define IDM_MEASUREMENT_OFF 145
  48. #define IDM_MEASUREMENT_ON 146
  49. #define IDM_MEASUREMENT_TEST 147
  50. #define IDM_BATCHTOFILE 150
  51. #define IDM_BATCH_GETDATA 151
  52. #define IDM_BATCH_GETDATAHERE 152
  53. // #define IDM_ADVISEMIN 200
  54. // #define IDM_ADVISETEXT (IDM_ADVISEMIN+CF_TEXT)
  55. // #define IDM_ADVISEBITMAP (IDM_ADVISEMIN+CF_BITMAP)
  56. // #define IDM_ADVISEMETAFILEPICT (IDM_ADVISEMIN+CF_METAFILEPICT)
  57. // #define IDM_ADVISEGETDATA 300
  58. // #define IDM_ADVISEREPAINT 301
  59. #ifdef WIN32
  60. #define API_ENTRY APIENTRY
  61. #else
  62. #define API_ENTRY FAR PASCAL _export
  63. #endif
  64. //DATAUSER.CPP
  65. LRESULT API_ENTRY DataUserWndProc(HWND, UINT, WPARAM, LPARAM);
  66. class CImpIAdviseSink;
  67. typedef class CImpIAdviseSink *PIMPIADVISESINK;
  68. #define FILENAME "time.dat"
  69. #define NUM_POINTS 15
  70. typedef struct {
  71. ULONG cData[NUM_POINTS];
  72. ULONG cBest[NUM_POINTS];
  73. ULONG cWorst[NUM_POINTS];
  74. ULONG cTotal[NUM_POINTS];
  75. } dataset_t;
  76. /*
  77. * Application-defined classes and types.
  78. */
  79. class CAppVars
  80. {
  81. friend LRESULT API_ENTRY DataUserWndProc(HWND, UINT, WPARAM, LPARAM);
  82. friend class CImpIAdviseSink;
  83. protected:
  84. HINSTANCE m_hInst; //WinMain parameters
  85. HINSTANCE m_hInstPrev;
  86. UINT m_nCmdShow;
  87. HWND m_hWnd; //Main window handle
  88. // BOOL m_fEXE; //For tracking menu
  89. // PIMPIADVISESINK m_pIAdviseSink; //Our CImpIAdviseSink
  90. // DWORD m_dwConn; //Advise connection
  91. // UINT m_cfAdvise; //Advise format
  92. // BOOL m_fGetData; //GetData on data change?
  93. // BOOL m_fRepaint; //Repaint on data change?
  94. // LPDATAOBJECT m_pIDataSmall;
  95. // LPDATAOBJECT m_pIDataMedium;
  96. // LPDATAOBJECT m_pIDataLarge;
  97. LPDATAOBJECT m_pIDataObject; //Current selection
  98. UINT m_f16Bit;
  99. UINT m_cfFormat;
  100. STGMEDIUM m_stm; //Current rendering
  101. BOOL m_fInitialized; //Did CoInitialize work?
  102. ULONG m_iDataSizeIndex;
  103. HGLOBAL m_hgHereBuffers[64];
  104. BOOL m_fDisplayTime;
  105. LONG m_cIterations;
  106. StopWatch_cl m_swTimer;
  107. int m_HereAllocCount; // For debugging.
  108. public:
  109. CAppVars(HINSTANCE, HINSTANCE, UINT);
  110. ~CAppVars(void);
  111. BOOL FInit(void);
  112. BOOL FReloadDataObjects(BOOL);
  113. void TryQueryGetData(LPFORMATETC, UINT, BOOL, UINT);
  114. void Paint(void);
  115. int m_GetDataHere(WORD wID);
  116. int m_GetData(WORD wID);
  117. int m_SetData_SetSize(long iSizeIndex);
  118. int m_SetData_WithPUnk(WORD wID);
  119. void m_SetMeasurement(WORD wID);
  120. void m_MeasureAllSizes(WORD wID, LPTSTR title, dataset_t *);
  121. void m_BatchToFile();
  122. void m_DisplayTimerResults();
  123. private:
  124. void pm_DrawText(HDC hDc, LPTSTR psz, RECT* prc, UINT flags);
  125. void pm_ClearDataset(dataset_t *);
  126. };
  127. typedef CAppVars *PAPPVARS;
  128. #define CBWNDEXTRA sizeof(PAPPVARS)
  129. #define DATAUSERWL_STRUCTURE 0
  130. //This lives with the app to get OnDataChange notifications.
  131. class CImpIAdviseSink : public IAdviseSink
  132. {
  133. protected:
  134. ULONG m_cRef;
  135. PAPPVARS m_pAV;
  136. public:
  137. CImpIAdviseSink(PAPPVARS);
  138. ~CImpIAdviseSink(void);
  139. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  140. STDMETHODIMP_(ULONG) AddRef(void);
  141. STDMETHODIMP_(ULONG) Release(void);
  142. //We only implement OnDataChange for now.
  143. STDMETHODIMP_(void) OnDataChange(LPFORMATETC, LPSTGMEDIUM);
  144. STDMETHODIMP_(void) OnViewChange(DWORD, LONG);
  145. STDMETHODIMP_(void) OnRename(LPMONIKER);
  146. STDMETHODIMP_(void) OnSave(void);
  147. STDMETHODIMP_(void) OnClose(void);
  148. };
  149. //////////////////////////////////////////////////////////////////////////////
  150. // Storage Medium IUnknown interface for pUnkForRelease.
  151. //
  152. class CStgMedIf: public IUnknown {
  153. private:
  154. ULONG m_cRef;
  155. public:
  156. CStgMedIf();
  157. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  158. STDMETHODIMP_(ULONG) AddRef(void);
  159. STDMETHODIMP_(ULONG) Release(void);
  160. };
  161. //////////////////////////
  162. // API for getting a pUnkForRelease.
  163. //
  164. HRESULT GetStgMedpUnkForRelease(IUnknown **pp_unk);
  165. #endif //_DATAUSER_H_
  166.