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.

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