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.

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