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.

198 lines
6.4 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // Copyright (C) 1993-1996 Microsoft Corporation. All Rights Reserved.
  3. //
  4. // MODULE: tipday.h
  5. //
  6. // PURPOSE: Defines the CTipOfTheDay control.
  7. //
  8. typedef struct {
  9. LPTSTR pszLinkText;
  10. LPTSTR pszLinkAddr;
  11. HWND hwndCtl;
  12. } LINKINFO, *PLINKINFO;
  13. #define LINKINFO_PROP _T("Link Info") // PLINKINFO pointer
  14. #define WNDPROC_PROP _T("Wndproc")
  15. #define TIPINFO_PROP _T("CTipOfTheDay") // 'this' pointer
  16. #define BUTTON_CLASS _T("Athena Button")
  17. class CTipOfTheDay
  18. {
  19. public:
  20. /////////////////////////////////////////////////////////////////////////
  21. // Constructors, Destructors, and Initialization
  22. CTipOfTheDay();
  23. ~CTipOfTheDay();
  24. HRESULT HrCreate(HWND hwndParent, FOLDER_TYPE ftType);
  25. STDMETHODIMP_(ULONG) AddRef(void);
  26. STDMETHODIMP_(ULONG) Release(void);
  27. static LRESULT CALLBACK TipWndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
  28. LPARAM lParam);
  29. BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct);
  30. void OnSize(HWND hwnd, UINT state, int cx, int cy);
  31. void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify);
  32. void OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT * lpDrawItem);
  33. void OnDestroy(HWND hwnd);
  34. void OnSysColorChange(HWND hwnd);
  35. void OnPaint(HWND hwnd);
  36. HBRUSH OnCtlColor(HWND hwnd, HDC hdc, HWND hwndChild, int type);
  37. DWORD GetRequiredWidth(void);
  38. DWORD GetRequiredHeight(void);
  39. void FreeLinkInfo(void);
  40. HRESULT HrLoadTipInfo(void);
  41. HRESULT HrLoadLinkInfo(void);
  42. HRESULT HrCreateChildWindows(HWND hwnd);
  43. HWND GetHwnd(void) { return m_hwnd; }
  44. private:
  45. /////////////////////////////////////////////////////////////////////////
  46. // Private Data
  47. ULONG m_cRef;
  48. HWND m_hwnd;
  49. HWND m_hwndParent;
  50. HWND m_hwndNext;
  51. FOLDER_TYPE m_ftType;
  52. TCHAR m_szTitle[CCHMAX_STRINGRES];
  53. TCHAR m_szNextTip[64];
  54. // Tip string information
  55. LPTSTR m_pszTip;
  56. DWORD m_dwCurrentTip;
  57. // Link information
  58. // DWORD m_cLinks;
  59. // PLINKINFO m_rgLinkInfo;
  60. // Drawing info -- these get reset every WM_SYSCOLORCHANGE
  61. COLORREF m_clrBack;
  62. COLORREF m_clrText;
  63. COLORREF m_clrLink;
  64. HFONT m_hfLink;
  65. TEXTMETRIC m_tmLink;
  66. HFONT m_hfTitle;
  67. TEXTMETRIC m_tmTitle;
  68. HFONT m_hfTip;
  69. HICON m_hiTip;
  70. DWORD m_cyTitleHeight;
  71. DWORD m_cxTitleWidth;
  72. HBRUSH m_hbrBack;
  73. DWORD m_dwBorder;
  74. DWORD m_cxNextWidth;
  75. DWORD m_cyNextHeight;
  76. RECT m_rcTip;
  77. };
  78. #define IDC_TIPCONTROL 1001
  79. #define IDC_TIP_STATIC 1002
  80. #define IDC_NEXTTIP_BUTTON 1003
  81. #define IDC_LINKBASE_BUTTON 1500
  82. #define LINK_BUTTON_BORDER 3 // pixels
  83. #define TIP_ICON_HEIGHT 32
  84. #define TIP_ICON_WIDTH 32
  85. /////////////////////////////////////////////////////////////////////////////
  86. //
  87. // CLinkButton
  88. //
  89. // Creates an owner-drawn button that looks a lot like a web link.
  90. //
  91. class CLinkButton
  92. {
  93. public:
  94. /////////////////////////////////////////////////////////////////////////
  95. // Constructors, Destructors, and Initialization
  96. CLinkButton();
  97. ~CLinkButton();
  98. HRESULT HrCreate(HWND hwndParent, LPTSTR pszCaption, LPTSTR pszLink,
  99. UINT uID);
  100. HRESULT HrCreate(HWND hwndParent, LPTSTR pszCaption, UINT uID, UINT index,
  101. HBITMAP hbmButton, HBITMAP hbmMask, HPALETTE hpal);
  102. /////////////////////////////////////////////////////////////////////////
  103. // Ref Counting
  104. STDMETHODIMP_(ULONG) AddRef(void);
  105. STDMETHODIMP_(ULONG) Release(void);
  106. /////////////////////////////////////////////////////////////////////////
  107. // Moving, Sizing
  108. DWORD GetHeight(void) { return m_cyHeight; }
  109. DWORD GetWidth(void) { return m_cxWidth; }
  110. HWND GetWindow(void) { return m_hwnd; }
  111. void Move(DWORD x, DWORD y);
  112. void Move(POINT pt) { Move(pt.x, pt.y); }
  113. void Show(BOOL fShow);
  114. /////////////////////////////////////////////////////////////////////////
  115. // Painting
  116. void OnDraw(HWND hwnd, const DRAWITEMSTRUCT *lpDrawItem);
  117. HBRUSH OnCtlColorBtn(HWND hwnd) { return (m_hbrBack); }
  118. /////////////////////////////////////////////////////////////////////////
  119. // System changes
  120. void OnSysColorChange(void);
  121. void OnPaletteChanged(HWND hwnd, HWND hwndPaletteChange);
  122. /////////////////////////////////////////////////////////////////////////
  123. // Execute
  124. void OnCommand(void);
  125. private:
  126. /////////////////////////////////////////////////////////////////////////
  127. // Private Data
  128. ULONG m_cRef; // Ref Count
  129. HWND m_hwnd; // Handle of our button window
  130. HWND m_hwndParent; // Handle of our parent
  131. // Caption and Link strings and Command ID
  132. LPTSTR m_pszCaption;
  133. LPTSTR m_pszLink;
  134. UINT m_uID;
  135. // Drawing info -- these get reset every WM_SYSCOLORCHANGE
  136. COLORREF m_clrLink;
  137. COLORREF m_clrBack;
  138. HFONT m_hfLink;
  139. TEXTMETRIC m_tmLink;
  140. HBRUSH m_hbrBack;
  141. DWORD m_dwBorder;
  142. DWORD m_cxWidth;
  143. DWORD m_cyHeight;
  144. UINT m_index;
  145. DWORD m_cxImage;
  146. DWORD m_cyImage;
  147. // GDI Resources passed to us when we are created
  148. HBITMAP m_hbmButtons;
  149. HBITMAP m_hbmMask;
  150. HPALETTE m_hpalButtons;
  151. };
  152. // #define CX_BUTTON_IMAGE 96
  153. // #define CY_BUTTON_IMAGE 84
  154. #define CX_BUTTON_IMAGE 110 // 104
  155. #define CY_BUTTON_IMAGE 110 // 68
  156. LRESULT CALLBACK ButtonSubClass(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  157. HRESULT HrLoadButtonBitmap(HWND hwnd, int idBmp, int idMask, HBITMAP* phBtns,
  158. HBITMAP *phMask, HPALETTE *phPalette);