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.

1710 lines
57 KiB

  1. /*
  2. * _w32sys.h
  3. *
  4. * Purpose:
  5. * Isolate various Win 32 system dependencies.
  6. *
  7. * Copyright (c) 1995-2000, Microsoft Corporation. All rights reserved.
  8. */
  9. #ifndef _W32SYS_H
  10. #define _W32SYS_H
  11. #ifndef NOFEPROCESSING
  12. #define OBSOLETE // need this to get old IMEShare defines
  13. #include "imeshare.h"
  14. #else
  15. // Some class declarations to keep the compiler happy
  16. struct IMESTYLE;
  17. struct IMECOLORSTY;
  18. struct CIMEShare;
  19. #endif
  20. #include "_array.h"
  21. #ifndef THICKCARET
  22. #define duCaret 1
  23. #else
  24. #define duCaret 2
  25. #endif
  26. #ifdef LIMITEDMEMORY
  27. #define FONTCACHESIZE 8
  28. #define CCSHASHSEARCHSIZE 15
  29. #define DEFAULT_UNDO_SIZE 20
  30. #else
  31. #define FONTCACHESIZE 24
  32. #define CCSHASHSEARCHSIZE 31
  33. #define DEFAULT_UNDO_SIZE 100
  34. #endif
  35. #ifdef SLOWCPU
  36. #define NUMPASTECHARSWAITCURSOR 1024
  37. #else
  38. #define NUMPASTECHARSWAITCURSOR (1024*32)
  39. #endif
  40. #ifndef NOMEMORYH
  41. #include "memory.h" // for memmove
  42. #endif
  43. #define RSHIFT 1
  44. #define LSHIFT 2
  45. #define RCTRL 0x10
  46. #define LCTRL 0x20
  47. #define RALT 0x40
  48. #define LALT 0x80
  49. #define SHIFT (RSHIFT + LSHIFT)
  50. #define ALT (RALT + LALT)
  51. #define CTRL (RCTRL + LCTRL)
  52. #define HOTEURO 0x1000
  53. #define ALT0 0x2000
  54. #define ALTNUMPAD 0x4000
  55. #define LETAFTERSHIFT 0x8000
  56. // special virtual keys copied from Japan MSVC ime.h
  57. #define VK_KANA 0x15
  58. #define VK_KANJI 0x19
  59. // Initialization flags that can be used in system.ini for testing purposes
  60. #define SYSINI_USELS 0x1
  61. #define SYSINI_BIDI 0x2
  62. #define SYSINI_USEAIMM 0x4
  63. #define SYSINI_DEBUGFONT 0x8
  64. #define SYSINI_DEBUGGCF125X 0x10
  65. #define SYSINI_USECTF 0x20
  66. /*
  67. * GetCaretDelta ()
  68. *
  69. * @func Get size of caret to add to current caret position to get the
  70. * maximum extent needed to display caret.
  71. *
  72. * @rdesc Size of caret over 1 pixel
  73. *
  74. * @devnote This exists solely to abstract this calculation
  75. * to handle a variable size caret.
  76. */
  77. inline int GetCaretDelta()
  78. {
  79. return duCaret - 1;
  80. }
  81. // Used in rtfread.cpp to keep track of lossy rtf.
  82. #ifdef PWORD_CONVERTER_V2
  83. #define REPORT_LOSSAGE
  84. #endif
  85. //Windows CE defines which need to be before their function declarations
  86. #ifdef UNDER_CE
  87. typedef struct tagKERNINGPAIR {
  88. WORD wFirst;
  89. WORD wSecond;
  90. int iKernAmount;
  91. } KERNINGPAIR, *LPKERNINGPAIR;
  92. #endif
  93. // Defines for some Codepages
  94. #define CP_JAPAN 932
  95. #define CP_KOREAN 949
  96. #define CP_CHINESE_TRAD 950
  97. #define CP_CHINESE_SIM 936
  98. #define CP_HEBREW 1255
  99. #define CP_ARABIC 1256
  100. #define CP_THAI 874
  101. #define CP_VIETNAMESE 1258
  102. #define CP_ULE 1200 // Unicode
  103. #define CP_UBE 1201
  104. #define IsUnicodeCP(cp) (((cp) & ~1) == CP_ULE)
  105. // Newly introduced Indic language ID
  106. #if(WINVER < 0x500)
  107. #define LANG_HINDI 0x39
  108. #define LANG_KONKANI 0x57
  109. #define LANG_NEPALI 0x61
  110. #define LANG_BENGALI 0x45
  111. #define LANG_PUNJABI 0x46
  112. #define LANG_GUJARATHI 0x47
  113. #define LANG_ORIYA 0x48
  114. #define LANG_TAMIL 0x49
  115. #define LANG_TELUGU 0x4a
  116. #define LANG_KANNADA 0x4b
  117. #define LANG_MALAYALAM 0x4c
  118. #define LANG_ASSAMESE 0x4d
  119. #define LANG_MARATHI 0x4e
  120. #define LANG_SANSKRIT 0x4f
  121. #endif
  122. // Other possibly missing defines
  123. #ifndef LANG_THAI
  124. #define LANG_THAI 0x1e
  125. #endif
  126. #define ANSI_INDEX 0 // Keep these indices in sync
  127. #define EASTEUROPE_INDEX 1 // with rgCodePage[] and
  128. #define RUSSIAN_INDEX 2 // rgCharSet[] if entries
  129. #define GREEK_INDEX 3 // exist in these arrays.
  130. #define TURKISH_INDEX 4
  131. #define HEBREW_INDEX 5
  132. #define ARABIC_INDEX 6
  133. #define BALTIC_INDEX 7
  134. #define VIET_INDEX 8
  135. #define DEFAULT_INDEX 9
  136. #define SYMBOL_INDEX 10
  137. #define THAI_INDEX 11
  138. #define SHIFTJIS_INDEX 12
  139. #define GB2312_INDEX 13
  140. #define HANGUL_INDEX 14
  141. #define BIG5_INDEX 15
  142. #define PC437_INDEX 16
  143. #define OEM_INDEX 17
  144. #define MAC_INDEX 18
  145. #define NCHARSETS 19 // Size of charset-oriented tables
  146. #define ARMENIAN_INDEX 19 // Start of Unicode-only repertoires
  147. #define SYRIAC_INDEX 20
  148. #define THAANA_INDEX 21
  149. #define DEVANAGARI_INDEX 22
  150. #define BENGALI_INDEX 23
  151. #define GURMUKHI_INDEX 24
  152. #define GUJARATI_INDEX 25
  153. #define ORIYA_INDEX 26
  154. #define TAMIL_INDEX 27
  155. #define TELUGU_INDEX 28
  156. #define KANNADA_INDEX 29
  157. #define MALAYALAM_INDEX 30
  158. #define SINHALA_INDEX 31
  159. #define LAO_INDEX 32
  160. #define TIBETAN_INDEX 33
  161. #define MYANMAR_INDEX 34
  162. #define GEORGIAN_INDEX 35
  163. #define JAMO_INDEX 36
  164. #define ETHIOPIC_INDEX 37
  165. #define CHEROKEE_INDEX 38
  166. #define ABORIGINAL_INDEX 39
  167. #define OGHAM_INDEX 40
  168. #define RUNIC_INDEX 41
  169. #define KHMER_INDEX 42
  170. #define MONGOLIAN_INDEX 43
  171. #define BRAILLE_INDEX 44
  172. #define YI_INDEX 45
  173. // Keep next four in same order as
  174. #define JPN2_INDEX 46 // SHIFTJIS_INDEX to BIG5_INDEX
  175. #define CHS2_INDEX 47
  176. #define KOR2_INDEX 48
  177. #define CHT2_INDEX 49
  178. #define NCHARREPERTOIRES 50 // Size of keyboard and font-binding tables
  179. #define INDIC_FIRSTINDEX DEVANAGARI_INDEX
  180. #define INDIC_LASTINDEX SINHALA_INDEX
  181. #define PC437_CHARSET 254
  182. // Flags which can be passed down to REExtTextOut
  183. // The low 2 bits are reserved for passing down the TFLOW of the text
  184. const DWORD fETOFEFontOnNonFEWin9x = 0x04;
  185. const DWORD fETOCustomTextOut = 0x08;
  186. #define IsSymbolOrOEMCharRep(x) (x == SYMBOL_INDEX || x == OEM_INDEX)
  187. enum CC
  188. {
  189. CC_ARABIC,
  190. CC_HEBREW,
  191. CC_RTL,
  192. CC_LTR,
  193. CC_EOP,
  194. CC_ASCIIDIGIT,
  195. CC_NEUTRAL
  196. };
  197. #define IsRTL(cc) (cc <= CC_RTL)
  198. const SHORT sLanguageEnglishUS = 0x0409;
  199. const SHORT sLanguageMask = 0x03ff;
  200. const SHORT sLanguageArabic = 0x0401;
  201. const SHORT sLanguageHebrew = 0x040d;
  202. // FUTURE: currently this const == sLanguageEnglishUS
  203. // for no reason except that it was this way
  204. // in RE1.0 BiDi. Consider changing, or sticking
  205. // the real language in, and changing the logic
  206. // of handling wLang a bit.
  207. const SHORT sLanguageNonBiDi = 0x0409;
  208. // Logical unit definition
  209. const int LX_PER_INCH = 1440;
  210. const int LY_PER_INCH = 1440;
  211. // HIMETRIC units per inch (used for conversion)
  212. const int HIMETRIC_PER_INCH = 2540;
  213. #if defined(DEBUG)
  214. void* __cdecl operator new(size_t nSize, char *szFile, int nLine);
  215. #define NEW_DEBUG new(__FILE__, __LINE__)
  216. #define new NEW_DEBUG
  217. void UpdateMst(void);
  218. struct MST
  219. {
  220. char *szFile;
  221. int cbAlloc;
  222. }; //Memory Statistics;
  223. extern MST vrgmst[];
  224. #endif //DEBUG
  225. #ifdef CopyMemory
  226. #undef CopyMemory
  227. #endif
  228. #ifdef MoveMemory
  229. #undef MoveMemory
  230. #endif
  231. #ifdef FillMemory
  232. #undef FillMemory
  233. #endif
  234. #ifdef ZeroMemory
  235. #undef ZeroMemory
  236. #endif
  237. #ifdef CompareMemory
  238. #undef CompareMemory
  239. #endif
  240. #ifndef KF_ALTDOWN
  241. #define KF_ALTDOWN 0x2000
  242. #endif
  243. // Use for our version of ExtTextOut
  244. enum CONVERTMODE
  245. {
  246. CVT_NONE, // Use Unicode (W) CharWidth/TextOut APIs
  247. CVT_WCTMB, // Convert to MBCS using WCTMB and _wCodePage
  248. CVT_LOWBYTE // Use low byte of 16-bit chars (for SYMBOL_CHARSET
  249. }; // and when code page isn't installed)
  250. // Opaque Type
  251. class CTxtSelection;
  252. class CTxtEdit;
  253. class CCharFormat;
  254. class CCcs;
  255. enum UN_FLAGS
  256. {
  257. UN_NOOBJECTS = 1,
  258. UN_CONVERT_WCH_EMBEDDING = 2
  259. };
  260. #undef GetStringTypeEx
  261. #undef CharLower
  262. #undef CharLowerBuff
  263. #undef CharUpperBuff
  264. #undef CreateIC
  265. #undef CreateFile
  266. #undef CreateFontIndirect
  267. #undef CompareString
  268. #undef DefWindowProc
  269. #undef GetKeyboardLayout
  270. #undef GetProfileSection
  271. #undef GetKerningPairs
  272. #undef GetTextMetrics
  273. #undef GetTextFace
  274. #undef GetWindowLong
  275. #undef GetWindowLongPtr
  276. #undef GetClassLong
  277. #undef LoadBitmap
  278. #undef LoadCursor
  279. #undef LoadLibrary
  280. #undef SendMessage
  281. #undef SetWindowLong
  282. #undef SetWindowLongPtr
  283. #undef PostMessage
  284. #undef lstrcmp
  285. #undef lstrcmpi
  286. #undef PeekMessage
  287. #undef GetModuleFileName
  288. #undef GlobalAlloc
  289. #undef GlobalFree
  290. #undef GlobalFlags
  291. #undef GlobalReAlloc
  292. #undef GlobalLock
  293. #undef GlobalHandle
  294. #undef GlobalUnlock
  295. #undef GlobalSize
  296. // Bits used in _fFEFontInfo:
  297. #define JPN_FONT_AVAILABLE 0x0001 // True if Jpn font is available
  298. #define KOR_FONT_AVAILABLE 0x0002 // True if Kor font is available
  299. #define BIG5_FONT_AVAILABLE 0x0004 // True if Trad. Chinese font is available
  300. #define GB_FONT_AVAILABLE 0x0008 // True if Simplified Chinese font is available
  301. #define FEUSER_LCID 0x0010 // True if User LCID is FE LCID
  302. #define FEUSER_CODEPAGE 0x0060 // indicate which User FE codepage its
  303. #define FEUSER_CP_JPN 0x0000 // =00 for JPN
  304. #define FEUSER_CP_KOR 0x0020 // =20 for KOR
  305. #define FEUSER_CP_BIG5 0x0040 // =40 for BIG5
  306. #define FEUSER_CP_GB 0x0060 // =60 for GB
  307. #define FEDATA_NOT_INIT 0xFFFF // No data yet
  308. class CConvertStrW
  309. {
  310. public:
  311. operator WCHAR *();
  312. protected:
  313. CConvertStrW();
  314. ~CConvertStrW();
  315. void Free();
  316. LPWSTR _pwstr;
  317. WCHAR _awch[MAX_PATH * 2];
  318. };
  319. inline CConvertStrW::CConvertStrW()
  320. {
  321. _pwstr = NULL;
  322. }
  323. inline CConvertStrW::~CConvertStrW()
  324. {
  325. Free();
  326. }
  327. inline CConvertStrW::operator WCHAR *()
  328. {
  329. return _pwstr;
  330. }
  331. class CStrInW : public CConvertStrW
  332. {
  333. public:
  334. CStrInW(LPCSTR pstr);
  335. CStrInW(LPCSTR pstr, UINT uiCodePage);
  336. CStrInW(LPCSTR pstr, int cch, UINT uiCodePage);
  337. int strlen();
  338. protected:
  339. CStrInW();
  340. void Init(LPCSTR pstr, int cch, UINT uiCodePage);
  341. int _cwchLen;
  342. UINT _uiCodePage;
  343. };
  344. inline CStrInW::CStrInW()
  345. {
  346. }
  347. inline int CStrInW::strlen()
  348. {
  349. return _cwchLen;
  350. }
  351. // Mask bit for temp display Attributes
  352. #define APPLY_TMP_FORECOLOR 0x0001 // Apply temp. text color
  353. #define APPLY_TMP_BACKCOLOR 0x0002 // Apply temp. background color
  354. // Actions for GetTmpColor
  355. #define GET_TEMP_TEXT_COLOR 1
  356. #define GET_TEMP_BACK_COLOR 2
  357. #define GET_TEMP_UL_COLOR 3
  358. typedef struct _tmpDispAttrib
  359. {
  360. WORD wMask; // Mask for temp display Attributes
  361. BYTE bUnderlineType; // Temp Underline type
  362. COLORREF crTextColor; // Temp Foreground color
  363. COLORREF crBackColor; // Temp Background color
  364. COLORREF crUnderlineColor; // Temp Underline color
  365. } TMPDISPLAYATTR;
  366. class CTmpDisplayAttrArray : public CArray<TMPDISPLAYATTR>
  367. {
  368. public:
  369. CTmpDisplayAttrArray() {};
  370. ~CTmpDisplayAttrArray() {};
  371. };
  372. typedef DWORD (WINAPI* PFN_GETLAYOUT)(HDC);
  373. typedef DWORD (WINAPI* PFN_SETLAYOUT)(HDC, DWORD);
  374. #ifdef wcsicmp
  375. #undef wcsicmp
  376. #endif
  377. class CW32System
  378. {
  379. private :
  380. static DWORD _dwPlatformId; // platform GetVersionEx();
  381. static LCID _syslcid;
  382. public :
  383. static CIMEShare *_pIMEShare;
  384. static UINT _fRegisteredXBox; // flag indicating if listbox and combobox were registered
  385. static DWORD _dwMajorVersion; // major version from GetVersionEx()
  386. static DWORD _dwMinorVersion; // minor version from GetVersionEx()
  387. static INT _icr3DDarkShadow; // value to use for COLOR_3DDKSHADOW
  388. static UINT _MSIMEMouseMsg; // mouse operation
  389. static UINT _MSIMEReconvertMsg; // reconversion
  390. static UINT _MSIMEReconvertRequestMsg; // reconversion request
  391. static UINT _MSIMEDocFeedMsg; // document feed
  392. static UINT _MSIMEQueryPositionMsg; // query position
  393. static UINT _MSIMEServiceMsg; // checking MSIME98 or later
  394. static UINT _MSMouseRoller; // mouse scrolling
  395. // Misc flags used for more precise character classification
  396. static WORD _fFEFontInfo;
  397. static BYTE _fLRMorRLM;
  398. // Misc flags used for FE
  399. static BYTE _fHaveIMMProcs;
  400. static BYTE _fHaveAIMM;
  401. static BYTE _fHaveIMMEShare;
  402. static BYTE _fLoadAIMM10;
  403. static CTmpDisplayAttrArray *_arTmpDisplayAttrib;
  404. CW32System();
  405. ~CW32System();
  406. static DWORD AddRef();
  407. static DWORD Release();
  408. // Platform testing
  409. static bool OnWinNTFE()
  410. {
  411. return _dwPlatformId == VER_PLATFORM_WIN32_NT && IsFELCID(_syslcid );
  412. }
  413. static bool OnWinNTNonFE()
  414. {
  415. return _dwPlatformId == VER_PLATFORM_WIN32_NT && !IsFELCID(_syslcid );
  416. }
  417. static bool OnWinNT5()
  418. {
  419. return _dwPlatformId == VER_PLATFORM_WIN32_NT && 5 == _dwMajorVersion;
  420. }
  421. static bool OnWinNT4()
  422. {
  423. return _dwPlatformId == VER_PLATFORM_WIN32_NT && 4 == _dwMajorVersion;
  424. }
  425. static bool OnWin9xFE()
  426. {
  427. return _dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && IsFELCID(_syslcid );
  428. }
  429. static bool OnWin9x()
  430. {
  431. return _dwPlatformId == VER_PLATFORM_WIN32_WINDOWS;
  432. }
  433. static bool OnWin95()
  434. {
  435. return OnWin9x() && (4 == _dwMajorVersion) && (0 == _dwMinorVersion);
  436. }
  437. static bool OnWin95FE()
  438. {
  439. return OnWin95() && IsFELCID(_syslcid );
  440. }
  441. static bool OnWin9xThai()
  442. {
  443. return _dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && PRIMARYLANGID(_syslcid) == LANG_THAI;
  444. }
  445. static bool OnWin9xBiDi()
  446. {
  447. return _dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && IsBiDiLcid(_syslcid);
  448. }
  449. static bool OnBiDiOS()
  450. {
  451. return IsBiDiLcid(_syslcid) != 0;
  452. }
  453. struct WM_CHAR_INFO
  454. {
  455. bool _fAccumulate;
  456. bool _fLeadByte;
  457. bool _fTrailByte;
  458. bool _fIMEChar;
  459. };
  460. static UINT GetACP() {return _ACP;}
  461. static LCID GetSysLCID() {return _syslcid;}
  462. #ifndef NOANSIWINDOWS
  463. static LRESULT ANSIWndProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, BOOL fIs10Mode );
  464. static void AnsiFilter( UINT &msg, WPARAM &wparam, LPARAM lparam, void *pvoid, BOOL fIs10Mode = FALSE );
  465. #endif
  466. static HGLOBAL WINAPI GlobalAlloc( UINT uFlags, DWORD dwBytes );
  467. static HGLOBAL WINAPI GlobalFree( HGLOBAL hMem );
  468. static UINT WINAPI GlobalFlags( HGLOBAL hMem );
  469. static HGLOBAL WINAPI GlobalReAlloc( HGLOBAL hMem, DWORD dwBytes, UINT uFlags );
  470. static DWORD WINAPI GlobalSize( HGLOBAL hMem );
  471. static PVOID WINAPI GlobalLock( HGLOBAL hMem );
  472. static HGLOBAL WINAPI GlobalHandle( LPCVOID pMem );
  473. static BOOL WINAPI GlobalUnlock( HGLOBAL hMem );
  474. static void WINAPI REGetCharWidth(
  475. HDC hdc,
  476. WCHAR ch,
  477. INT *pdxp,
  478. UINT uiCodePage,
  479. BOOL fCustomTextOut);
  480. static DWORD WINAPI GetKerningPairs(HDC hdc, DWORD ckp, KERNINGPAIR *pkp);
  481. static void EraseTextOut(HDC hdc, const RECT *prc);
  482. static void WINAPI REExtTextOut(
  483. CONVERTMODE cm,
  484. UINT uiCodePage,
  485. HDC hdc,
  486. int x,
  487. int y,
  488. UINT fuOptions,
  489. CONST RECT *lprc,
  490. const WCHAR *lpString,
  491. UINT cch,
  492. CONST INT *lpDx,
  493. DWORD dwETOFlags);
  494. static CONVERTMODE WINAPI DetermineConvertMode( HDC hdc, BYTE tmCharSet );
  495. static void WINAPI CalcUnderlineInfo(HDC hdc, CCcs *pccs, TEXTMETRIC *ptm );
  496. static BOOL WINAPI EnableScrollBar( HWND hWnd, UINT wSBflags, UINT wArrows );
  497. static BOOL WINAPI ShowScrollBar( HWND hWnd, int wBar, BOOL bShow, LONG nMax );
  498. static BOOL WINAPI IsEnhancedMetafileDC( HDC hdc );
  499. static HPALETTE WINAPI ManagePalette(
  500. HDC hdc,
  501. CONST LOGPALETTE *plogpal,
  502. HPALETTE &hpalOld,
  503. HPALETTE &hpalNew
  504. );
  505. static UINT WINAPI SetTextAlign(
  506. HDC hdc,
  507. UINT fMode
  508. );
  509. static BOOL WINAPI InvertRect(
  510. HDC hdc,
  511. CONST RECT *lprc
  512. );
  513. static BOOL PtInRect(const RECT *prc, POINT pt)
  514. {
  515. return ::PtInRect(prc, pt);
  516. }
  517. static BOOL PtInRect(const RECTUV *prc, POINTUV pt)
  518. {
  519. POINT ptxy = {pt.u, pt.v};
  520. return ::PtInRect((RECT*) prc, ptxy);
  521. }
  522. static void InflateRect(RECT *prc, int dxp, int dyp)
  523. {
  524. ::InflateRect(prc, dxp, dyp);
  525. }
  526. static void InflateRect(RECTUV *prc, int dup, int dvp)
  527. {
  528. ::InflateRect((RECT*) prc, dup, dvp);
  529. }
  530. static BOOL IntersectRect(RECT *prcDest, CONST RECT *prc1, CONST RECT *prc2)
  531. {
  532. return ::IntersectRect(prcDest, prc1, prc2);
  533. }
  534. static BOOL IntersectRect(RECTUV *prcDest, CONST RECTUV *prc1, CONST RECTUV *prc2)
  535. {
  536. return ::IntersectRect((RECT*) prcDest, (RECT*) prc1, (RECT*) prc2);
  537. }
  538. static void GetFacePriCharSet(HDC hdc, LOGFONT* plf);
  539. static BOOL WINAPI WinLPtoDP(HDC hdc, LPPOINT lppoints, int nCount);
  540. static BOOL WINAPI WinDPtoLP(HDC hdc, LPPOINT lppoints, int nCount);
  541. static long WINAPI WvsprintfA(LONG cb, LPSTR szBuf, LPCSTR szFmt, va_list arglist);
  542. static int WINAPI MulDivFunc(int nNumber, int nNumerator, int nDenominator);
  543. static inline LONG HimetricToDevice(LONG z, LONG dzpInch)
  544. {
  545. return MulDivFunc(z, dzpInch, HIMETRIC_PER_INCH);
  546. }
  547. static inline LONG DeviceToHimetric(LONG z, LONG dzpInch)
  548. {
  549. return MulDivFunc(z, HIMETRIC_PER_INCH, dzpInch);
  550. }
  551. //
  552. // Case insensitive ASCII compare
  553. //
  554. static BOOL ASCIICompareI( const BYTE *pstr1, const BYTE *pstr2, int iCount )
  555. {
  556. int i;
  557. for (i = 0; i < iCount && !((pstr1[i] ^ pstr2[i]) & ~0x20); i++)
  558. ;
  559. return i == iCount;
  560. }
  561. //
  562. // Allocate and convert a MultiByte string to a wide character string
  563. // Allocated strings must be freed with delete
  564. //
  565. static WCHAR *ConvertToWideChar( const char *pstr )
  566. {
  567. int istrlen = 0;
  568. if(pstr)
  569. for (istrlen; pstr[istrlen]; istrlen++);
  570. WCHAR *pnew = new WCHAR[istrlen + 1];
  571. if(pnew && (!pstr || 0 != ::MultiByteToWideChar(
  572. CP_ACP, 0, pstr, -1, pnew, istrlen + 1)))
  573. {
  574. return pnew;
  575. }
  576. return NULL;
  577. }
  578. //
  579. // functions for memory and string management
  580. //
  581. #ifdef DEBUG
  582. static void PvSet(void *pv, char *szFile, int line);
  583. static PVOID PvAllocDebug(ULONG cbBuf, UINT uiMemFlags, char *szFile, int line);
  584. static PVOID PvReAllocDebug(PVOID pvBuf, DWORD cbBuf, char *szFile, int line);
  585. static void FreePvDebug(PVOID pvBuf);
  586. #endif
  587. static PVOID PvAlloc(ULONG cbBuf, UINT uiMemFlags);
  588. static PVOID PvReAlloc(PVOID pvBuf, DWORD cbBuf);
  589. static void FreePv(PVOID pvBuf);
  590. static inline void *MoveMemory(void *dst, const void *src, size_t cb)
  591. {
  592. Assert(cb >= 0);
  593. return memmove(dst, src, cb);
  594. }
  595. static inline void *CopyMemory(void *dst, const void *src, size_t cb)
  596. {
  597. // Will work for overlapping regions
  598. Assert(cb >= 0);
  599. return MoveMemory(dst, src, cb);
  600. }
  601. static inline void *FillMemory(void *dst, int fill, size_t cb)
  602. {
  603. return memset(dst, fill, cb);
  604. }
  605. static inline void *ZeroMemory(void *dst, size_t cb)
  606. {
  607. Assert(cb >= 0);
  608. return memset(dst, 0, cb);
  609. }
  610. static inline int CompareMemory(const void *s1, const void *s2, size_t cb)
  611. {
  612. return memcmp(s1, s2, cb);
  613. }
  614. static size_t wcslen(const wchar_t *wcs);
  615. static wchar_t * wcscpy(wchar_t * dst, const wchar_t * src);
  616. static int wcscmp(const wchar_t * src, const wchar_t * dst);
  617. static int wcsicmp(const wchar_t * src, const wchar_t * dst);
  618. static wchar_t * wcsncpy (wchar_t * dest, const wchar_t * source, size_t count);
  619. static int wcsnicmp(const wchar_t *first, const wchar_t *last, size_t count);
  620. static unsigned long strtoul(const char *);
  621. #ifndef NOFEPROCESSING
  622. // ----------------------------------
  623. // IME Support
  624. // ----------------------------------
  625. static BOOL ImmInitialize( void );
  626. static void ImmTerminate( void );
  627. static LONG ImmGetCompositionStringA ( HIMC, DWORD, PVOID, DWORD, BOOL );
  628. static LONG ImmGetCompositionStringW ( HIMC, DWORD, PVOID, DWORD, BOOL );
  629. static HIMC ImmGetContext ( HWND, BOOL );
  630. static BOOL ImmSetCompositionFontA ( HIMC, LPLOGFONTA, BOOL );
  631. static BOOL ImmSetCompositionWindow ( HIMC, LPCOMPOSITIONFORM, BOOL );
  632. static BOOL ImmReleaseContext ( HWND, HIMC, BOOL );
  633. static DWORD ImmGetProperty ( HKL, DWORD, BOOL );
  634. static BOOL ImmGetCandidateWindow ( HIMC, DWORD, LPCANDIDATEFORM, BOOL );
  635. static BOOL ImmSetCandidateWindow ( HIMC, LPCANDIDATEFORM, BOOL );
  636. static BOOL ImmNotifyIME ( HIMC, DWORD, DWORD, DWORD, BOOL );
  637. static HIMC ImmAssociateContext ( HWND, HIMC, BOOL );
  638. static UINT ImmGetVirtualKey ( HWND, BOOL );
  639. static HIMC ImmEscape ( HKL, HIMC, UINT, PVOID, BOOL );
  640. static BOOL ImmGetOpenStatus ( HIMC, BOOL );
  641. static BOOL ImmSetOpenStatus ( HIMC, BOOL, BOOL );
  642. static BOOL ImmGetConversionStatus ( HIMC, LPDWORD, LPDWORD, BOOL );
  643. static BOOL ImmSetConversionStatus ( HIMC, DWORD, DWORD, BOOL );
  644. static HWND ImmGetDefaultIMEWnd ( HWND , BOOL);
  645. static BOOL ImmSetCompositionStringW (HIMC, DWORD, PVOID, DWORD, PVOID, DWORD, BOOL);
  646. static BOOL ImmIsIME ( HKL, BOOL );
  647. static BOOL FSupportSty ( UINT, UINT );
  648. static const IMESTYLE * PIMEStyleFromAttr ( const UINT );
  649. static const IMECOLORSTY * PColorStyleTextFromIMEStyle ( const IMESTYLE * );
  650. static const IMECOLORSTY * PColorStyleBackFromIMEStyle ( const IMESTYLE * );
  651. static BOOL FBoldIMEStyle ( const IMESTYLE * );
  652. static BOOL FItalicIMEStyle ( const IMESTYLE * );
  653. static BOOL FUlIMEStyle ( const IMESTYLE * );
  654. static UINT IdUlIMEStyle ( const IMESTYLE * );
  655. static COLORREF RGBFromIMEColorStyle ( const IMECOLORSTY * );
  656. #endif // NOFEPROCESSING
  657. // ----------------------------------
  658. // National Language Keyboard support
  659. // ----------------------------------
  660. static HKL CheckChangeKeyboardLayout (BYTE iCharRep);
  661. static HKL ActivateKeyboard (LONG iCharRep);
  662. static QWORD GetCharFlags125x(WCHAR ch);
  663. static BOOL GetKeyboardFlag (WORD dwKeyMask, WORD wKey);
  664. static WORD GetKeyboardFlags () {return _wKeyboardFlags;}
  665. static HKL GetKeyboardLayout (DWORD dwThreadID);
  666. static DWORD GetKeyPadNumber () {return _dwNumKeyPad;}
  667. static WORD GetDeadKey () {return _wDeadKey;}
  668. static void InitKeyboardFlags ();
  669. static void RefreshKeyboardLayout ();
  670. static void ResetKeyboardFlag (WORD wFlag) {_wKeyboardFlags &= ~wFlag;}
  671. static void SetDeadKey (WORD wDeadKey) {_wDeadKey = wDeadKey;}
  672. static void SetKeyboardFlag (WORD wFlag) {_wKeyboardFlags |= wFlag;}
  673. static void SetKeyPadNumber (DWORD dwNum) {_dwNumKeyPad = dwNum;}
  674. static bool UsingHebrewKeyboard ()
  675. {return PRIMARYLANGID(_hklCurrent) == LANG_HEBREW;}
  676. static void InitPreferredFontInfo();
  677. static bool SetPreferredFontInfo(
  678. int iCharRep,
  679. bool fUIFont,
  680. SHORT iFont,
  681. BYTE yHeight,
  682. BYTE bPitchAndFamily
  683. );
  684. static bool GetPreferredFontInfo(
  685. int iCharRep,
  686. bool fUIFont,
  687. SHORT& iFont,
  688. BYTE& yHeight,
  689. BYTE& bPitchAndFamily
  690. );
  691. static bool IsExternalFontCheckActive() {return false;}
  692. static bool GetExternalPreferredFontInfo(
  693. const WCHAR *pch,
  694. LONG cch,
  695. BYTE & iCharRep,
  696. SHORT & iFont,
  697. BYTE & bPitchAndFamily,
  698. bool fUIFont
  699. ) { return false;}
  700. static int GetTextCharsetInfo(
  701. HDC hdc, // handle to device context
  702. LPFONTSIGNATURE lpSig, // pointer to structure to receive data
  703. DWORD dwFlags // reserved; must be zero
  704. );
  705. static SHORT GetPreferredFontHeight(
  706. bool fUIFont,
  707. BYTE iCharRepOrg,
  708. BYTE iCharRepNew,
  709. SHORT yOrgHeight
  710. );
  711. static void CheckInstalledFEFonts();
  712. static void CheckInstalledKeyboards();
  713. static bool IsFontAvail( HDC hDC, int iCharRep, bool fUIFont = false, short *piFontIndex = NULL,
  714. WCHAR *pFontName = NULL);
  715. static bool IsDefaultFontDefined(LONG iCharRep, bool fUIFont, SHORT &iFont);
  716. #ifndef NOFEPROCESSING
  717. static bool IsFEFontInSystem( int cpg );
  718. static UINT GetFEFontInfo( void );
  719. static int IsFESystem()
  720. {
  721. return IsFELCID( _syslcid );
  722. }
  723. #else
  724. static bool IsFEFontInSystem( int ) { return FALSE; }
  725. static UINT GetFEFontInfo( void ) { return 0; };
  726. static int IsFESystem() { return FALSE; }
  727. #endif
  728. // Helper routines to get data from temp display attributes array
  729. static short GetTmpDisplayAttrIdx(TMPDISPLAYATTR &tmpDisplayAttr);
  730. static short GetTmpUnderline(SHORT idx);
  731. static bool GetTmpColor(SHORT idx, COLORREF &crTmpColor, INT iAction);
  732. #ifndef NOACCESSIBILITY
  733. // ----------------------------------
  734. // Accessability Support
  735. // ----------------------------------
  736. static HRESULT VariantCopy(VARIANTARG FAR* pvargDest, VARIANTARG FAR* pvargSrc);
  737. static LRESULT LResultFromObject(REFIID riid, WPARAM wParam, LPUNKNOWN punk);
  738. static HRESULT CreateStdAccessibleProxyW(HWND hwnd, LPCWSTR pClassName, LONG idObject, REFIID riid, void** ppvObject);
  739. static HRESULT AccessibleObjectFromWindow(HWND hWnd, DWORD dwID, REFIID riidInterface, void ** ppvObject);
  740. static BOOL BlockInput(BOOL fBlock);
  741. static UINT SendInput(UINT nInputs, LPINPUT pInputs, int cbSize);
  742. static VOID NotifyWinEvent(DWORD dwEvent, HWND hWnd, LONG lObjectType, LONG lObjectId);
  743. #endif
  744. // ----------------------------------
  745. // OLE Support
  746. // ----------------------------------
  747. static HRESULT LoadRegTypeLib ( REFGUID, WORD, WORD, LCID, ITypeLib ** );
  748. static HRESULT LoadTypeLib ( const OLECHAR *, ITypeLib ** );
  749. static HRESULT LoadTypeLibEx( LPCOLESTR szFile, REGKIND regkind, ITypeLib ** pptlib );
  750. static BSTR SysAllocString ( const OLECHAR * );
  751. static BSTR SysAllocStringLen ( const OLECHAR *, UINT );
  752. static void SysFreeString ( BSTR );
  753. static UINT SysStringLen ( BSTR );
  754. static void VariantInit ( VARIANTARG * );
  755. static void VariantClear ( VARIANTARG * );
  756. static HRESULT OleCreateFromData ( LPDATAOBJECT, REFIID, DWORD, LPFORMATETC, LPOLECLIENTSITE, LPSTORAGE, void ** );
  757. static void CoTaskMemFree ( PVOID );
  758. static HRESULT CreateBindCtx ( DWORD, LPBC * );
  759. static HANDLE OleDuplicateData ( HANDLE, CLIPFORMAT, UINT );
  760. static HRESULT CoTreatAsClass ( REFCLSID, REFCLSID );
  761. static HRESULT ProgIDFromCLSID ( REFCLSID, LPOLESTR * );
  762. static HRESULT OleConvertIStorageToOLESTREAM ( LPSTORAGE, LPOLESTREAM );
  763. static HRESULT OleConvertIStorageToOLESTREAMEx ( LPSTORAGE, CLIPFORMAT, LONG, LONG, DWORD, LPSTGMEDIUM, LPOLESTREAM );
  764. static HRESULT OleSave ( LPPERSISTSTORAGE, LPSTORAGE, BOOL );
  765. static HRESULT StgCreateDocfileOnILockBytes ( ILockBytes *, DWORD, DWORD, IStorage ** );
  766. static HRESULT CreateILockBytesOnHGlobal ( HGLOBAL, BOOL, ILockBytes ** );
  767. static HRESULT OleCreateLinkToFile ( LPCOLESTR, REFIID, DWORD, LPFORMATETC, LPOLECLIENTSITE, LPSTORAGE, void ** );
  768. static PVOID CoTaskMemAlloc ( ULONG );
  769. static PVOID CoTaskMemRealloc ( PVOID, ULONG );
  770. static HRESULT OleInitialize ( PVOID );
  771. static void OleUninitialize ( );
  772. static HRESULT OleSetClipboard ( IDataObject * );
  773. static HRESULT OleFlushClipboard ( );
  774. static HRESULT OleIsCurrentClipboard ( IDataObject * );
  775. static HRESULT DoDragDrop ( IDataObject *, IDropSource *, DWORD, DWORD * );
  776. static HRESULT OleGetClipboard ( IDataObject ** );
  777. static HRESULT RegisterDragDrop ( HWND, IDropTarget * );
  778. static HRESULT OleCreateLinkFromData ( IDataObject *, REFIID, DWORD, LPFORMATETC, IOleClientSite *, IStorage *, void ** );
  779. static HRESULT OleCreateStaticFromData ( IDataObject *, REFIID, DWORD, LPFORMATETC, IOleClientSite *, IStorage *, void ** );
  780. static HRESULT OleDraw ( IUnknown *, DWORD, HDC, LPCRECT );
  781. static HRESULT OleSetContainedObject ( IUnknown *, BOOL );
  782. static HRESULT CoDisconnectObject ( IUnknown *, DWORD );
  783. static HRESULT WriteFmtUserTypeStg ( IStorage *, CLIPFORMAT, LPOLESTR );
  784. static HRESULT WriteClassStg ( IStorage *, REFCLSID );
  785. static HRESULT SetConvertStg ( IStorage *, BOOL );
  786. static HRESULT ReadFmtUserTypeStg ( IStorage *, CLIPFORMAT *, LPOLESTR * );
  787. static HRESULT ReadClassStg ( IStorage *pstg, CLSID * );
  788. static HRESULT OleRun ( IUnknown * );
  789. static HRESULT RevokeDragDrop ( HWND );
  790. static HRESULT CreateStreamOnHGlobal ( HGLOBAL, BOOL, IStream ** );
  791. static HRESULT GetHGlobalFromStream ( IStream *pstm, HGLOBAL * );
  792. static HRESULT OleCreateDefaultHandler ( REFCLSID, IUnknown *, REFIID, void ** );
  793. static HRESULT CLSIDFromProgID ( LPCOLESTR, LPCLSID );
  794. static HRESULT OleConvertOLESTREAMToIStorage ( LPOLESTREAM, IStorage *, const DVTARGETDEVICE * );
  795. static HRESULT OleLoad ( IStorage *, REFIID, IOleClientSite *, void ** );
  796. static HRESULT ReleaseStgMedium ( LPSTGMEDIUM );
  797. static HRESULT CoCreateInstance (REFCLSID rclsid, LPUNKNOWN pUnknown,
  798. DWORD dwClsContext, REFIID riid, PVOID *ppv);
  799. static HRESULT OleCreateFromFile (REFCLSID, LPCOLESTR, REFIID, DWORD, LPFORMATETC, LPOLECLIENTSITE, LPSTORAGE, LPVOID *);
  800. static void FreeOle();
  801. #ifndef NOFEPROCESSING
  802. static void FreeIME();
  803. static BOOL HaveIMEShare();
  804. static BOOL getIMEShareObject(CIMEShare **ppIMEShare);
  805. static BOOL IsAIMMLoaded() { return _fHaveAIMM; }
  806. static BOOL GetAimmObject(IUnknown **ppAimm);
  807. static BOOL LoadAIMM(BOOL fUseAimm12);
  808. static HRESULT AIMMDefWndProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam, LRESULT *plres);
  809. static HRESULT AIMMGetCodePage (HKL hKL, UINT *uCodePage);
  810. static HRESULT AIMMActivate (BOOL fRestoreLayout);
  811. static HRESULT AIMMDeactivate (void);
  812. static HRESULT AIMMFilterClientWindows(ATOM *aaClassList, UINT uSize, HWND hWnd);
  813. static HRESULT AIMMUnfilterClientWindows(HWND hWnd);
  814. static UINT GetDisplayGUID (HIMC hIMC, UINT uAttribute);
  815. #endif // NOFEPROCESSING
  816. int __cdecl sprintf(char * buff, char *fmt, ...);
  817. #ifdef DEBUG
  818. int __cdecl strcmp(const char *, const char *);
  819. char * __cdecl strrchr(const char *, int);
  820. char * __cdecl strcat(char *, const char *);
  821. #endif
  822. // ----------------------------------
  823. // Useful ANSI<-->Unicode conversion
  824. // and language id routines
  825. // ----------------------------------
  826. static int MbcsFromUnicode(LPSTR pstr, int cch, LPCWSTR pwstr,
  827. int cwch = -1, UINT codepage = CP_ACP,
  828. UN_FLAGS flags = UN_CONVERT_WCH_EMBEDDING);
  829. static int UnicodeFromMbcs(LPWSTR pwstr, int cwch, LPCSTR pstr, int cch = -1,
  830. UINT uiCodePage = CP_ACP);
  831. static int MBTWC(INT CodePage, DWORD dwFlags, LPCSTR pstrMB, int cchMB,
  832. LPWSTR pstrWC, int cchWC, LPBOOL pfNoCodePage);
  833. static int WCTMB(INT CodePage, DWORD dwFlags, LPCWSTR pstrWC, int cchWC,
  834. LPSTR pstrMB, int cchMB, LPCSTR pchDefault, LPBOOL pfUsedDef,
  835. LPBOOL pfNoCodePage, BOOL fTestCodePage = FALSE);
  836. static int VerifyFEString(INT cpg, LPCWSTR pstrWC, int cchWC, BOOL fTestInputCpg);
  837. static HGLOBAL TextHGlobalAtoW( HGLOBAL hglobal );
  838. static HGLOBAL TextHGlobalWtoA( HGLOBAL hglobal );
  839. static LONG CharRepFontSig(QWORD qwFontSig, BOOL fFirstAvailable);
  840. static UINT CharRepFromLID(WORD lid, BOOL fPlane2 = FALSE);
  841. static LONG CharRepFromCharSet(BYTE bCharSet);
  842. static INT CharRepFromCodePage(LONG CodePage);
  843. static LONG CharRepFromFontSig(QWORD qwFontSig)
  844. {return CharRepFontSig(qwFontSig, FALSE);}
  845. static BYTE CharSetFromCharRep(LONG iCharRep);
  846. static INT CodePageFromCharRep(LONG iCharRep);
  847. static QWORD FontSigFromCharRep(LONG iCharRep);
  848. #ifndef NOCOMPLEXSCRIPTS
  849. static HKL FindDirectionalKeyboard(BOOL fRTL);
  850. #else
  851. static HKL FindDirectionalKeyboard(BOOL fRTL) {return NULL;}
  852. #endif
  853. static BYTE GetCharSet(INT cpg, int *piCharRep = NULL);
  854. static BYTE MatchFECharRep(QWORD qwCharFlags, QWORD qwFontSig);
  855. static BYTE GetFirstAvailCharRep(QWORD qwFontSig)
  856. {return CharRepFontSig(qwFontSig, TRUE);}
  857. static UINT GetKeyboardCharRep(DWORD dwMakeAPICall = 0);
  858. static UINT GetKeyboardCodePage(DWORD dwMakeAPICall = 0)
  859. {return CodePageFromCharRep(GetKeyboardCharRep(dwMakeAPICall));}
  860. static LCID GetKeyboardLCID(DWORD dwMakeAPICall = 0);
  861. static UINT GetLocaleCharRep();
  862. static HKL GetPreferredKbd(LONG iCharRep) {return _hkl[iCharRep];}
  863. static void SetPreferredKbd(LONG iCharRep, HKL hkl) {_hkl[iCharRep] = hkl;}
  864. static UINT GetSystemDefaultCodePage()
  865. {return CodePageFromCharRep(CharRepFromLID(GetSystemDefaultLangID()));}
  866. static int GetTrailBytesCount(BYTE ach, UINT cpg);
  867. static BOOL Is8BitCodePage(unsigned CodePage);
  868. static BOOL Is8BitCharRep(unsigned iCharRep)
  869. {return IN_RANGE(ANSI_INDEX, iCharRep, THAI_INDEX);}
  870. static BOOL IsAlef(WCHAR ch);
  871. static BOOL IsBiDiCharSet(unsigned CharSet)
  872. {return IN_RANGE(HEBREW_CHARSET, CharSet, ARABIC_CHARSET);}
  873. static BOOL IsBiDiCharRep(unsigned iCharRep)
  874. {return IN_RANGE(HEBREW_INDEX, iCharRep, ARABIC_INDEX) ||
  875. IN_RANGE(SYRIAC_INDEX, iCharRep, THAANA_INDEX);}
  876. static BOOL IsIndicCharRep(unsigned iCharRep)
  877. {return IN_RANGE(INDIC_FIRSTINDEX, iCharRep, INDIC_LASTINDEX);}
  878. static bool IsBiDiCodePage(int cpg)
  879. {return IN_RANGE(CP_HEBREW, cpg, CP_ARABIC);}
  880. static bool IsBiDiKbdInstalled()
  881. {return _hkl[HEBREW_INDEX] || _hkl[ARABIC_INDEX];}
  882. static bool IsThaiKbdInstalled()
  883. {return _hkl[THAI_INDEX] != 0;}
  884. static bool IsIndicKbdInstalled();
  885. static bool IsComplexKbdInstalled()
  886. {return IsBiDiKbdInstalled() || IsThaiKbdInstalled() || IsIndicKbdInstalled();}
  887. static bool IsVietnameseCodePage(int cpg)
  888. {return cpg == CP_VIETNAMESE;}
  889. static BOOL IsDiacritic(WCHAR ch);
  890. static BOOL IsBiDiDiacritic(WCHAR ch);
  891. static BOOL IsBiDiKashida(WCHAR ch)
  892. {return ch == 0x0640;}
  893. static BOOL IsBiDiLcid(LCID lcid);
  894. static BOOL IsIndicLcid(LCID lcid);
  895. static BOOL IsComplexScriptLcid(LCID lcid);
  896. #ifndef NOCOMPLEXSCRIPTS
  897. static BOOL IsDiacriticOrKashida(WCHAR ch, WORD wC3Type);
  898. #else
  899. static BOOL IsDiacriticOrKashida(WCHAR, WORD) { return FALSE; }
  900. #endif
  901. static bool IsFELCID(LCID lcid);
  902. static BOOL IsFECharSet (BYTE bCharSet);
  903. static BOOL IsFECharRep (BYTE iCharRep)
  904. {return IN_RANGE(SHIFTJIS_INDEX, iCharRep, BIG5_INDEX);}
  905. static bool IsFECodePage(int cpg)
  906. {return IN_RANGE(CP_JAPAN, cpg, CP_CHINESE_TRAD);}
  907. static BOOL IsFECodePageFont (DWORD dwFontSig);
  908. static BOOL IsRTLCharRep(BYTE iCharRep)
  909. {return IN_RANGE(HEBREW_INDEX, iCharRep, ARABIC_INDEX);}
  910. static BOOL IsRTLCharSet(BYTE bCharSet);
  911. BOOL IsStrongDirectional(CC cc) {return cc <= CC_LTR;}
  912. static BOOL IsVietCdmSequenceValid(WCHAR ch1, WCHAR ch2);
  913. static BOOL IsUTF8BOM(BYTE *pstr);
  914. static WPARAM ValidateStreamWparam(WPARAM wparam);
  915. static CC MECharClass(WCHAR ch);
  916. static HDC GetScreenDC();
  917. // ----------------------------------
  918. // Unicode Wrapped Functions
  919. // ----------------------------------
  920. // We could use inline and a function pointer table to improve efficiency and code size.
  921. static ATOM WINAPI RegisterREClass(
  922. const WNDCLASSW *lpWndClass
  923. );
  924. static BOOL GetVersion(
  925. DWORD *pdwPlatformId,
  926. DWORD *pdwMajorVersion,
  927. DWORD *pdwMinorVersion
  928. );
  929. static BOOL GetStringTypes(
  930. LCID lcid,
  931. LPCTSTR lpSrcStr,
  932. int cchSrc,
  933. LPWORD lpCharType1,
  934. LPWORD lpCharType3
  935. );
  936. static BOOL WINAPI GetStringTypeEx(
  937. LCID Locale,
  938. DWORD dwInfoType,
  939. LPCWSTR lpSrcStr,
  940. int cchSrc,
  941. LPWORD lpCharType
  942. );
  943. static LPWSTR WINAPI CharLower(LPWSTR pwstr);
  944. static DWORD WINAPI CharLowerBuff(LPWSTR pwstr, DWORD cchLength);
  945. static DWORD WINAPI CharUpperBuff(LPWSTR pwstr, DWORD cchLength);
  946. static HDC WINAPI CreateIC(
  947. LPCWSTR lpszDriver,
  948. LPCWSTR lpszDevice,
  949. LPCWSTR lpszOutput,
  950. CONST DEVMODEW * lpInitData
  951. );
  952. static HANDLE WINAPI CreateFile(
  953. LPCWSTR lpFileName,
  954. DWORD dwDesiredAccess,
  955. DWORD dwShareMode,
  956. LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  957. DWORD dwCreationDisposition,
  958. DWORD dwFlagsAndAttributes,
  959. HANDLE hTemplateFile
  960. );
  961. static HFONT WINAPI CreateFontIndirect(CONST LOGFONTW * plfw);
  962. static int WINAPI CompareString (
  963. LCID Locale, // locale identifier
  964. DWORD dwCmpFlags, // comparison-style options
  965. LPCWSTR lpString1, // pointer to first string
  966. int cch1, // size, in bytes or characters, of first string
  967. LPCWSTR lpString2, // pointer to second string
  968. int cch2 // size, in bytes or characters, of second string
  969. );
  970. static LRESULT WINAPI DefWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  971. static int WINAPI GetObject(HGDIOBJ hgdiObj, int cbBuffer, PVOID lpvObj);
  972. static DWORD APIENTRY GetProfileSection(
  973. LPCWSTR lpAppName,
  974. LPWSTR lpReturnedString,
  975. DWORD nSize
  976. );
  977. static int WINAPI GetTextFace(
  978. HDC hdc,
  979. int cch,
  980. LPWSTR lpFaceName
  981. );
  982. static BOOL WINAPI GetTextMetrics(HDC hdc, LPTEXTMETRICW lptm);
  983. static BOOL WINAPI GetTextMetrics(HDC hdc, LOGFONTW &lf, TEXTMETRICW &tm);
  984. static LONG WINAPI GetWindowLong(HWND hWnd, int nIndex);
  985. static LONG_PTR WINAPI GetWindowLongPtr(HWND hWnd, int nIndex);
  986. static DWORD WINAPI GetClassLong(HWND hWnd, int nIndex);
  987. static HBITMAP WINAPI LoadBitmap(HINSTANCE hInstance, LPCWSTR lpBitmapName);
  988. static HBITMAP WINAPI GetPictureBitmap(IStream *pstm);
  989. static HCURSOR WINAPI LoadCursor(HINSTANCE hInstance, LPCWSTR lpCursorName);
  990. static HINSTANCE WINAPI LoadLibrary(LPCWSTR lpLibFileName);
  991. static LRESULT WINAPI SendMessage(
  992. HWND hWnd,
  993. UINT Msg,
  994. WPARAM wParam,
  995. LPARAM lParam
  996. );
  997. static LONG WINAPI SetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong);
  998. static LONG WINAPI SetWindowLongPtr(HWND hWnd, int nIndex, LONG_PTR dwNew);
  999. static BOOL WINAPI PostMessage(
  1000. HWND hWnd,
  1001. UINT Msg,
  1002. WPARAM wParam,
  1003. LPARAM lParam
  1004. );
  1005. static BOOL WINAPI UnregisterClass(LPCWSTR lpClassName, HINSTANCE hInstance);
  1006. static int WINAPI lstrcmpi(LPCWSTR lpString1, LPCWSTR lpString2);
  1007. static BOOL WINAPI PeekMessage(
  1008. LPMSG lpMsg,
  1009. HWND hWnd,
  1010. UINT wMsgFilterMin,
  1011. UINT wMsgFilterMax,
  1012. UINT wRemoveMsg
  1013. );
  1014. static DWORD WINAPI GetModuleFileName(
  1015. HMODULE hModule,
  1016. LPWSTR lpFilename,
  1017. DWORD nSize
  1018. );
  1019. static DWORD GetCurrentThreadId(void);
  1020. static BOOL TrackMouseLeave(HWND hWnd);
  1021. static COLORREF GetCtlBorderColor(BOOL fMousedown, BOOL fMouseover);
  1022. static COLORREF GetCtlBkgColor(BOOL fMousedown, BOOL fMouseover);
  1023. static COLORREF GetCtlTxtColor(BOOL fMousedown, BOOL fMouseover, BOOL fDisabled);
  1024. static void DrawBorderedRectangle(
  1025. HDC hdc,
  1026. RECT *prc,
  1027. COLORREF crBorder,
  1028. COLORREF crBackground
  1029. );
  1030. static void DrawArrow(
  1031. HDC hdc,
  1032. RECT *prc,
  1033. COLORREF crArrow
  1034. );
  1035. private:
  1036. // System Parameters
  1037. static BOOL _fSysParamsOk; // System Parameters have been Initialized
  1038. static INT _dupSystemFont; // average char width of system font
  1039. static INT _dvpSystemFont; // height of system font
  1040. static INT _ySysFontLeading; // System font internal leading
  1041. static BOOL _fUsePalette;
  1042. static LONG _xPerInchScreenDC; // Pixels per inch used for conversions ...
  1043. static LONG _yPerInchScreenDC; // ... and determining whether screen or ...
  1044. static INT _cxBorder; // GetSystemMetricx(SM_CXBORDER)...
  1045. static INT _cyBorder; // GetSystemMetricx(SM_CYBORDER)...
  1046. static INT _cxVScroll; // Width/height of scrlbar arw bitmap
  1047. static INT _cyHScroll; // Width of scrlbar arw bitmap
  1048. static LONG _dxSelBar;
  1049. static INT _sysiniflags; // Start using line services from the start
  1050. static UINT _ACP; // Current Ansi code page identifier
  1051. static HDC _hdcScreen;
  1052. // Double click distances
  1053. static INT _cxDoubleClk;
  1054. static INT _cyDoubleClk;
  1055. // Double Click Time in milliseconds
  1056. static INT _DCT;
  1057. //Width of hot zone (in pixels) for auto-scrolling
  1058. static WORD _nScrollInset;
  1059. //Delay (in ms) before scrolling
  1060. static WORD _nScrollDelay;
  1061. //Interval (in ms) at which we scroll
  1062. static WORD _nScrollInterval;
  1063. //Amount of horizontal scroll at each interval (pixels)
  1064. static WORD _nScrollHAmount;
  1065. //Amount of vertical scroll at each interval (pixels)
  1066. static WORD _nScrollVAmount;
  1067. //Amount of time to wait for determining start of drag operation
  1068. static WORD _nDragDelay;
  1069. //Minimun distance that must be traversed within drag delay time interval
  1070. static WORD _nDragMinDist;
  1071. //Keyboard deadkey
  1072. static WORD _wDeadKey;
  1073. //Keyboard shift/ctrl/alt/lock status
  1074. static WORD _wKeyboardFlags;
  1075. //North/South sizing cursor (double arrow)
  1076. static HCURSOR _hcurSizeNS;
  1077. //West/East sizing cursor (double arrow)
  1078. static HCURSOR _hcurSizeWE;
  1079. //Northwest/Southeast sizing cursor (double arrow)
  1080. static HCURSOR _hcurSizeNWSE;
  1081. //Northeast/Southwest sizing cursor (double arrow)
  1082. static HCURSOR _hcurSizeNESW;
  1083. //Number of Lines to scroll with a mouse roller wheel, -1 for pages
  1084. static LONG _cLineScroll;
  1085. //System Font Handle. This one need only be done once.
  1086. static HFONT _hSystemFont;
  1087. //Default Font Handle. This one need only be done once.
  1088. static HFONT _hDefaultFont;
  1089. //System Keyboard Layout
  1090. static HKL _hklCurrent;
  1091. static HKL _hkl[NCHARREPERTOIRES];
  1092. // Ref Count
  1093. static DWORD _cRefs;
  1094. //AltNumericKeyboard number
  1095. static DWORD _dwNumKeyPad;
  1096. //Digit substitution mode (context, none, national)
  1097. static BYTE _bDigitSubstMode;
  1098. //SYSTEM_FONT charset
  1099. static BYTE _bCharSetSys;
  1100. public:
  1101. static INT GetDupSystemFont() {return _dupSystemFont; }
  1102. static INT GetDvpSystemFont() {return _dvpSystemFont; }
  1103. static INT GetSysFontLeading() {return _ySysFontLeading; }
  1104. static LONG GetXPerInchScreenDC(){return _xPerInchScreenDC; }
  1105. static LONG GetYPerInchScreenDC(){return _yPerInchScreenDC; }
  1106. static INT GetCxBorder() {return _cxBorder; }
  1107. static INT GetCyBorder() {return _cyBorder; }
  1108. static INT GetCyHScroll() {return _cyHScroll; }
  1109. static INT GetCxVScroll() {return _cxVScroll; }
  1110. static LONG GetDxSelBar() {return _dxSelBar; }
  1111. static WORD GetScrollInset() {return _nScrollInset; }
  1112. static WORD GetScrollDelay() {return _nScrollDelay; }
  1113. static WORD GetScrollInterval() {return _nScrollInterval; }
  1114. static WORD GetScrollHAmount() {return _nScrollHAmount; }
  1115. static WORD GetScrollVAmount() {return _nScrollVAmount; }
  1116. static INT GetCxDoubleClk() {return _cxDoubleClk; }
  1117. static INT GetCyDoubleClk() {return _cyDoubleClk; }
  1118. static INT GetDCT() {return _DCT; }
  1119. static WORD GetDragDelay() {return _nDragDelay; }
  1120. static WORD GetDragMinDist() {return _nDragMinDist; }
  1121. static LONG GetRollerLineScrollCount();
  1122. static HCURSOR GetSizeCursor(LPTSTR idcur);
  1123. static HFONT GetSystemFont() {return _hSystemFont; }
  1124. static BYTE ReadRegDigitSubstitutionMode();
  1125. static BYTE GetDigitSubstitutionMode() {return _bDigitSubstMode;}
  1126. static bool fUseAimm() {return (_sysiniflags & SYSINI_USEAIMM) != 0;}
  1127. static bool fUseCTF() {return (_sysiniflags & SYSINI_USECTF) != 0;}
  1128. static bool fUseBiDi() {return (_sysiniflags & SYSINI_BIDI) != 0;}
  1129. static bool fUseLs() {return (_sysiniflags & SYSINI_USELS) != 0;}
  1130. static bool fDebugFont() {return (_sysiniflags & SYSINI_DEBUGFONT) != 0;}
  1131. static int DebugDefaultCpg() {return HIWORD(_sysiniflags);}
  1132. static BOOL FUsePalette() {return _fUsePalette; }
  1133. static void InitSysParams(BOOL fUpdate = FALSE);
  1134. static DWORD GetRefs() {return _cRefs;}
  1135. static BYTE GetSysCharSet() {return _bCharSetSys;}
  1136. static BOOL IsForegroundFrame(HWND);
  1137. // Should also be wrapped but aren't. Used for debugging.
  1138. // MessageBox
  1139. // OutputDebugString
  1140. // lstrcmpiA should also be wrapped for Win CE's sake but the code
  1141. // that uses it is ifdeffed out for WINCE.
  1142. // Mirroring API entry points
  1143. static PFN_GETLAYOUT _pfnGetLayout;
  1144. static PFN_SETLAYOUT _pfnSetLayout;
  1145. #ifndef NODRAFTMODE
  1146. public:
  1147. static bool GetDraftModeFontInfo(
  1148. SHORT &iFont,
  1149. SHORT &yHeight,
  1150. QWORD &qwFontSig,
  1151. COLORREF &crColor
  1152. );
  1153. private:
  1154. struct DraftModeFontInfo {
  1155. SHORT _iFont;
  1156. SHORT _yHeight;
  1157. QWORD _qwFontSig;
  1158. COLORREF _crTextColor;
  1159. };
  1160. static struct DraftModeFontInfo _draftModeFontInfo;
  1161. #endif
  1162. };
  1163. extern CW32System *W32;
  1164. HKL g_hkl[];
  1165. // This fixes a problem with MulDiv reference in _font.h
  1166. #define W32MulDiv W32->MulDivFunc
  1167. #if !defined(W32SYS_CPP)
  1168. #define OnWinNTFE W32->OnWinNTFE
  1169. #define OnWin95FE W32->OnWin95FE
  1170. #if defined(DEBUG)
  1171. #define PvAlloc(cbBuf, uiMemFlags) W32->PvAllocDebug(cbBuf, uiMemFlags, __FILE__, __LINE__)
  1172. #define PvReAlloc(pv, cbBuf) W32->PvReAllocDebug(pv, cbBuf, __FILE__, __LINE__)
  1173. #define PvSet(pv) W32->PvSet(pv, __FILE__, __LINE__)
  1174. #define FreePv W32->FreePvDebug
  1175. #else
  1176. #define PvAlloc W32->PvAlloc
  1177. #define PvReAlloc W32->PvReAlloc
  1178. #define FreePv W32->FreePv
  1179. #define PvSet(pv)
  1180. #endif
  1181. #define CopyMemory W32->CopyMemory
  1182. #define MoveMemory W32->MoveMemory
  1183. #define FillMemory W32->FillMemory
  1184. #define ZeroMemory W32->ZeroMemory
  1185. #define CompareMemory W32->CompareMemory
  1186. #define GlobalAlloc W32->GlobalAlloc
  1187. #define GlobalFree W32->GlobalFree
  1188. #define GlobalFlags W32->GlobalFlags
  1189. #define GlobalReAlloc W32->GlobalReAlloc
  1190. #define GlobalSize W32->GlobalSize
  1191. #define GlobalLock W32->GlobalLock
  1192. #define GlobalHandle W32->GlobalHandle
  1193. #define GlobalUnlock W32->GlobalUnlock
  1194. #define ImmInitialize W32->ImmInitialize
  1195. #define ImmTerminate W32->ImmTerminate
  1196. #define ImmGetCompositionStringA W32->ImmGetCompositionStringA
  1197. #define ImmGetCompositionStringW W32->ImmGetCompositionStringW
  1198. #define ImmGetContext W32->ImmGetContext
  1199. #define ImmSetCompositionFontA W32->ImmSetCompositionFontA
  1200. #define ImmSetCompositionWindow W32->ImmSetCompositionWindow
  1201. #define ImmReleaseContext W32->ImmReleaseContext
  1202. #define ImmGetProperty W32->ImmGetProperty
  1203. #define ImmGetCandidateWindow W32->ImmGetCandidateWindow
  1204. #define ImmSetCandidateWindow W32->ImmSetCandidateWindow
  1205. #define ImmNotifyIME W32->ImmNotifyIME
  1206. #define ImmAssociateContext W32->ImmAssociateContext
  1207. #define ImmGetVirtualKey W32->ImmGetVirtualKey
  1208. #define ImmEscape W32->ImmEscape
  1209. #define ImmGetOpenStatus W32->ImmGetOpenStatus
  1210. #define ImmSetOpenStatus W32->ImmSetOpenStatus
  1211. #define ImmGetConversionStatus W32->ImmGetConversionStatus
  1212. #define ImmSetConversionStatus W32->ImmSetConversionStatus
  1213. #define ImmGetDefaultIMEWnd W32->ImmGetDefaultIMEWnd
  1214. #define ImmSetCompositionStringW W32->ImmSetCompositionStringW
  1215. #define ImmIsIME W32->ImmIsIME
  1216. #define LoadRegTypeLib W32->LoadRegTypeLib
  1217. #define LoadTypeLib W32->LoadTypeLib
  1218. #define SysAllocString W32->SysAllocString
  1219. #define SysAllocStringLen W32->SysAllocStringLen
  1220. #define SysFreeString W32->SysFreeString
  1221. #define SysStringLen W32->SysStringLen
  1222. #define VariantInit W32->VariantInit
  1223. #define VariantClear W32->VariantClear
  1224. #define OleCreateFromData W32->OleCreateFromData
  1225. #define CoTaskMemFree W32->CoTaskMemFree
  1226. #define CreateBindCtx W32->CreateBindCtx
  1227. #define OleDuplicateData W32->OleDuplicateData
  1228. #define CoTreatAsClass W32->CoTreatAsClass
  1229. #define ProgIDFromCLSID W32->ProgIDFromCLSID
  1230. #define OleConvertIStorageToOLESTREAM W32->OleConvertIStorageToOLESTREAM
  1231. #define OleConvertIStorageToOLESTREAMEx W32->OleConvertIStorageToOLESTREAMEx
  1232. #define OleSave W32->OleSave
  1233. #define StgCreateDocfileOnILockBytes W32->StgCreateDocfileOnILockBytes
  1234. #define CreateILockBytesOnHGlobal W32->CreateILockBytesOnHGlobal
  1235. #define OleCreateLinkToFile W32->OleCreateLinkToFile
  1236. #define CoTaskMemAlloc W32->CoTaskMemAlloc
  1237. #define CoTaskMemRealloc W32->CoTaskMemRealloc
  1238. #define OleInitialize W32->OleInitialize
  1239. #define OleUninitialize W32->OleUninitialize
  1240. #define OleSetClipboard W32->OleSetClipboard
  1241. #define OleFlushClipboard W32->OleFlushClipboard
  1242. #define OleIsCurrentClipboard W32->OleIsCurrentClipboard
  1243. #define DoDragDrop W32->DoDragDrop
  1244. #define OleGetClipboard W32->OleGetClipboard
  1245. #define RegisterDragDrop W32->RegisterDragDrop
  1246. #define OleCreateLinkFromData W32->OleCreateLinkFromData
  1247. #define OleCreateStaticFromData W32->OleCreateStaticFromData
  1248. #define OleDraw W32->OleDraw
  1249. #define OleSetContainedObject W32->OleSetContainedObject
  1250. #define CoDisconnectObject W32->CoDisconnectObject
  1251. #define WriteFmtUserTypeStg W32->WriteFmtUserTypeStg
  1252. #define WriteClassStg W32->WriteClassStg
  1253. #define SetConvertStg W32->SetConvertStg
  1254. #define ReadFmtUserTypeStg W32->ReadFmtUserTypeStg
  1255. #define ReadClassStg W32->ReadClassStg
  1256. #define OleRun W32->OleRun
  1257. #define RevokeDragDrop W32->RevokeDragDrop
  1258. #define CreateStreamOnHGlobal W32->CreateStreamOnHGlobal
  1259. #define GetHGlobalFromStream W32->GetHGlobalFromStream
  1260. #define OleCreateDefaultHandler W32->OleCreateDefaultHandler
  1261. #define CLSIDFromProgID W32->CLSIDFromProgID
  1262. #define OleConvertOLESTREAMToIStorage W32->OleConvertOLESTREAMToIStorage
  1263. #define OleLoad W32->OleLoad
  1264. #define ReleaseStgMedium W32->ReleaseStgMedium
  1265. #define CoCreateInstance W32->CoCreateInstance
  1266. #ifndef NOFEPROCESSING
  1267. #define FSupportSty W32->FSupportSty
  1268. #define PIMEStyleFromAttr W32->PIMEStyleFromAttr
  1269. #define PColorStyleTextFromIMEStyle W32->PColorStyleTextFromIMEStyle
  1270. #define PColorStyleBackFromIMEStyle W32->PColorStyleBackFromIMEStyle
  1271. #define FBoldIMEStyle W32->FBoldIMEStyle
  1272. #define FItalicIMEStyle W32->FItalicIMEStyle
  1273. #define FUlIMEStyle W32->FUlIMEStyle
  1274. #define IdUlIMEStyle W32->IdUlIMEStyle
  1275. #define RGBFromIMEColorStyle W32->RGBFromIMEColorStyle
  1276. #endif // NOFEPROCESSING
  1277. #define fHaveIMMProcs W32->_fHaveIMMProcs
  1278. #define fHaveAIMM W32->_fHaveAIMM
  1279. #define fLoadAIMM10 W32->_fLoadAIMM10
  1280. #define dwPlatformId W32->_dwPlatformId
  1281. #define icr3DDarkShadow W32->_icr3DDarkShadow
  1282. #define MSIMEMouseMsg W32->_MSIMEMouseMsg
  1283. #define MSIMEReconvertMsg W32->_MSIMEReconvertMsg
  1284. #define MSIMEReconvertRequestMsg W32->_MSIMEReconvertRequestMsg
  1285. #define MSIMEDocFeedMsg W32->_MSIMEDocFeedMsg
  1286. #define MSIMEQueryPositionMsg W32->_MSIMEQueryPositionMsg
  1287. #define MSIMEServiceMsg W32->_MSIMEServiceMsg
  1288. #define CharRepFromCharSet W32->CharRepFromCharSet
  1289. #define CharRepFromCodePage W32->CharRepFromCodePage
  1290. #define CharSetFromCharRep W32->CharSetFromCharRep
  1291. #define CodePageFromCharRep W32->CodePageFromCharRep
  1292. #define MECharClass W32->MECharClass
  1293. #define MbcsFromUnicode W32->MbcsFromUnicode
  1294. #define UnicodeFromMbcs W32->UnicodeFromMbcs
  1295. #define TextHGlobalAtoW W32->TextHGlobalAtoW
  1296. #define TextHGlobalWtoA W32->TextHGlobalWtoA
  1297. #define CharRepFromLID W32->CharRepFromLID
  1298. #define In125x W32->In125x
  1299. #define Is8BitCharRep W32->Is8BitCharRep
  1300. #define Is8BitCodePage W32->Is8BitCodePage
  1301. #define IsAlef W32->IsAlef
  1302. #define IsAmbiguous W32->IsAmbiguous
  1303. #define IsBiDiCharRep W32->IsBiDiCharRep
  1304. #define IsBiDiCharSet W32->IsBiDiCharSet
  1305. #define IsBiDiDiacritic W32->IsBiDiDiacritic
  1306. #define IsBiDiKashida W32->IsBiDiKashida
  1307. #define IsBiDiKbdInstalled W32->IsBiDiKbdInstalled
  1308. #define IsDiacritic W32->IsDiacritic
  1309. #define IsDiacriticOrKashida W32->IsDiacriticOrKashida
  1310. #define IsFECharRep W32->IsFECharRep
  1311. #define IsFECharSet W32->IsFECharSet
  1312. #define IsFELCID W32->IsFELCID
  1313. #define IsRTLCharRep W32->IsRTLCharRep
  1314. #define IsRTLCharSet W32->IsRTLCharSet
  1315. #define IsStrongDirectional W32->IsStrongDirectional
  1316. #define IsThaiKbdInstalled W32->IsThaiKbdInstalled
  1317. #define IsIndicKbdInstalled W32->IsIndicKbdInstalled
  1318. #define IsComplexKbdInstalled W32->IsComplexKbdInstalled
  1319. #define IsTrailByte W32->IsTrailByte
  1320. #define IsVietCdmSequenceValid W32->IsVietCdmSequenceValid
  1321. #define GetCharSet W32->GetCharSet
  1322. #define FontSigFromCharRep W32->FontSigFromCharRep
  1323. #define GetFirstAvailCharRep W32->GetFirstAvailCharRep
  1324. #define MatchFECharRep W32->MatchFECharRep
  1325. #define GetKeyboardCharRep W32->GetKeyboardCharRep
  1326. #define GetKeyboardCodePage W32->GetKeyboardCodePage
  1327. #define GetKeyboardLCID W32->GetKeyboardLCID
  1328. #define GetLocaleCharRep W32->GetLocaleCharRep
  1329. #define GetSystemDefaultCodePage W32->GetSystemDefaultCodePage
  1330. #define GetTrailBytesCount W32->GetTrailBytesCount
  1331. #define MBTWC W32->MBTWC
  1332. #define WCTMB W32->WCTMB
  1333. #define VerifyFEString W32->VerifyFEString
  1334. #define GetKerningPairs W32->GetKerningPairs
  1335. #define CharLower W32->CharLower
  1336. #define CharLowerBuff W32->CharLowerBuff
  1337. #define CharUpperBuff W32->CharUpperBuff
  1338. #define CreateIC W32->CreateIC
  1339. #define CreateFile W32->CreateFile
  1340. #define CreateFontIndirect W32->CreateFontIndirect
  1341. #define CompareString W32->CompareString
  1342. #define DefWindowProc W32->DefWindowProc
  1343. #define GetDeadKey W32->GetDeadKey
  1344. #define GetKeyboardFlag W32->GetKeyboardFlag
  1345. #define GetKeyboardFlags W32->GetKeyboardFlags
  1346. #define GetKeyboardLayout W32->GetKeyboardLayout
  1347. #define GetKeyPadNumber W32->GetKeyPadNumber
  1348. #define GetProfileSection W32->GetProfileSection
  1349. #define GetTextMetrics W32->GetTextMetrics
  1350. #define GetTextFace W32->GetTextFace
  1351. #define GetWindowLong W32->GetWindowLong
  1352. #define GetWindowLongPtr W32->GetWindowLongPtr
  1353. #define GetClassLong W32->GetClassLong
  1354. #define InitKeyboardFlags W32->InitKeyboardFlags
  1355. #define IsEnhancedMetafileDC W32->IsEnhancedMetafileDC
  1356. #define LoadBitmap W32->LoadBitmap
  1357. #define LoadCursor W32->LoadCursor
  1358. #define LoadLibrary W32->LoadLibrary
  1359. #define ResetKeyboardFlag W32->ResetKeyboardFlag
  1360. #define SendMessage W32->SendMessage
  1361. #define SetDeadKey W32->SetDeadKey
  1362. #define SetKeyboardFlag W32->SetKeyboardFlag
  1363. #define SetKeyPadNumber W32->SetKeyPadNumber
  1364. #define SetWindowLong W32->SetWindowLong
  1365. #define SetWindowLongPtr W32->SetWindowLongPtr
  1366. #define PostMessage W32->PostMessage
  1367. #define lstrcmpi W32->lstrcmpi
  1368. #define PeekMessage W32->PeekMessage
  1369. #define WinLPtoDP W32->WinLPtoDP
  1370. #define WinDPtoLP W32->WinDPtoLP
  1371. #define MulDiv W32->MulDivFunc
  1372. #define InflateRect W32->InflateRect
  1373. #define PtInRect W32->PtInRect
  1374. #define IntersectRect W32->IntersectRect
  1375. #define InflateRect W32->InflateRect
  1376. #define PtInRect W32->PtInRect
  1377. #define IntersectRect W32->IntersectRect
  1378. // AIMM wrapper
  1379. #define IsAIMMLoaded W32->IsAIMMLoaded
  1380. #define LoadAIMM W32->LoadAIMM
  1381. #define CallAIMMDefaultWndProc W32->AIMMDefWndProc
  1382. #define GetAIMMKeyboardCP W32->AIMMGetCodePage
  1383. #define ActivateAIMM W32->AIMMActivate
  1384. #define DeactivateAIMM W32->AIMMDeactivate
  1385. #define FilterClientWindowsAIMM W32->AIMMFilterClientWindows
  1386. #define UnfilterClientWindowsAIMM W32->AIMMUnfilterClientWindows
  1387. #define sprintf W32->sprintf
  1388. #ifdef DEBUG
  1389. #define strrchr W32->strrchr
  1390. #define strcmp W32->strcmp
  1391. #define strcat W32->strcat
  1392. #endif
  1393. #define wcslen W32->wcslen
  1394. #define wcscpy W32->wcscpy
  1395. #define wcscmp W32->wcscmp
  1396. #define wcsicmp W32->wcsicmp
  1397. #define wcsncpy W32->wcsncpy
  1398. #define W32GetLayout (*W32->_pfnGetLayout)
  1399. #define W32SetLayout (*W32->_pfnSetLayout)
  1400. #define GetTmpTextColor(a, b) W32->GetTmpColor(a, b, GET_TEMP_TEXT_COLOR)
  1401. #define GetTmpBackColor(a, b) W32->GetTmpColor(a, b, GET_TEMP_BACK_COLOR)
  1402. #define GetTmpUnderlineColor(a, b) W32->GetTmpColor(a, b, GET_TEMP_UL_COLOR)
  1403. #define GetTmpDisplayAttrIdx W32->GetTmpDisplayAttrIdx
  1404. #define GetTmpUnderline W32->GetTmpUnderline
  1405. #define GetACP W32->GetACP
  1406. #define GetSysLCID W32->GetSysLCID
  1407. #define SetTextAlign W32->SetTextAlign
  1408. #define InvertRect W32->InvertRect
  1409. #endif // !defined(W32SYS_CPP)
  1410. #ifndef offsetof
  1411. #define offsetof(s,m) ((size_t)&(((s*)0)->m))
  1412. #endif
  1413. #ifdef UNDER_CE
  1414. // The follwing definitions do not exist in the Windows CE environment but we emulate them.
  1415. // The values have been copied from the appropriate win32 header files.
  1416. // These definitions should be removed if Ce adds them
  1417. // Scroll Bars
  1418. #ifndef ESB_ENABLE_BOTH
  1419. #define ESB_ENABLE_BOTH 0x0000
  1420. #define ESB_DISABLE_BOTH 0x0003
  1421. #endif
  1422. // Text alignment values
  1423. #ifndef TA_TOP
  1424. #define TA_TOP 0
  1425. #define TA_BOTTOM 8
  1426. #define TA_BASELINE 24
  1427. #define TA_CENTER 6
  1428. #define TA_LEFT 0
  1429. #define TA_RIGHT 2
  1430. #endif
  1431. // Device Technology. This one is mostly used for exclusion
  1432. #ifndef DT_METAFILE
  1433. #define DT_METAFILE 5 // Metafile, VDM
  1434. #endif
  1435. // FInd/Replace options
  1436. #ifndef FR_DOWN
  1437. #define FR_DOWN 0x00000001
  1438. #define FR_WHOLEWORD 0x00000002
  1439. #define FR_MATCHCASE 0x00000004
  1440. #endif
  1441. // Window messages
  1442. #ifndef WM_NCMOUSEMOVE
  1443. #define WM_NCMOUSEMOVE 0x00A0
  1444. #endif
  1445. #ifndef WM_NCMBUTTONDBLCLK
  1446. #define WM_NCMBUTTONDBLCLK 0x00A9
  1447. #endif
  1448. #ifndef WM_DROPFILES
  1449. #define WM_DROPFILES 0x0233
  1450. #endif
  1451. // Clipboard formats
  1452. #ifndef CF_METAFILEPICT
  1453. #define CF_METAFILEPICT 3
  1454. #endif
  1455. /* Pen Styles : Windows CE only supports PS_DASH */
  1456. #ifndef PS_DOT
  1457. #define PS_DOT PS_DASH
  1458. #endif
  1459. #ifndef PS_DASHDOT
  1460. #define PS_DASHDOT PS_DASH
  1461. #endif
  1462. #ifndef PS_DASHDOTDOT
  1463. #define PS_DASHDOTDOT PS_DASH
  1464. #endif
  1465. // Missing APIs
  1466. #define GetMessageTime() 0
  1467. #define IsIconic(hwnd) 0
  1468. #define SetWindowOrgEx(hdc, xOrg, yOrg, pt)
  1469. #define SetViewportExtEx(hdc, nX, nY, lpSize)
  1470. #define SetWindowExtEx(hdc, x, y, lpSize)
  1471. // Unsupported messages.
  1472. // FUTURE : Perhaps we should ifdef the code the messages control
  1473. #ifndef WS_EX_TRANSPARENT
  1474. #define WS_EX_TRANSPARENT 0x00000020L
  1475. #endif
  1476. #ifndef WM_MOUSEACTIVATE
  1477. #define WM_MOUSEACTIVATE 0x0021
  1478. #endif
  1479. #ifndef WM_SYSCOLORCHANGE
  1480. #define WM_SYSCOLORCHANGE 0x0015
  1481. #endif
  1482. #ifndef WM_STYLECHANGING
  1483. #define WM_STYLECHANGING 0x007C
  1484. #endif
  1485. #ifndef WM_WINDOWPOSCHANGING
  1486. #define WM_WINDOWPOSCHANGING 0x0046
  1487. #endif
  1488. #ifndef WM_SETCURSOR
  1489. #define WM_SETCURSOR 0x0020
  1490. #endif
  1491. #ifndef WM_NCPAINT
  1492. #define WM_NCPAINT 0x0085
  1493. #endif
  1494. #ifndef SM_SWAPBUTTON
  1495. #define SM_SWAPBUTTON 23
  1496. #endif
  1497. #ifndef TPM_RIGHTBUTTON
  1498. #define TPM_RIGHTBUTTON 0x0002L
  1499. #endif
  1500. #define RegisterClipboardFormatA(s) RegisterClipboardFormatW(TEXT(s))
  1501. /*
  1502. * EDITWORDBREAKPROC
  1503. */
  1504. typedef int (CALLBACK* EDITWORDBREAKPROC)(LPWSTR lpch, int ichCurrent, int cch, int code);
  1505. #ifndef WB_LEFT
  1506. #define WB_LEFT 0
  1507. #define WB_RIGHT 1
  1508. #define WB_ISDELIMITER 2
  1509. #endif
  1510. #ifndef OUT_TT_ONLY_PRECIS
  1511. #define OUT_TT_ONLY_PRECIS 7
  1512. #endif
  1513. // Mapping Modes : Win CE only supports MM_TEXT
  1514. #ifndef MM_TEXT
  1515. #define MM_TEXT 1
  1516. #define SetMapMode(hdc, mapmode)
  1517. WINGDIAPI inline int WINAPI GetMapMode(HDC)
  1518. {
  1519. return MM_TEXT;
  1520. }
  1521. #endif
  1522. #ifndef HANGUL_CHARSET
  1523. #define HANGUL_CHARSET HANGEUL_CHARSET
  1524. #endif
  1525. #endif // UNDER_CE
  1526. #endif // _W32SYS_H