Source code of Windows XP (NT5)
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.

791 lines
26 KiB

  1. #undef STRICT
  2. #define STRICT
  3. #include "nt.h"
  4. #include "ntrtl.h"
  5. #include "nturtl.h"
  6. #include "ntlsa.h"
  7. #ifndef RC_INVOKED
  8. // disable "non-standard extension" warnings in out code
  9. #pragma warning(disable:4001)
  10. // disable "nonstandard extension used : zero-sized array in struct/union"
  11. // warning from immp.h
  12. #pragma warning(disable:4200)
  13. #endif
  14. #include <w4warn.h>
  15. /*
  16. * Level 4 warnings to be turned on.
  17. * Do not disable any more level 4 warnings.
  18. */
  19. #pragma warning(disable:4127) // conditional expression is constant
  20. #pragma warning(disable:4305) // 'type cast' : truncation from 'LPWSTR ' to 'WORD'
  21. #pragma warning(disable:4189) // 'cyRet' : local variable is initialized but not referenced
  22. #pragma warning(disable:4328) // indirection alignment of formal parameter 1 (4) is greater than the actual argument alignment (2)
  23. #pragma warning(disable:4245) // 'initializing' : conversion from 'const int' to 'UINT', signed/unsigned mismatch
  24. #pragma warning(disable:4706) // <func:#77> assignment within conditional expression
  25. #pragma warning(disable:4701) // local variable 'crOldTextColor' may be used without having been initialized
  26. #pragma warning(disable:4057) // 'function' : 'LONG *__ptr64 ' differs in indirection to slightly different base types 'UINT *__ptr64 '
  27. #pragma warning(disable:4267) // 'initializing' : conversion from 'size_t' to 'UINT', possible loss of data
  28. #pragma warning(disable:4131) // 'ComboBox_NcDestroyHandler' : uses old-style declarator
  29. #pragma warning(disable:4310) // cast truncates constant value
  30. #pragma warning(disable:4306) // 'type cast' : conversion from 'BYTE' to 'DWORD *__ptr64 ' of greater size
  31. #pragma warning(disable:4054) // 'type cast' : from function pointer 'FARPROC ' to data pointer 'PLPKEDITCALLOUT '
  32. #pragma warning(disable:4055) // 'type cast' : from data pointer 'IStream *__ptr64 ' to function pointer 'FARPROC '
  33. #pragma warning(disable:4221) // nonstandard extension used : 'lprcClip' : cannot be initialized using address of automatic variable 'rcClip'
  34. #pragma warning(disable:4702) // <func:#191 ".ListView_RedrawSelection"> unreachable code
  35. #pragma warning(disable:4327) // '=' : indirection alignment of LHS (4) is greater than RHS (2)
  36. #pragma warning(disable:4213) // nonstandard extension used : cast on l-value
  37. #pragma warning(disable:4210) // nonstandard extension used : function given file scope
  38. #define _COMCTL32_
  39. #define _INC_OLE
  40. #define _SHLWAPI_
  41. #define CONST_VTABLE
  42. #define CC_INTERNAL
  43. #define OEMRESOURCE // Get the OEM bitmaps OBM_XXX from winuser.h
  44. #include <windows.h>
  45. #include <uxtheme.h>
  46. #include <tmschema.h>
  47. #include <windowsx.h>
  48. #include <ole2.h> // to get IStream for image.c
  49. #include <commctrl.h>
  50. #include <wingdip.h>
  51. #include <winuserp.h>
  52. #define NO_SHLWAPI_UNITHUNK // We have our own private thunks
  53. #include <shlwapi.h>
  54. #include <port32.h>
  55. #define DISALLOW_Assert
  56. #include <debug.h>
  57. #include <winerror.h>
  58. #include <ccstock.h>
  59. #include <imm.h>
  60. #include <immp.h>
  61. #include <shfusion.h>
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif // __cplusplus
  65. #include "thunk.h" // Ansi / Wide string conversions
  66. #include "mem.h"
  67. #include "rcids.h"
  68. #include "cstrings.h"
  69. #include "shobjidl.h"
  70. #include <CommonControls.h>
  71. #include "shpriv.h"
  72. #ifndef DS_BIDI_RTL
  73. #define DS_BIDI_RTL 0x8000
  74. #endif
  75. #define REGSTR_EXPLORER_ADVANCED TEXT("software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced")
  76. #define DCHF_TOPALIGN 0x00000002 // default is center-align
  77. #define DCHF_HORIZONTAL 0x00000004 // default is vertical
  78. #define DCHF_HOT 0x00000008 // default is flat
  79. #define DCHF_PUSHED 0x00000010 // default is flat
  80. #define DCHF_FLIPPED 0x00000020 // if horiz, default is pointing right
  81. // if vert, default is pointing up
  82. #define DCHF_TRANSPARENT 0x00000040
  83. #define DCHF_INACTIVE 0x00000080
  84. #define DCHF_NOBORDER 0x00000100
  85. extern void DrawCharButton(HDC hdc, LPRECT lprc, UINT wControlState, TCHAR ch, COLORREF rgbOveride);
  86. extern void DrawScrollArrow(HDC hdc, LPRECT lprc, UINT wControlState, COLORREF rgbOveride);
  87. extern void DrawChevron(HTHEME hTheme, int iPartId, HDC hdc, LPRECT lprc, DWORD dwFlags);
  88. #define EVENT_OBJECT_CREATE 0x8000
  89. #define EVENT_OBJECT_DESTROY 0x8001
  90. #define EVENT_OBJECT_SHOW 0x8002
  91. #define EVENT_OBJECT_HIDE 0x8003
  92. #define EVENT_OBJECT_REORDER 0x8004
  93. #define EVENT_OBJECT_FOCUS 0x8005
  94. #define EVENT_OBJECT_SELECTION 0x8006
  95. #define EVENT_OBJECT_SELECTIONADD 0x8007
  96. #define EVENT_OBJECT_SELECTIONREMOVE 0x8008
  97. #define EVENT_OBJECT_SELECTIONWITHIN 0x8009
  98. #define EVENT_OBJECT_STATECHANGE 0x800A
  99. #define EVENT_OBJECT_LOCATIONCHANGE 0x800B
  100. #define EVENT_OBJECT_NAMECHANGE 0x800C
  101. #define EVENT_OBJECT_DESCRIPTIONCHANGE 0x800D
  102. #define EVENT_OBJECT_VALUECHANGE 0x800E
  103. #define EVENT_SYSTEM_SOUND 0x0001
  104. #define EVENT_SYSTEM_ALERT 0x0002
  105. #define EVENT_SYSTEM_SCROLLINGSTART 0x0012
  106. #define EVENT_SYSTEM_SCROLLINGEND 0x0013
  107. // Secret SCROLLBAR index values
  108. #define INDEX_SCROLLBAR_SELF 0
  109. #define INDEX_SCROLLBAR_UP 1
  110. #define INDEX_SCROLLBAR_UPPAGE 2
  111. #define INDEX_SCROLLBAR_THUMB 3
  112. #define INDEX_SCROLLBAR_DOWNPAGE 4
  113. #define INDEX_SCROLLBAR_DOWN 5
  114. #define INDEX_SCROLLBAR_MIC 1
  115. #define INDEX_SCROLLBAR_MAC 5
  116. #define INDEX_SCROLLBAR_LEFT 7
  117. #define INDEX_SCROLLBAR_LEFTPAGE 8
  118. #define INDEX_SCROLLBAR_HORZTHUMB 9
  119. #define INDEX_SCROLLBAR_RIGHTPAGE 10
  120. #define INDEX_SCROLLBAR_RIGHT 11
  121. #define INDEX_SCROLLBAR_HORIZONTAL 6
  122. #define INDEX_SCROLLBAR_GRIP 12
  123. #define CHILDID_SELF 0
  124. #define INDEXID_OBJECT 0
  125. #define INDEXID_CONTAINER 0
  126. #ifndef WM_GETOBJECT
  127. #define WM_GETOBJECT 0x003D
  128. #endif
  129. #define MSAA_CLASSNAMEIDX_BASE 65536L
  130. #define MSAA_CLASSNAMEIDX_LISTBOX (MSAA_CLASSNAMEIDX_BASE+0)
  131. #define MSAA_CLASSNAMEIDX_BUTTON (MSAA_CLASSNAMEIDX_BASE+2)
  132. #define MSAA_CLASSNAMEIDX_STATIC (MSAA_CLASSNAMEIDX_BASE+3)
  133. #define MSAA_CLASSNAMEIDX_EDIT (MSAA_CLASSNAMEIDX_BASE+4)
  134. #define MSAA_CLASSNAMEIDX_COMBOBOX (MSAA_CLASSNAMEIDX_BASE+5)
  135. #define MSAA_CLASSNAMEIDX_SCROLLBAR (MSAA_CLASSNAMEIDX_BASE+10)
  136. #define MSAA_CLASSNAMEIDX_STATUS (MSAA_CLASSNAMEIDX_BASE+11)
  137. #define MSAA_CLASSNAMEIDX_TOOLBAR (MSAA_CLASSNAMEIDX_BASE+12)
  138. #define MSAA_CLASSNAMEIDX_PROGRESS (MSAA_CLASSNAMEIDX_BASE+13)
  139. #define MSAA_CLASSNAMEIDX_ANIMATE (MSAA_CLASSNAMEIDX_BASE+14)
  140. #define MSAA_CLASSNAMEIDX_TAB (MSAA_CLASSNAMEIDX_BASE+15)
  141. #define MSAA_CLASSNAMEIDX_HOTKEY (MSAA_CLASSNAMEIDX_BASE+16)
  142. #define MSAA_CLASSNAMEIDX_HEADER (MSAA_CLASSNAMEIDX_BASE+17)
  143. #define MSAA_CLASSNAMEIDX_TRACKBAR (MSAA_CLASSNAMEIDX_BASE+18)
  144. #define MSAA_CLASSNAMEIDX_LISTVIEW (MSAA_CLASSNAMEIDX_BASE+19)
  145. #define MSAA_CLASSNAMEIDX_UPDOWN (MSAA_CLASSNAMEIDX_BASE+22)
  146. #define MSAA_CLASSNAMEIDX_TOOLTIPS (MSAA_CLASSNAMEIDX_BASE+24)
  147. #define MSAA_CLASSNAMEIDX_TREEVIEW (MSAA_CLASSNAMEIDX_BASE+25)
  148. //
  149. // End BOGUS insertion from \win\core\access\inc32\winable.h
  150. //
  151. #ifdef MAXINT
  152. #undef MAXINT
  153. #endif
  154. #define MAXINT (int)0x7FFFFFFF
  155. // special value for pt.y or cyLabel indicating recomputation needed
  156. // NOTE: icon ordering code considers (RECOMPUTE, RECOMPUTE) at end
  157. // of all icons
  158. //
  159. #define RECOMPUTE (DWORD)MAXINT
  160. #define SRECOMPUTE ((short)0x7FFF)
  161. #define RECTWIDTH(rc) ((rc).right - (rc).left)
  162. #define RECTHEIGHT(rc) ((rc).bottom - (rc).top)
  163. #define ABS(i) (((i) < 0) ? -(i) : (i))
  164. #define BOUND(x,low,high) max(min(x, high),low)
  165. #define LPARAM_TO_POINT(lParam, pt) ((pt).x = LOWORD(lParam), \
  166. (pt).y = HIWORD(lParam))
  167. // common control info stuff
  168. typedef struct tagControlInfo
  169. {
  170. HWND hwnd;
  171. HWND hwndParent;
  172. DWORD style;
  173. DWORD dwCustom;
  174. BITBOOL bUnicode : 1;
  175. BITBOOL bInFakeCustomDraw:1;
  176. BITBOOL fDPIAware:1;
  177. UINT uiCodePage;
  178. DWORD dwExStyle;
  179. LRESULT iVersion;
  180. WORD wUIState;
  181. } CCONTROLINFO, *LPCCONTROLINFO;
  182. #define CCDPIScale(ci) ((ci).fDPIAware)
  183. BOOL CCGetIconSize(LPCCONTROLINFO pCI, HIMAGELIST himl, int* pcx, int* pcy);
  184. BOOL CCOnUIState(LPCCONTROLINFO pCI, UINT uMessage, WPARAM wParam, LPARAM lParam);
  185. BOOL CCGetUIState(LPCCONTROLINFO pControlInfo);
  186. BOOL CCNotifyNavigationKeyUsage(LPCCONTROLINFO pControlInfo, WORD wFlag);
  187. BOOL CCWndProc(CCONTROLINFO* pci, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* plres);
  188. void CCDrawInsertMark(HDC hdc, LPRECT prc, BOOL fHorizMode, COLORREF clr);
  189. void CIInitialize(LPCCONTROLINFO lpci, HWND hwnd, LPCREATESTRUCT lpcs);
  190. LRESULT CIHandleNotifyFormat(LPCCONTROLINFO lpci, LPARAM lParam);
  191. DWORD CICustomDrawNotify(LPCCONTROLINFO lpci, DWORD dwStage, LPNMCUSTOMDRAW lpnmcd);
  192. DWORD CIFakeCustomDrawNotify(LPCCONTROLINFO lpci, DWORD dwStage, LPNMCUSTOMDRAW lpnmcd);
  193. UINT RTLSwapLeftRightArrows(CCONTROLINFO *pci, WPARAM wParam);
  194. UINT CCSwapKeys(WPARAM wParam, UINT vk1, UINT vk2);
  195. LPTSTR CCReturnDispInfoText(LPTSTR pszSrc, LPTSTR pszDest, UINT cchDest);
  196. void FillRectClr(HDC hdc, PRECT prc, COLORREF clr);
  197. void FillPointClr(HDC hdc, POINT* ppt, COLORREF clr);
  198. //
  199. // helpers for drag-drop enabled controls
  200. //
  201. typedef LRESULT (*PFNDRAGCB)(HWND hwnd, UINT code, WPARAM wp, LPARAM lp);
  202. #define DPX_DRAGHIT (0) // WP = (unused) LP = POINTL* ret = item id
  203. #define DPX_GETOBJECT (1) // LP = nmobjectnotify ret = HRESULT
  204. #define DPX_SELECT (2) // WP = item id LP = DROPEFFECT_ ret = (unused)
  205. #define DPX_ENTER (3) // WP = (unused) LP = (unused) ret = BOOL
  206. #define DPX_LEAVE (4) // WP = (unused) LP = (unused) ret = (unused)
  207. // ddproxy.cpp
  208. DECLARE_HANDLE(HDRAGPROXY);
  209. STDAPI_(HDRAGPROXY) CreateDragProxy(HWND hwnd, PFNDRAGCB pfn, BOOL bRegister);
  210. STDAPI_(void) DestroyDragProxy(HDRAGPROXY hdp);
  211. STDAPI GetDragProxyTarget(HDRAGPROXY hdp, IDropTarget **ppdtgt);
  212. STDAPI GetItemObject(CCONTROLINFO *, UINT, const IID *, LPNMOBJECTNOTIFY);
  213. STDAPI_(struct IImgCtx *) CBitmapImgCtx_Create(HBITMAP hbm);
  214. #define SWAP(x,y, _type) { _type i; i = x; x = y; y = i; }
  215. //
  216. // This is for widened dispatch loop stuff
  217. //
  218. #ifdef WIN32
  219. typedef MSG MSG32;
  220. typedef MSG32 * LPMSG32;
  221. #define GetMessage32(lpmsg, hwnd, min, max, f32) GetMessage(lpmsg, hwnd, min, max)
  222. #define PeekMessage32(lpmsg, hwnd, min, max, flags, f32) PeekMessage(lpmsg, hwnd, min, max, flags)
  223. #define TranslateMessage32(lpmsg, f32) TranslateMessage(lpmsg)
  224. #define DispatchMessage32(lpmsg, f32) DispatchMessage(lpmsg)
  225. #define CallMsgFilter32(lpmsg, u, f32) CallMsgFilter(lpmsg, u)
  226. #define IsDialogMessage32(hwnd, lpmsg, f32) IsDialogMessage(hwnd, lpmsg)
  227. #else
  228. // This comes from ..\..\inc\usercmn.h--but I can't get commctrl to compile
  229. // when I include it and I don't have the time to mess with this right now.
  230. // DWORD wParam MSG structure
  231. typedef struct tagMSG32
  232. {
  233. HWND hwnd;
  234. UINT message;
  235. WPARAM wParam;
  236. LPARAM lParam;
  237. DWORD time;
  238. POINT pt;
  239. WPARAM wParamHi;
  240. } MSG32,* LPMSG32;
  241. BOOL WINAPI GetMessage32(LPMSG32, HWND, UINT, UINT, BOOL);
  242. BOOL WINAPI PeekMessage32(LPMSG32, HWND, UINT, UINT, UINT, BOOL);
  243. BOOL WINAPI TranslateMessage32(const MSG32*, BOOL);
  244. LONG WINAPI DispatchMessage32(const MSG32*, BOOL);
  245. BOOL WINAPI CallMsgFilter32(LPMSG32, int, BOOL);
  246. BOOL WINAPI IsDialogMessage32(HWND, LPMSG32, BOOL);
  247. #endif // WIN32
  248. //
  249. // This is a very important piece of performance hack for non-DBCS codepage.
  250. //
  251. // was !defined(DBCS) || defined(UNICODE)
  252. // FastCharNext and FastCharPrev are like CharNext and CharPrev except that
  253. // they don't check if you are at the beginning/end of the string.
  254. #define FastCharNext(pch) ((pch)+1)
  255. #define FastCharPrev(pchStart, pch) ((pch)-1)
  256. #define CH_PREFIX TEXT('&')
  257. #ifdef UNICODE
  258. #define lstrfns_StrEndN lstrfns_StrEndNW
  259. #define ChrCmp ChrCmpW
  260. #define ChrCmpI ChrCmpIW
  261. #else
  262. #define lstrfns_StrEndN lstrfns_StrEndNA
  263. #define ChrCmp ChrCmpA
  264. #define ChrCmpI ChrCmpIA
  265. #endif
  266. BOOL ChrCmpIA(WORD w1, WORD wMatch);
  267. BOOL ChrCmpIW(WCHAR w1, WCHAR wMatch);
  268. void TruncateString(char *sz, int cch); // from strings.c
  269. void InitGlobalMetrics(WPARAM);
  270. void InitGlobalColors();
  271. BOOL InitToolbarClass(HINSTANCE hInstance);
  272. BOOL InitReBarClass(HINSTANCE hInstance);
  273. BOOL InitToolTipsClass(HINSTANCE hInstance);
  274. BOOL InitStatusClass(HINSTANCE hInstance);
  275. BOOL InitHeaderClass(HINSTANCE hInstance);
  276. BOOL InitButtonListBoxClass(HINSTANCE hInstance);
  277. BOOL InitTrackBar(HINSTANCE hInstance);
  278. BOOL InitUpDownClass(HINSTANCE hInstance);
  279. BOOL InitProgressClass(HINSTANCE hInstance);
  280. BOOL InitHotKeyClass(HINSTANCE hInstance);
  281. BOOL InitToolTips(HINSTANCE hInstance);
  282. BOOL InitDateClasses(HINSTANCE hinst);
  283. BOOL InitButtonClass(HINSTANCE hinst);
  284. BOOL InitStaticClass(HINSTANCE hinst);
  285. BOOL InitEditClass(HINSTANCE hinst);
  286. BOOL InitLinkClass(HINSTANCE hinst);
  287. BOOL InitListBoxClass(HINSTANCE hinst);
  288. BOOL InitComboboxClass(HINSTANCE hInstance);
  289. BOOL InitComboLBoxClass(HINSTANCE hInstance);
  290. BOOL InitScrollBarClass(HINSTANCE hInstance);
  291. BOOL InitReaderModeClass(HINSTANCE hinst);
  292. VOID InitEditLpk(VOID);
  293. BOOL ChildOfActiveWindow(HWND hwnd);
  294. /* cutils.c */
  295. HFONT CCCreateUnderlineFont(HFONT hf);
  296. HFONT CCGetHotFont(HFONT hFont, HFONT *phFontHot);
  297. HFONT CCCreateStatusFont(void);
  298. BOOL CCForwardEraseBackground(HWND hwnd, HDC hdc);
  299. void CCPlaySound(LPCTSTR lpszName);
  300. BOOL CheckForDragBegin(HWND hwnd, int x, int y);
  301. void NewSize(HWND hWnd, int nHeight, LONG style, int left, int top, int width, int height);
  302. BOOL MGetTextExtent(HDC hdc, LPCTSTR lpstr, int cnt, int * pcx, int * pcy);
  303. void RelayToToolTips(HWND hwndToolTips, HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam);
  304. int StripAccelerators(LPTSTR lpszFrom, LPTSTR lpszTo, BOOL fAmpOnly);
  305. UINT GetCodePageForFont (HFONT hFont);
  306. void* CCLocalReAlloc(void* p, UINT uBytes);
  307. LONG GetMessagePosClient(HWND hwnd, LPPOINT ppt);
  308. void FlipRect(LPRECT prc);
  309. DWORD SetWindowBits(HWND hWnd, int iWhich, DWORD dwBits, DWORD dwValue);
  310. BOOL CCDrawEdge(HDC hdc, LPRECT lprc, UINT edge, UINT flags, LPCOLORSCHEME lpclrsc);
  311. BOOL CCThemeDrawEdge(HTHEME hTheme, HDC hdc, LPRECT lprc, int iPart, int iState, UINT edge, UINT flags, LPCOLORSCHEME lpclrsc);
  312. void CCInvalidateFrame(HWND hwnd);
  313. void FlipPoint(LPPOINT lppt);
  314. void CCSetInfoTipWidth(HWND hwndOwner, HWND hwndToolTips);
  315. #define CCResetInfoTipWidth(hwndOwner, hwndToolTips) \
  316. SendMessage(hwndToolTips, TTM_SETMAXTIPWIDTH, 0, -1)
  317. // Incremental search
  318. typedef struct ISEARCHINFO
  319. {
  320. int iIncrSearchFailed;
  321. LPTSTR pszCharBuf; // isearch string lives here
  322. int cbCharBuf; // allocated size of pszCharBuf
  323. int ichCharBuf; // number of live chars in pszCharBuf
  324. DWORD timeLast; // time of last input event
  325. #if defined(FE_IME) || !defined(WINNT)
  326. BOOL fReplaceCompChar;
  327. #endif
  328. } ISEARCHINFO, *PISEARCHINFO;
  329. #if defined(FE_IME) || !defined(WINNT)
  330. BOOL IncrementSearchImeCompStr(PISEARCHINFO pis, BOOL fCompStr, LPTSTR lpszCompChar, LPTSTR *lplpstr);
  331. #endif
  332. BOOL IncrementSearchString(PISEARCHINFO pis, UINT ch, LPTSTR *lplpstr);
  333. int GetIncrementSearchString(PISEARCHINFO pis, LPTSTR lpsz);
  334. int GetIncrementSearchStringA(PISEARCHINFO pis, UINT uiCodePage, LPSTR lpsz);
  335. void IncrementSearchBeep(PISEARCHINFO pis);
  336. #define IncrementSearchFree(pis) ((pis)->pszCharBuf ? Free((pis)->pszCharBuf) : 0)
  337. // For RTL mirroring use
  338. void MirrorBitmapInDC( HDC hdc , HBITMAP hbmOrig );
  339. BOOL CCForwardPrint(CCONTROLINFO* pci, HDC hdc);
  340. BOOL CCSendPrint(CCONTROLINFO* pci, HDC hdc);
  341. BOOL CCSendPrintRect(CCONTROLINFO* pci, HDC hdc, RECT* prc);
  342. // consider folding hTheme in with CControlInfo
  343. BOOL CCShouldAskForBits(CCONTROLINFO* pci, HTHEME hTheme, int iPart, int iState);
  344. BOOL AreAllMonitorsAtLeast(int iBpp);
  345. void BlurBitmap(ULONG* plBitmapBits, int cx, int cy, COLORREF crFill);
  346. int CCGetScreenDPI();
  347. void CCDPIScaleX(int* x);
  348. void CCDPIScaleY(int* y);
  349. int CCScaleX(int x);
  350. int CCScaleY(int y);
  351. void CCDPIUnScaleX(int* x);
  352. void CCDPIUnScaleY(int* y);
  353. BOOL CCIsHighDPI();
  354. void CCAdjustForBold(LOGFONT* plf);
  355. typedef struct tagCCDBUFFER
  356. {
  357. BOOL fInitialized;
  358. HDC hMemDC;
  359. HBITMAP hMemBm;
  360. HBITMAP hOldBm;
  361. HDC hPaintDC;
  362. RECT rc;
  363. } CCDBUFFER;
  364. HDC CCBeginDoubleBuffer(HDC hdcIn, RECT* prc, CCDBUFFER* pdb);
  365. void CCEndDoubleBuffer(CCDBUFFER* pdb);
  366. #ifdef FEATURE_FOLLOW_FOCUS_RECT
  367. void CCSetFocus(HWND hwnd, RECT* prc);
  368. void CCLostFocus(HWND hwnd);
  369. #endif
  370. BOOL CCDrawNonClientTheme(HTHEME hTheme, HWND hwnd, HRGN hRgnUpdate, HBRUSH hbr, int iPartId, int iStateId);
  371. BOOL DSA_ForceGrow(HDSA hdsa, int iNumberToAdd);
  372. #ifdef DEBUG
  373. void DumpRgn(ULONGLONG qwFlags, char*trace, HRGN hrgn);
  374. #else
  375. #define DumpRgn(qwFlags, trace, hrgn) 0
  376. #endif
  377. // Locale manipulation (prsht.c)
  378. //
  379. // The "proper thread locale" is the thread locale we should
  380. // be using for our UI elements.
  381. //
  382. // If you need to change the thread locale temporarily
  383. // to the proper thread locale, use
  384. //
  385. // LCID lcidPrev;
  386. // CCSetProperThreadLocale(&lcidPrev);
  387. // munge munge munge
  388. // CCRestoreThreadLocale(lcidPrev);
  389. //
  390. // If you just want to retrieve the proper thread locale,
  391. // call CCGetProperThreadLocale(NULL).
  392. //
  393. //
  394. LCID CCGetProperThreadLocale(OPTIONAL LCID *plcidPrev);
  395. __inline void CCSetProperThreadLocale(LCID *plcidPrev) {
  396. SetThreadLocale(CCGetProperThreadLocale(plcidPrev));
  397. }
  398. #define CCRestoreThreadLocale(lcid) SetThreadLocale(lcid)
  399. int CCLoadStringExInternal(HINSTANCE hInst, UINT uID, LPWSTR lpBuffer, int nBufferMax, WORD wLang);
  400. int CCLoadStringEx(UINT uID, LPWSTR lpBuffer, int nBufferMax, WORD wLang);
  401. int LocalizedLoadString(UINT uID, LPWSTR lpBuffer, int nBufferMax);
  402. HRSRC FindResourceExRetry(HMODULE hmod, LPCTSTR lpType, LPCTSTR lpName, WORD wLang);
  403. // assign most unlikely used value for the fake sublang id
  404. #define SUBLANG_JAPANESE_ALTFONT 0x3f // max within 6bit
  405. // used to get resource lang of shell32
  406. #define DLG_EXITWINDOWS 1064
  407. //
  408. // Plug UI Setting funcions (commctrl.c)
  409. //
  410. LANGID WINAPI GetMUILanguage(void);
  411. #ifdef UNICODE
  412. //
  413. // Tooltip thunking api's
  414. //
  415. BOOL ThunkToolTipTextAtoW (LPTOOLTIPTEXTA lpTttA, LPTOOLTIPTEXTW lpTttW, UINT uiCodePage);
  416. #endif
  417. HWND GetDlgItemRect(HWND hDlg, int nIDItem, LPRECT prc);
  418. //
  419. // Global variables
  420. //
  421. extern HINSTANCE g_hinst;
  422. extern UINT uDragListMsg;
  423. extern int g_iIncrSearchFailed;
  424. extern ATOM g_atomThemeScrollBar;
  425. extern UINT g_uiACP;
  426. #ifndef QWORD
  427. #define QWORD unsigned __int64
  428. #endif
  429. extern QWORD qw128;
  430. extern QWORD qw1;
  431. #define g_bMirroredOS TRUE
  432. //
  433. // Icon mirroring stuff
  434. //
  435. extern HDC g_hdc;
  436. extern HDC g_hdcMask;
  437. #define HINST_THISDLL g_hinst
  438. #ifdef WIN32
  439. #ifdef DEBUG
  440. #undef SendMessage
  441. #define SendMessage SendMessageD
  442. #ifdef __cplusplus
  443. extern "C"
  444. {
  445. #endif
  446. LRESULT WINAPI SendMessageD(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
  447. int WINAPI Str_GetPtr0(LPCTSTR pszCurrent, LPTSTR pszBuf, int cchBuf);
  448. #ifdef __cplusplus
  449. }
  450. #endif
  451. #else // !DEBUG
  452. #define Str_GetPtr0 Str_GetPtr
  453. #endif // DEBUG / !DEBUG
  454. #endif // WIN32
  455. // REVIEW, should this be a function? (inline may generate a lot of code)
  456. #define CBBITMAPBITS(cx, cy, cPlanes, cBitsPerPixel) \
  457. (((((cx) * (cBitsPerPixel) + 15) & ~15) >> 3) \
  458. * (cPlanes) * (cy))
  459. #define WIDTHBYTES(cx, cBitsPerPixel) \
  460. ((((cx) * (cBitsPerPixel) + 31) / 32) * 4)
  461. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) /* ;Internal */
  462. #define InRange(id, idFirst, idLast) ((UINT)((id)-(idFirst)) <= (UINT)((idLast)-(idFirst)))
  463. void ColorDitherBrush_OnSysColorChange();
  464. extern HBRUSH g_hbrMonoDither; // gray dither brush from image.c
  465. void InitDitherBrush();
  466. void TerminateDitherBrush();
  467. #ifndef DT_NOFULLWIDTHCHARBREAK
  468. #define DT_NOFULLWIDTHCHARBREAK 0x00080000
  469. #endif // DT_NOFULLWIDTHCHARBREAK
  470. #define SHDT_DRAWTEXT 0x00000001
  471. #define SHDT_ELLIPSES 0x00000002
  472. #define SHDT_CLIPPED 0x00000004
  473. #define SHDT_SELECTED 0x00000008
  474. #define SHDT_DESELECTED 0x00000010
  475. #define SHDT_DEPRESSED 0x00000020
  476. #define SHDT_EXTRAMARGIN 0x00000040
  477. #define SHDT_TRANSPARENT 0x00000080
  478. #define SHDT_SELECTNOFOCUS 0x00000100
  479. #define SHDT_HOTSELECTED 0x00000200
  480. #define SHDT_DTELLIPSIS 0x00000400
  481. #ifdef WINDOWS_ME
  482. #define SHDT_RTLREADING 0x00000800
  483. #endif
  484. #define SHDT_NODBCSBREAK 0x00001000
  485. #define SHDT_VCENTER 0x00002000
  486. #define SHDT_LEFT 0x00004000
  487. #define SHDT_BORDERSELECT 0x00008000
  488. // Do not draw text in selected style:
  489. #define SHDT_NOSELECTED 0x00010000
  490. #define SHDT_NOMARGIN 0x00020000
  491. #define SHDT_SHADOWTEXT 0x00040000
  492. void WINAPI SHDrawText(HDC hdc, LPCTSTR pszText, RECT* prc,
  493. int fmt, UINT flags, int cyChar, int cxEllipses,
  494. COLORREF clrText, COLORREF clrTextBk);
  495. void WINAPI SHThemeDrawText(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCTSTR pszText, RECT* prc,
  496. int fmt, UINT flags, int cyChar, int cxEllipses,
  497. COLORREF clrText, COLORREF clrTextBk);
  498. // notify.c
  499. LRESULT WINAPI CCSendNotify(CCONTROLINFO * pci, int code, LPNMHDR pnm);
  500. BOOL CCReleaseCapture(CCONTROLINFO * pci);
  501. void CCSetCapture(CCONTROLINFO * pci, HWND hwndSet);
  502. // treeview.c, listview.c for FE_IME code
  503. LPTSTR GET_COMP_STRING(HIMC hImc, DWORD dwFlags);
  504. // lvicon.c in-place editing
  505. #define SEIPS_WRAP 0x0001
  506. #ifdef DEBUG
  507. #define SEIPS_NOSCROLL 0x0002 // Flag is used only in DEBUG
  508. #endif
  509. void SetEditInPlaceSize(HWND hwndEdit, RECT *prc, HFONT hFont, UINT seips);
  510. HWND CreateEditInPlaceWindow(HWND hwnd, LPCTSTR lpText, int cbText, LONG style, HFONT hFont);
  511. void RescrollEditWindow(HWND hwndEdit);
  512. void SHOutlineRectThickness(HDC hdc, const RECT* prc, COLORREF cr, COLORREF crDefault, int cp);
  513. #define SHOutlineRect(hdc, prc, cr, crDefault) SHOutlineRectThickness(hdc, prc, cr, crDefault, 1)
  514. COLORREF GetSortColor(int iPercent, COLORREF clr);
  515. COLORREF GetBorderSelectColor(int iPercent, COLORREF clr);
  516. BOOL IsUsingCleartype();
  517. BOOL UseMenuSelectionStyle();
  518. // readermode.c auto scroll control entry point
  519. BOOL EnterReaderMode(HWND hwnd);
  520. // Global System metrics.
  521. extern int g_cxEdge;
  522. extern int g_cyEdge;
  523. extern int g_cxEdgeScaled;
  524. extern int g_cyEdgeScaled;
  525. extern int g_cxBorder;
  526. extern int g_cyBorder;
  527. extern int g_cxScreen;
  528. extern int g_cyScreen;
  529. extern int g_cxDoubleClk;
  530. extern int g_cyDoubleClk;
  531. extern int g_cxSmIcon;
  532. extern int g_cySmIcon;
  533. //extern int g_cxIcon;
  534. //extern int g_cyIcon;
  535. extern int g_cxFrame;
  536. extern int g_cyFrame;
  537. extern int g_cxIconSpacing, g_cyIconSpacing;
  538. extern int g_cxScrollbar, g_cyScrollbar;
  539. extern int g_cxIconMargin, g_cyIconMargin;
  540. extern int g_cyLabelSpace;
  541. extern int g_cxLabelMargin;
  542. //extern int g_cxIconOffset, g_cyIconOffset;
  543. extern int g_cxVScroll;
  544. extern int g_cyHScroll;
  545. extern int g_cxHScroll;
  546. extern int g_cyVScroll;
  547. extern int g_fDragFullWindows;
  548. extern int g_fDBCSEnabled;
  549. extern int g_fMEEnabled;
  550. extern int g_fDBCSInputEnabled;
  551. extern int g_fIMMEnabled;
  552. extern int g_cyCompensateInternalLeading;
  553. extern int g_fLeftAligned;
  554. extern COLORREF g_clrWindow;
  555. extern COLORREF g_clrWindowText;
  556. extern COLORREF g_clrWindowFrame;
  557. extern COLORREF g_clrGrayText;
  558. extern COLORREF g_clrBtnText;
  559. extern COLORREF g_clrBtnFace;
  560. extern COLORREF g_clrBtnShadow;
  561. extern COLORREF g_clrBtnHighlight;
  562. extern COLORREF g_clrHighlight;
  563. extern COLORREF g_clrHighlightText;
  564. extern COLORREF g_clrInfoText;
  565. extern COLORREF g_clrInfoBk;
  566. extern COLORREF g_clr3DDkShadow;
  567. extern COLORREF g_clr3DLight;
  568. extern COLORREF g_clrMenuHilight;
  569. extern COLORREF g_clrMenuText;
  570. extern HBRUSH g_hbrGrayText;
  571. extern HBRUSH g_hbrWindow;
  572. extern HBRUSH g_hbrWindowText;
  573. extern HBRUSH g_hbrWindowFrame;
  574. extern HBRUSH g_hbrBtnFace;
  575. extern HBRUSH g_hbrBtnHighlight;
  576. extern HBRUSH g_hbrBtnShadow;
  577. extern HBRUSH g_hbrHighlight;
  578. extern HBRUSH g_hbrMenuHilight;
  579. extern HBRUSH g_hbrMenuText;
  580. extern HFONT g_hfontSystem;
  581. #define WHEEL_DELTA 120
  582. extern UINT g_msgMSWheel;
  583. extern UINT g_ucScrollLines;
  584. extern int gcWheelDelta;
  585. extern UINT g_uDragImages;
  586. extern BOOL g_fEnableBalloonTips;
  587. extern BOOL g_fHighContrast;
  588. extern double g_dScaleX;
  589. extern double g_dScaleY;
  590. #ifdef __cplusplus
  591. }
  592. #endif // __cplusplus
  593. //
  594. // Defining FULL_DEBUG makes us debug memory problems.
  595. //
  596. #if defined(FULL_DEBUG) && defined(WIN32)
  597. #include "../inc/deballoc.h"
  598. #endif // defined(FULL_DEBUG) && defined(WIN32)
  599. // TRACE FLAGS
  600. //
  601. #define TF_MONTHCAL 0x00000100 // MonthCal and DateTimePick
  602. #define TF_BKIMAGE 0x00000200 // ListView background image
  603. #define TF_TOOLBAR 0x00000400 // Toolbar stuff
  604. #define TF_PAGER 0x00000800 // Pager Stuff
  605. #define TF_REBAR 0x00001000 // Rebar
  606. #define TF_LISTVIEW 0x00002000 // Listview
  607. #define TF_TREEVIEW 0x00004000 // Treeview
  608. #define TF_STATUS 0x00008000 // Status bar
  609. #define TF_STANDARD 0x00010000 // Standard controls ported from user32
  610. #define TF_IMAGELIST 0x00020000
  611. // Prototype flags
  612. #define PTF_FLATLOOK 0x00000001 // Overall flatlook
  613. #define PTF_NOISEARCHTO 0x00000002 // No incremental search timeout
  614. #include <platform.h>
  615. // Dummy union macros for code compilation on platforms not
  616. // supporting nameless stuct/union
  617. #ifdef NONAMELESSUNION
  618. #define DUMMYUNION_MEMBER(member) DUMMYUNIONNAME.member
  619. #define DUMMYUNION2_MEMBER(member) DUMMYUNIONNAME2.member
  620. #define DUMMYUNION3_MEMBER(member) DUMMYUNIONNAME3.member
  621. #define DUMMYUNION4_MEMBER(member) DUMMYUNIONNAME4.member
  622. #define DUMMYUNION5_MEMBER(member) DUMMYUNIONNAME5.member
  623. #else
  624. #define DUMMYUNION_MEMBER(member) member
  625. #define DUMMYUNION2_MEMBER(member) member
  626. #define DUMMYUNION3_MEMBER(member) member
  627. #define DUMMYUNION4_MEMBER(member) member
  628. #define DUMMYUNION5_MEMBER(member) member
  629. #endif
  630. #ifdef FULL_DEBUG
  631. #ifdef __cplusplus
  632. extern "C" {
  633. #endif
  634. void DebugPaintInvalid(HWND hwnd, RECT* prc, HRGN rgn);
  635. void DebugPaintClip(HWND hwnd, HDC hdc);
  636. void DebugPaintRect(HDC hdc, RECT* prc);
  637. #ifdef __cplusplus
  638. }
  639. #endif
  640. #else
  641. #define DebugPaintInvalid(hwnd, prc, rgn) 0
  642. #define DebugPaintClip(hwnd, hdc) 0
  643. #define DebugPaintRect(hdc, prc) 0
  644. #endif
  645. #define ALLOC_NULLHEAP(heap, size) Alloc( size )
  646. #define COLOR_STRUCT DWORD
  647. #define QUAD_PART(a) ((a)##.QuadPart)
  648. #ifndef ISREMOTESESSION
  649. #define ISREMOTESESSION() GetSystemMetrics(SM_REMOTESESSION)
  650. #endif
  651. EXTERN_C BOOL g_fCriticalInitialized;
  652. #undef ENTERCRITICAL
  653. #undef LEAVECRITICAL
  654. #undef ASSERTCRITICAL
  655. #define ENTERCRITICAL do { if (g_fCriticalInitialized) EnterCriticalSection(&g_csDll); } while (0);
  656. #define LEAVECRITICAL do { if (g_fCriticalInitialized) LeaveCriticalSection(&g_csDll); } while (0);
  657. #define ASSERTCRITICAL