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.

692 lines
23 KiB

  1. #undef STRICT
  2. #define STRICT
  3. /* disable "non-standard extension" warnings in our code
  4. */
  5. #ifndef RC_INVOKED
  6. #pragma warning(disable:4001)
  7. #endif
  8. #define _COMCTL32_
  9. #define _INC_OLE
  10. #define _SHLWAPI_
  11. #define CONST_VTABLE
  12. #ifndef WINVER
  13. // This stuff must run on Win95
  14. // The NT build process already have these set as 0x0400
  15. #define WINVER 0x0400
  16. #endif
  17. #define CC_INTERNAL
  18. // so winbase.h declares QueryActCtx, ActivateActCtx, etc.
  19. #define _WIN32_FUSION 0x0100
  20. #include <nt.h>
  21. #include <ntrtl.h>
  22. #include <nturtl.h>
  23. #include <windows.h>
  24. #include <windowsx.h>
  25. #include <ole2.h> // to get IStream for image.c
  26. #include <commctrl.h>
  27. #define NO_SHLWAPI_UNITHUNK // We have our own private thunks
  28. #include <shlwapi.h>
  29. #include <port32.h>
  30. #define DISALLOW_Assert
  31. #include <debug.h>
  32. #include <winerror.h>
  33. #include <ccstock.h>
  34. #if defined(FE_IME)
  35. #include <imm.h>
  36. #endif
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif // __cplusplus
  40. #include "multimon.h" // support for multiple monitor APIs on non-mm OSes
  41. #include "thunk.h" // Ansi / Wide string conversions
  42. #include "apithk.h"
  43. #include "mem.h"
  44. #include "rcids.h"
  45. #include "cstrings.h"
  46. #include <crtfree.h>
  47. #include "shpriv.h"
  48. #include <strsafe.h>
  49. #ifndef DS_BIDI_RTL
  50. #define DS_BIDI_RTL 0x8000
  51. #endif
  52. #ifdef FONT_LINK
  53. //
  54. // CodePages
  55. //
  56. #define CP_OEM_437 437
  57. #define CP_IBM852 852
  58. #define CP_IBM866 866
  59. #define CP_THAI 874
  60. #define CP_JAPAN 932
  61. #define CP_CHINA 936
  62. #define CP_KOREA 949
  63. #define CP_TAIWAN 950
  64. #define CP_EASTEUROPE 1250
  65. #define CP_RUSSIAN 1251
  66. #define CP_WESTEUROPE 1252
  67. #define CP_GREEK 1253
  68. #define CP_TURKISH 1254
  69. #define CP_HEBREW 1255
  70. #define CP_ARABIC 1256
  71. #define CP_BALTIC 1257
  72. #define CP_VIETNAMESE 1258
  73. #define CP_RUSSIANKOI8R 20866
  74. #define CP_RUSSIANKOI8RU 21866
  75. #define CP_ISOEASTEUROPE 28592
  76. #define CP_ISOTURKISH 28593
  77. #define CP_ISOBALTIC 28594
  78. #define CP_ISORUSSIAN 28595
  79. #define CP_ISOARABIC 28596
  80. #define CP_ISOGREEK 28597
  81. #define CP_JAPANNHK 50220
  82. #define CP_JAPANESC 50221
  83. #define CP_JAPANSIO 50222
  84. #define CP_KOREAISO 50225
  85. #define CP_JAPANEUC 51932
  86. #define CP_CHINAHZ 52936
  87. #define CP_MAC_ROMAN 10000
  88. #define CP_MAC_JAPAN 10001
  89. #define CP_MAC_GREEK 10006
  90. #define CP_MAC_CYRILLIC 10007
  91. #define CP_MAC_LATIN2 10029
  92. #define CP_MAC_TURKISH 10081
  93. #define CP_DEFAULT CP_ACP
  94. #define CP_GETDEFAULT GetACP()
  95. #define CP_JOHAB 1361
  96. #define CP_SYMBOL 42
  97. #define CP_UTF8 65001
  98. #define CP_UTF7 65000
  99. #define CP_UNICODELITTLE 1200
  100. #define CP_UNICODEBIG 1201
  101. #define OEM437_CHARSET 254
  102. #endif //FONT_LINK
  103. //
  104. // inside comctl32 we always call _TrackMouseEvent...
  105. //
  106. #ifndef TrackMouseEvent
  107. #define TrackMouseEvent _TrackMouseEvent
  108. #endif
  109. #define DCHF_LARGE 0x00000001 // default is small
  110. #define DCHF_TOPALIGN 0x00000002 // default is center-align
  111. #define DCHF_HORIZONTAL 0x00000004 // default is vertical
  112. #define DCHF_HOT 0x00000008 // default is flat
  113. #define DCHF_PUSHED 0x00000010 // default is flat
  114. #define DCHF_FLIPPED 0x00000020 // if horiz, default is pointing right
  115. // if vert, default is pointing up
  116. #define DCHF_TRANSPARENT 0x00000040
  117. #define DCHF_INACTIVE 0x00000080
  118. #define DCHF_NOBORDER 0x00000100
  119. extern void DrawCharButton(HDC hdc, LPRECT lprc, UINT wControlState, TCHAR ch);
  120. extern void DrawScrollArrow(HDC hdc, LPRECT lprc, UINT wControlState);
  121. extern void DrawChevron(HDC hdc, LPRECT lprc, DWORD dwState);
  122. //
  123. // BOGUS -- This are all in \win\core\access\inc32\winable.h, but it's too
  124. // tricky to mess with the build process. The IE guys are not enlisted in
  125. // core, just shell, so they won't be able to build COMCTL32 if we include
  126. // that file.
  127. //
  128. extern void MyNotifyWinEvent(UINT, HWND, LONG, LONG_PTR);
  129. #define OBJID_WINDOW ((LONG)0x00000000)
  130. #define OBJID_SYSMENU ((LONG)0xFFFFFFFF)
  131. #define OBJID_TITLEBAR ((LONG)0xFFFFFFFE)
  132. #define OBJID_MENU ((LONG)0xFFFFFFFD)
  133. #define OBJID_CLIENT ((LONG)0xFFFFFFFC)
  134. #define OBJID_VSCROLL ((LONG)0xFFFFFFFB)
  135. #define OBJID_HSCROLL ((LONG)0xFFFFFFFA)
  136. #define OBJID_SIZEGRIP ((LONG)0xFFFFFFF9)
  137. #define OBJID_CARET ((LONG)0xFFFFFFF8)
  138. #define OBJID_CURSOR ((LONG)0xFFFFFFF7)
  139. #define OBJID_ALERT ((LONG)0xFFFFFFF6)
  140. #define OBJID_SOUND ((LONG)0xFFFFFFF5)
  141. #define OBJID_QUERYCLASSNAMEIDX ((LONG)0xFFFFFFF4)
  142. #define EVENT_OBJECT_CREATE 0x8000
  143. #define EVENT_OBJECT_DESTROY 0x8001
  144. #define EVENT_OBJECT_SHOW 0x8002
  145. #define EVENT_OBJECT_HIDE 0x8003
  146. #define EVENT_OBJECT_REORDER 0x8004
  147. #define EVENT_OBJECT_FOCUS 0x8005
  148. #define EVENT_OBJECT_SELECTION 0x8006
  149. #define EVENT_OBJECT_SELECTIONADD 0x8007
  150. #define EVENT_OBJECT_SELECTIONREMOVE 0x8008
  151. #define EVENT_OBJECT_SELECTIONWITHIN 0x8009
  152. #define EVENT_OBJECT_STATECHANGE 0x800A
  153. #define EVENT_OBJECT_LOCATIONCHANGE 0x800B
  154. #define EVENT_OBJECT_NAMECHANGE 0x800C
  155. #define EVENT_OBJECT_DESCRIPTIONCHANGE 0x800D
  156. #define EVENT_OBJECT_VALUECHANGE 0x800E
  157. #define EVENT_SYSTEM_SOUND 0x0001
  158. #define EVENT_SYSTEM_ALERT 0x0002
  159. #define EVENT_SYSTEM_SCROLLINGSTART 0x0012
  160. #define EVENT_SYSTEM_SCROLLINGEND 0x0013
  161. // Secret SCROLLBAR index values
  162. #define INDEX_SCROLLBAR_SELF 0
  163. #define INDEX_SCROLLBAR_UP 1
  164. #define INDEX_SCROLLBAR_UPPAGE 2
  165. #define INDEX_SCROLLBAR_THUMB 3
  166. #define INDEX_SCROLLBAR_DOWNPAGE 4
  167. #define INDEX_SCROLLBAR_DOWN 5
  168. #define INDEX_SCROLLBAR_MIC 1
  169. #define INDEX_SCROLLBAR_MAC 5
  170. #define INDEX_SCROLLBAR_LEFT 7
  171. #define INDEX_SCROLLBAR_LEFTPAGE 8
  172. #define INDEX_SCROLLBAR_HORZTHUMB 9
  173. #define INDEX_SCROLLBAR_RIGHTPAGE 10
  174. #define INDEX_SCROLLBAR_RIGHT 11
  175. #define INDEX_SCROLLBAR_HORIZONTAL 6
  176. #define INDEX_SCROLLBAR_GRIP 12
  177. #define CHILDID_SELF 0
  178. #define INDEXID_OBJECT 0
  179. #define INDEXID_CONTAINER 0
  180. #ifndef WM_GETOBJECT
  181. #define WM_GETOBJECT 0x003D
  182. #endif
  183. #define MSAA_CLASSNAMEIDX_BASE 65536L
  184. #define MSAA_CLASSNAMEIDX_STATUS (MSAA_CLASSNAMEIDX_BASE+11)
  185. #define MSAA_CLASSNAMEIDX_TOOLBAR (MSAA_CLASSNAMEIDX_BASE+12)
  186. #define MSAA_CLASSNAMEIDX_PROGRESS (MSAA_CLASSNAMEIDX_BASE+13)
  187. #define MSAA_CLASSNAMEIDX_ANIMATE (MSAA_CLASSNAMEIDX_BASE+14)
  188. #define MSAA_CLASSNAMEIDX_TAB (MSAA_CLASSNAMEIDX_BASE+15)
  189. #define MSAA_CLASSNAMEIDX_HOTKEY (MSAA_CLASSNAMEIDX_BASE+16)
  190. #define MSAA_CLASSNAMEIDX_HEADER (MSAA_CLASSNAMEIDX_BASE+17)
  191. #define MSAA_CLASSNAMEIDX_TRACKBAR (MSAA_CLASSNAMEIDX_BASE+18)
  192. #define MSAA_CLASSNAMEIDX_LISTVIEW (MSAA_CLASSNAMEIDX_BASE+19)
  193. #define MSAA_CLASSNAMEIDX_UPDOWN (MSAA_CLASSNAMEIDX_BASE+22)
  194. #define MSAA_CLASSNAMEIDX_TOOLTIPS (MSAA_CLASSNAMEIDX_BASE+24)
  195. #define MSAA_CLASSNAMEIDX_TREEVIEW (MSAA_CLASSNAMEIDX_BASE+25)
  196. //
  197. // End BOGUS insertion from \win\core\access\inc32\winable.h
  198. //
  199. #ifdef MAXINT
  200. #undef MAXINT
  201. #endif
  202. #define MAXINT (int)0x7FFFFFFF
  203. // special value for pt.y or cyLabel indicating recomputation needed
  204. // NOTE: icon ordering code considers (RECOMPUTE, RECOMPUTE) at end
  205. // of all icons
  206. //
  207. #define RECOMPUTE (DWORD)MAXINT
  208. #define SRECOMPUTE ((short)0x7FFF)
  209. #define RECTWIDTH(rc) ((rc).right - (rc).left)
  210. #define RECTHEIGHT(rc) ((rc).bottom - (rc).top)
  211. #define ABS(i) (((i) < 0) ? -(i) : (i))
  212. #define BOUND(x,low,high) max(min(x, high),low)
  213. #define LPARAM_TO_POINT(lParam, pt) ((pt).x = LOWORD(lParam), \
  214. (pt).y = HIWORD(lParam))
  215. // common control info stuff
  216. typedef struct tagControlInfo {
  217. HWND hwnd;
  218. HWND hwndParent;
  219. DWORD style;
  220. DWORD dwCustom;
  221. BITBOOL bUnicode : 1;
  222. BITBOOL bInFakeCustomDraw:1;
  223. UINT uiCodePage;
  224. DWORD dwExStyle;
  225. LRESULT iVersion;
  226. WORD wUIState;
  227. } CONTROLINFO, FAR *LPCONTROLINFO;
  228. BOOL CCGetUIState(LPCONTROLINFO pControlInfo);
  229. BOOL CCNotifyNavigationKeyUsage(LPCONTROLINFO pControlInfo, WORD wFlag);
  230. BOOL NEAR PASCAL CCOnUIState(LPCONTROLINFO pCI, UINT uMessage, WPARAM wParam, LPARAM lParam);
  231. BOOL CCWndProc(CONTROLINFO* pci, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* plres);
  232. void FAR PASCAL CIInitialize(LPCONTROLINFO lpci, HWND hwnd, LPCREATESTRUCT lpcs);
  233. LRESULT FAR PASCAL CIHandleNotifyFormat(LPCONTROLINFO lpci, LPARAM lParam);
  234. DWORD NEAR PASCAL CICustomDrawNotify(LPCONTROLINFO lpci, DWORD dwStage, LPNMCUSTOMDRAW lpnmcd);
  235. DWORD CIFakeCustomDrawNotify(LPCONTROLINFO lpci, DWORD dwStage, LPNMCUSTOMDRAW lpnmcd);
  236. UINT RTLSwapLeftRightArrows(CONTROLINFO *pci, WPARAM wParam);
  237. UINT CCSwapKeys(WPARAM wParam, UINT vk1, UINT vk2);
  238. LPTSTR CCReturnDispInfoText(LPTSTR pszSrc, LPTSTR pszDest, UINT cchDest);
  239. void FillRectClr(HDC hdc, LPRECT prc, COLORREF clr);
  240. void CCCreateWindow();
  241. void CCDestroyWindow();
  242. //
  243. // helpers for drag-drop enabled controls
  244. //
  245. typedef LRESULT (*PFNDRAGCB)(HWND hwnd, UINT code, WPARAM wp, LPARAM lp);
  246. #define DPX_DRAGHIT (0) // WP = (unused) LP = POINTL* ret = item id
  247. #define DPX_GETOBJECT (1) // LP = nmobjectnotify ret = HRESULT
  248. #define DPX_SELECT (2) // WP = item id LP = DROPEFFECT_ ret = (unused)
  249. #define DPX_ENTER (3) // WP = (unused) LP = (unused) ret = BOOL
  250. #define DPX_LEAVE (4) // WP = (unused) LP = (unused) ret = (unused)
  251. // ddproxy.cpp
  252. DECLARE_HANDLE(HDRAGPROXY);
  253. STDAPI_(HDRAGPROXY) CreateDragProxy(HWND hwnd, PFNDRAGCB pfn, BOOL bRegister);
  254. STDAPI_(void) DestroyDragProxy(HDRAGPROXY hdp);
  255. STDAPI GetDragProxyTarget(HDRAGPROXY hdp, IDropTarget **ppdtgt);
  256. STDAPI GetItemObject(CONTROLINFO *, UINT, const IID *, LPNMOBJECTNOTIFY);
  257. #define SWAP(x,y, _type) { _type i; i = x; x = y; y = i; }
  258. //
  259. // This is for widened dispatch loop stuff
  260. //
  261. typedef MSG MSG32;
  262. typedef MSG32 FAR * LPMSG32;
  263. #define GetMessage32(lpmsg, hwnd, min, max, f32) GetMessage(lpmsg, hwnd, min, max)
  264. #define PeekMessage32(lpmsg, hwnd, min, max, flags, f32) PeekMessage(lpmsg, hwnd, min, max, flags)
  265. #define TranslateMessage32(lpmsg, f32) TranslateMessage(lpmsg)
  266. #define DispatchMessage32(lpmsg, f32) DispatchMessage(lpmsg)
  267. #define CallMsgFilter32(lpmsg, u, f32) CallMsgFilter(lpmsg, u)
  268. #define IsDialogMessage32(hwnd, lpmsg, f32) IsDialogMessage(hwnd, lpmsg)
  269. //
  270. // This is a very important piece of performance hack for non-DBCS codepage.
  271. //
  272. // was !defined(DBCS) || defined(UNICODE)
  273. // NB - These are already macros in Win32 land.
  274. #undef AnsiNext
  275. #undef AnsiPrev
  276. #define AnsiNext(x) ((x)+1)
  277. #define AnsiPrev(y,x) ((x)-1)
  278. #define IsDBCSLeadByte(x) ((x), FALSE)
  279. // FastCharNext and FastCharPrev are like CharNext and CharPrev except that
  280. // they don't check if you are at the beginning/end of the string.
  281. #define FastCharNext(pch) ((pch)+1)
  282. #define FastCharPrev(pchStart, pch) ((pch)-1)
  283. #define CH_PREFIX TEXT('&')
  284. #define lstrfns_StrEndN lstrfns_StrEndNW
  285. #define ChrCmpI ChrCmpIW
  286. BOOL ChrCmpIA(WORD w1, WORD wMatch);
  287. BOOL ChrCmpIW(WCHAR w1, WCHAR wMatch);
  288. void TruncateString(char *sz, int cch); // from strings.c
  289. void FAR PASCAL InitGlobalMetrics(WPARAM);
  290. void FAR PASCAL InitGlobalColors();
  291. BOOL FAR PASCAL InitToolbarClass(HINSTANCE hInstance);
  292. BOOL FAR PASCAL InitReBarClass(HINSTANCE hInstance);
  293. BOOL FAR PASCAL InitToolTipsClass(HINSTANCE hInstance);
  294. BOOL FAR PASCAL InitStatusClass(HINSTANCE hInstance);
  295. BOOL FAR PASCAL InitHeaderClass(HINSTANCE hInstance);
  296. BOOL FAR PASCAL InitButtonListBoxClass(HINSTANCE hInstance);
  297. BOOL FAR PASCAL InitTrackBar(HINSTANCE hInstance);
  298. BOOL FAR PASCAL InitUpDownClass(HINSTANCE hInstance);
  299. BOOL FAR PASCAL InitProgressClass(HINSTANCE hInstance);
  300. BOOL FAR PASCAL InitHotKeyClass(HINSTANCE hInstance);
  301. BOOL FAR PASCAL InitToolTips(HINSTANCE hInstance);
  302. BOOL FAR PASCAL InitDateClasses(HINSTANCE hinst);
  303. BOOL NEAR PASCAL ChildOfActiveWindow(HWND hwnd);
  304. /* cutils.c */
  305. HFONT CCGetHotFont(HFONT hFont, HFONT *phFontHot);
  306. HFONT CCCreateStatusFont(void);
  307. BOOL CCForwardEraseBackground(HWND hwnd, HDC hdc);
  308. void CCPlaySound(LPCTSTR lpszName);
  309. BOOL FAR PASCAL CheckForDragBegin(HWND hwnd, int x, int y);
  310. void FAR PASCAL NewSize(HWND hWnd, int nHeight, LONG style, int left, int top, int width, int height);
  311. BOOL FAR PASCAL MGetTextExtent(HDC hdc, LPCTSTR lpstr, int cnt, int FAR * pcx, int FAR * pcy);
  312. void FAR PASCAL RelayToToolTips(HWND hwndToolTips, HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam);
  313. void FAR PASCAL StripAccelerators(LPTSTR lpszFrom, LPTSTR lpszTo, BOOL fAmpOnly);
  314. UINT GetCodePageForFont (HFONT hFont);
  315. void* CCLocalReAlloc(void* p, UINT uBytes);
  316. LONG GetMessagePosClient(HWND hwnd, LPPOINT ppt);
  317. void FAR PASCAL FlipRect(LPRECT prc);
  318. DWORD SetWindowBits(HWND hWnd, int iWhich, DWORD dwBits, DWORD dwValue);
  319. BOOL CCDrawEdge(HDC hdc, LPRECT lprc, UINT edge, UINT flags, LPCOLORSCHEME lpclrsc);
  320. void CCInvalidateFrame(HWND hwnd);
  321. void FlipPoint(LPPOINT lppt);
  322. void CCSetInfoTipWidth(HWND hwndOwner, HWND hwndToolTips);
  323. #define CCResetInfoTipWidth(hwndOwner, hwndToolTips) \
  324. SendMessage(hwndToolTips, TTM_SETMAXTIPWIDTH, 0, -1)
  325. // Incremental search
  326. typedef struct ISEARCHINFO {
  327. int iIncrSearchFailed;
  328. LPTSTR pszCharBuf; // isearch string lives here
  329. int cbCharBuf; // allocated size of pszCharBuf
  330. int ichCharBuf; // number of live chars in pszCharBuf
  331. DWORD timeLast; // time of last input event
  332. #if defined(FE_IME)
  333. BOOL fReplaceCompChar;
  334. #endif
  335. } ISEARCHINFO, *PISEARCHINFO;
  336. #if defined(FE_IME)
  337. BOOL FAR PASCAL IncrementSearchImeCompStr(PISEARCHINFO pis, BOOL fCompStr, LPTSTR lpszCompChar, LPTSTR FAR *lplpstr);
  338. #endif
  339. BOOL FAR PASCAL IncrementSearchString(PISEARCHINFO pis, UINT ch, LPTSTR FAR *lplpstr);
  340. int FAR PASCAL GetIncrementSearchString(PISEARCHINFO pis, LPTSTR lpsz);
  341. int FAR PASCAL GetIncrementSearchStringA(PISEARCHINFO pis, UINT uiCodePage, LPSTR lpsz);
  342. void FAR PASCAL IncrementSearchBeep(PISEARCHINFO pis);
  343. #define IncrementSearchFree(pis) ((pis)->pszCharBuf ? Free((pis)->pszCharBuf) : 0)
  344. // For RTL mirroring use
  345. void MirrorBitmapInDC( HDC hdc , HBITMAP hbmOrig );
  346. // Locale manipulation (prsht.c)
  347. //
  348. // The "proper thread locale" is the thread locale we should
  349. // be using for our UI elements.
  350. //
  351. // If you need to change the thread locale temporarily
  352. // to the proper thread locale, use
  353. //
  354. // LCID lcidPrev;
  355. // CCSetProperThreadLocale(&lcidPrev);
  356. // munge munge munge
  357. // CCRestoreThreadLocale(lcidPrev);
  358. //
  359. // If you just want to retrieve the proper thread locale,
  360. // call CCGetProperThreadLocale(NULL).
  361. //
  362. //
  363. LCID CCGetProperThreadLocale(OPTIONAL LCID *plcidPrev);
  364. __inline void CCSetProperThreadLocale(LCID *plcidPrev) {
  365. SetThreadLocale(CCGetProperThreadLocale(plcidPrev));
  366. }
  367. #define CCRestoreThreadLocale(lcid) SetThreadLocale(lcid)
  368. int CCLoadStringExInternal(HINSTANCE hInst, UINT uID, LPWSTR lpBuffer, int nBufferMax, WORD wLang);
  369. int CCLoadStringEx(UINT uID, LPWSTR lpBuffer, int nBufferMax, WORD wLang);
  370. int LocalizedLoadString(UINT uID, LPWSTR lpBuffer, int nBufferMax);
  371. HRSRC FindResourceExRetry(HMODULE hmod, LPCTSTR lpType, LPCTSTR lpName, WORD wLang);
  372. // assign most unlikely used value for the fake sublang id
  373. #define SUBLANG_JAPANESE_ALTFONT 0x3f // max within 6bit
  374. // used to get resource lang of shell32
  375. #define DLG_EXITWINDOWS 1064
  376. //
  377. // Plug UI Setting funcions (commctrl.c)
  378. //
  379. LANGID WINAPI GetMUILanguage(void);
  380. //
  381. // Tooltip thunking api's
  382. //
  383. BOOL ThunkToolTipTextAtoW (LPTOOLTIPTEXTA lpTttA, LPTOOLTIPTEXTW lpTttW, UINT uiCodePage);
  384. HWND GetDlgItemRect(HWND hDlg, int nIDItem, LPRECT prc);
  385. //
  386. // Global variables
  387. //
  388. extern HINSTANCE g_hinst;
  389. extern UINT uDragListMsg;
  390. extern int g_iIncrSearchFailed;
  391. #define g_bRunOnNT TRUE
  392. #define g_bRunOnMemphis FALSE
  393. extern BOOL g_bRunOnNT5;
  394. extern BOOL g_bRemoteSession;
  395. extern UINT g_uiACP;
  396. //
  397. // Is Mirroring APIs enabled (BiDi Memphis and NT5 only)
  398. //
  399. extern BOOL g_bMirroredOS;
  400. #ifdef FONT_LINK
  401. extern BOOL g_bComplexPlatform;
  402. #endif
  403. //
  404. // Icon mirroring stuff
  405. //
  406. extern HDC g_hdc;
  407. extern HDC g_hdcMask;
  408. #define HINST_THISDLL g_hinst
  409. #ifdef DEBUG
  410. #undef SendMessage
  411. #define SendMessage SendMessageD
  412. #ifdef __cplusplus
  413. extern "C"
  414. {
  415. #endif
  416. LRESULT WINAPI SendMessageD(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
  417. int WINAPI Str_GetPtr0(LPCTSTR pszCurrent, LPTSTR pszBuf, int cchBuf);
  418. #ifdef __cplusplus
  419. }
  420. #endif
  421. #else // !DEBUG
  422. #define Str_GetPtr0 Str_GetPtr
  423. #endif // DEBUG / !DEBUG
  424. // REVIEW, should this be a function? (inline may generate a lot of code)
  425. #define CBBITMAPBITS(cx, cy, cPlanes, cBitsPerPixel) \
  426. (((((cx) * (cBitsPerPixel) + 15) & ~15) >> 3) \
  427. * (cPlanes) * (cy))
  428. #define WIDTHBYTES(cx, cBitsPerPixel) \
  429. ((((cx) * (cBitsPerPixel) + 31) / 32) * 4)
  430. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0])) /* ;Internal */
  431. #define InRange(id, idFirst, idLast) ((UINT)((id)-(idFirst)) <= (UINT)((idLast)-(idFirst)))
  432. void FAR PASCAL ColorDitherBrush_OnSysColorChange();
  433. extern HBRUSH g_hbrMonoDither; // gray dither brush from image.c
  434. void FAR PASCAL InitDitherBrush();
  435. void FAR PASCAL TerminateDitherBrush();
  436. #ifndef DT_NOFULLWIDTHCHARBREAK
  437. #define DT_NOFULLWIDTHCHARBREAK 0x00080000
  438. #endif // DT_NOFULLWIDTHCHARBREAK
  439. #define SHDT_DRAWTEXT 0x0001
  440. #define SHDT_ELLIPSES 0x0002
  441. #define SHDT_CLIPPED 0x0004
  442. #define SHDT_SELECTED 0x0008
  443. #define SHDT_DESELECTED 0x0010
  444. #define SHDT_DEPRESSED 0x0020
  445. #define SHDT_EXTRAMARGIN 0x0040
  446. #define SHDT_TRANSPARENT 0x0080
  447. #define SHDT_SELECTNOFOCUS 0x0100
  448. #define SHDT_HOTSELECTED 0x0200
  449. #define SHDT_DTELLIPSIS 0x0400
  450. #define SHDT_RTLREADING 0x0800
  451. #define SHDT_NODBCSBREAK 0x1000
  452. void WINAPI SHDrawText(HDC hdc, LPCTSTR pszText, RECT FAR* prc,
  453. int fmt, UINT flags, int cyChar, int cxEllipses,
  454. COLORREF clrText, COLORREF clrTextBk);
  455. // notify.c
  456. LRESULT WINAPI CCSendNotify(CONTROLINFO * pci, int code, LPNMHDR pnm);
  457. BOOL CCReleaseCapture(CONTROLINFO * pci);
  458. // treeview.c, listview.c for FE_IME code
  459. LPTSTR GET_COMP_STRING(HIMC hImc, DWORD dwFlags);
  460. // lvicon.c in-place editing
  461. #define SEIPS_WRAP 0x0001
  462. #ifdef DEBUG
  463. #define SEIPS_NOSCROLL 0x0002 // Flag is used only in DEBUG
  464. #endif
  465. void FAR PASCAL SetEditInPlaceSize(HWND hwndEdit, RECT FAR *prc, HFONT hFont, UINT seips);
  466. HWND FAR PASCAL CreateEditInPlaceWindow(HWND hwnd, LPCTSTR lpText, int cbText, LONG style, HFONT hFont);
  467. void RescrollEditWindow(HWND hwndEdit);
  468. // Global System metrics.
  469. extern int g_cxEdge;
  470. extern int g_cyEdge;
  471. extern int g_cxBorder;
  472. extern int g_cyBorder;
  473. extern int g_cxScreen;
  474. extern int g_cyScreen;
  475. extern int g_cxDoubleClk;
  476. extern int g_cyDoubleClk;
  477. extern int g_cxSmIcon;
  478. extern int g_cySmIcon;
  479. //extern int g_cxIcon;
  480. //extern int g_cyIcon;
  481. extern int g_cxFrame;
  482. extern int g_cyFrame;
  483. extern int g_cxIconSpacing, g_cyIconSpacing;
  484. extern int g_cxScrollbar, g_cyScrollbar;
  485. extern int g_cxIconMargin, g_cyIconMargin;
  486. extern int g_cyLabelSpace;
  487. extern int g_cxLabelMargin;
  488. //extern int g_cxIconOffset, g_cyIconOffset;
  489. extern int g_cxVScroll;
  490. extern int g_cyHScroll;
  491. extern int g_cxHScroll;
  492. extern int g_cyVScroll;
  493. extern int g_fDragFullWindows;
  494. extern int g_fDBCSEnabled;
  495. extern int g_fMEEnabled;
  496. extern int g_fDBCSInputEnabled;
  497. extern COLORREF g_clrWindow;
  498. extern COLORREF g_clrWindowText;
  499. extern COLORREF g_clrWindowFrame;
  500. extern COLORREF g_clrGrayText;
  501. extern COLORREF g_clrBtnText;
  502. extern COLORREF g_clrBtnFace;
  503. extern COLORREF g_clrBtnShadow;
  504. extern COLORREF g_clrBtnHighlight;
  505. extern COLORREF g_clrHighlight;
  506. extern COLORREF g_clrHighlightText;
  507. extern COLORREF g_clrInfoText;
  508. extern COLORREF g_clrInfoBk;
  509. extern COLORREF g_clr3DDkShadow;
  510. extern COLORREF g_clr3DLight;
  511. extern HBRUSH g_hbrGrayText;
  512. extern HBRUSH g_hbrWindow;
  513. extern HBRUSH g_hbrWindowText;
  514. extern HBRUSH g_hbrWindowFrame;
  515. extern HBRUSH g_hbrBtnFace;
  516. extern HBRUSH g_hbrBtnHighlight;
  517. extern HBRUSH g_hbrBtnShadow;
  518. extern HBRUSH g_hbrHighlight;
  519. extern HFONT g_hfontSystem;
  520. #define WHEEL_DELTA 120
  521. extern UINT g_msgMSWheel;
  522. extern UINT g_ucScrollLines;
  523. extern int gcWheelDelta;
  524. extern UINT g_uDragImages;
  525. #ifdef __cplusplus
  526. }
  527. #endif // __cplusplus
  528. typedef LRESULT (CALLBACK *SUBCLASSPROC)(HWND hWnd, UINT uMsg, WPARAM wParam,
  529. LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
  530. STDAPI_(BOOL) WINAPI SetWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uIdSubclass,
  531. DWORD_PTR dwRefData);
  532. STDAPI_(BOOL) WINAPI GetWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uIdSubclass,
  533. DWORD_PTR *pdwRefData);
  534. STDAPI_(BOOL) WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass,
  535. UINT_PTR uIdSubclass);
  536. STDAPI_(LRESULT) WINAPI DefSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  537. #define CDIS_SHOWKEYBOARDCUES 0x0200
  538. // TRACE FLAGS
  539. //
  540. #define TF_MONTHCAL 0x00000100 // MonthCal and DateTimePick
  541. #define TF_BKIMAGE 0x00000200 // ListView background image
  542. #define TF_TOOLBAR 0x00000400 // Toolbar stuff
  543. #define TF_PAGER 0x00000800 // Pager Stuff
  544. #define TF_REBAR 0x00001000 // Rebar
  545. #define TF_LISTVIEW 0x00002000 // Listview
  546. #define TF_TREEVIEW 0x00004000 // Treeview
  547. #define TF_STATUS 0x00008000 // Status bar
  548. // Prototype flags
  549. #define PTF_FLATLOOK 0x00000001 // Overall flatlook
  550. #define PTF_NOISEARCHTO 0x00000002 // No incremental search timeout
  551. #include <platform.h>
  552. // Dummy union macros for code compilation on platforms not
  553. // supporting nameless stuct/union
  554. #ifdef NONAMELESSUNION
  555. #define DUMMYUNION_MEMBER(member) DUMMYUNIONNAME.member
  556. #define DUMMYUNION2_MEMBER(member) DUMMYUNIONNAME2.member
  557. #define DUMMYUNION3_MEMBER(member) DUMMYUNIONNAME3.member
  558. #define DUMMYUNION4_MEMBER(member) DUMMYUNIONNAME4.member
  559. #define DUMMYUNION5_MEMBER(member) DUMMYUNIONNAME5.member
  560. #else
  561. #define DUMMYUNION_MEMBER(member) member
  562. #define DUMMYUNION2_MEMBER(member) member
  563. #define DUMMYUNION3_MEMBER(member) member
  564. #define DUMMYUNION4_MEMBER(member) member
  565. #define DUMMYUNION5_MEMBER(member) member
  566. #endif
  567. #define ALLOC_NULLHEAP(heap, size) Alloc( size )
  568. #define COLOR_STRUCT DWORD
  569. #define QUAD_PART(a) ((a)##.QuadPart)