字体、语言相关的API函数原型:
0 g- g0 T5 _* ]# Y: M
7 p4 Z) a& }8 E% k7 _createFont 用指定的属性创建一种逻辑字体 % g' a' c6 X2 _5 J7 C2 u" K- V1 [& A
createFontIndirect 用指定的属性创建一种逻辑字体
# d3 q( s$ t' t# `% VGetStockObject 取得一个固有对象(笔、刷子、字体等)
& L7 s' v+ D* b9 y4 x, z4 n$ v2 M" i/ d0 @" e
GetACP 检取ANSI系统代码页的标识符
% ~; V% F6 y& v, M& zGetOEMCP 检取系统的OEM代码页标识符 q: A7 W" U* r- d6 i4 f8 V I% u
GetTextExtentPoint 判断一个字串的大小(范围)(用于限制输入)- C6 r9 w# X R
EnumFontFamilies 列举指定设备可用的字体
( h0 w5 p- P6 ]% U, t p& S$ sEnumFontFamiliesEx 列举指定设备可用的字体
4 M- g4 V6 u7 M( u# H- {/ _3 wEnumFonts 列举指定设备可用的字体
. e/ v' D' f. HGetSystemDefaultLangID 取得系统的默认语言ID
2 Y1 }2 W: A( O( _9 q4 uGetUserDefaultLangID 为当前用户取得默认语言ID& D$ y5 z# `9 C( D1 Q- n8 C
GetStringTypeA 获取ANSI字符串类型 ,返回指定字符串的字符类型信息7 ~ a5 P: } C
GetStringTypeW 返回一个Unicode串的字符类型信息6 l* _$ G W7 C, p. B- ^
GetSystemDefaultLangID 检取系统缺省语言标识符4 v5 p9 \) N" f: ]1 H
WideCharToMultiByte 把一个宽字符串映射为一个新字符串! {' l6 k9 J5 k" G: |$ | a- s
# ^) J5 ~& ?% S=====================================================================
- c- P! N) F# [2 v* T
! c3 K$ r/ K/ |0 J: {. u8 N6 y7 xHFONT CreateFont(
" [; d: | E1 a. l: O" G7 M
+ b1 R/ S; u( \0 i6 ~7 j) uint nHeight, // logical height of font ; H( @* t, t' D* S) O
int nWidth, // logical average character width 0 K! }8 \- a9 A* J6 R
int nEscapement, // angle of escapement
' h5 `+ X$ H; B$ o! Aint nOrientation, // base-line orientation angle ! Z+ B7 g4 s3 W8 U7 D8 A
int fnWeight, // font weight
$ N, U+ V! n* q3 f1 WDWORD fdwItalic, // italic attribute flag
y8 B7 T# V4 ]DWORD fdwUnderline, // underline attribute flag
9 U; m: u- I* @: YDWORD fdwStrikeOut, // strikeout attribute flag
/ P$ T4 [& i: H' q' D8 d$ r& XDWORD fdwCharSet, // character set identifier
2 `: x3 y/ V! \2 DDWORD fdwOutputPrecision, // output precision
w: s$ z/ P7 y# a) Y% P9 q* eDWORD fdwClipPrecision, // clipping precision
/ A+ S; ]2 }3 _$ JDWORD fdwQuality, // output quality " V) T @8 L) \; c0 W) Z u
DWORD fdwPitchAndFamily, // pitch and family 3 v4 c( c f) R: A" U% W) \
LPCTSTR lpszFace // pointer to typeface name string * j3 X# Y" ^4 c2 p; j
);0 r0 `# a0 I8 _( I) V. v( |2 l. S& k
* `$ v8 j( A- T: |6 D# L7 k. B
==========================================================================
, k) Q' J) ~5 M& y: f6 OHFONT CreateFontIndirect(# Y" r5 b, l+ e- W% t
1 a/ W+ `! w; Y9 U( T
CONST LOGFONT *lplf // pointer to logical font structure
P7 \9 T' q$ A. n# d/ i);
7 y8 I+ A' C2 k( j( e6 c- k3 k5 I/ x2 C7 z8 Y* P
==========================================================================
) [, A" M8 L) e/ SHGDIOBJ GetStockObject(
& o. o: [: U" G
9 e4 ~* [; [2 f& wint fnObject // type of stock object : w& _& p- a0 o8 C8 S
);; R# A1 F4 p3 x' \; D) l9 S& r
) v, g; t2 |+ u i: {. q0 U6 ^$ Y3 p- t0 | G v& h* l- g
fnObject* V9 f8 N, V- |6 j8 K
Specifies the type of stock object. This parameter can be any one of the following values: ( O$ y( I: J, H+ O9 ?* V
Value ; x/ }1 y2 o% d' y" e
4.BLACK_BRUSH Black brush.
3 Y' [! C. ]1 D4 f( X* c3.DKGRAY_BRUSH Dark gray brush.
; B& f$ {- P7 k/ W2.GRAY_BRUSH Gray brush." q( e1 `; E# L; T' ^5 P$ ?
5.HOLLOW_BRUSH Hollow brush (equivalent to NULL_BRUSH).
1 e% X- Y& e2 l; E T1.LTGRAY_BRUSH Light gray brush.& t+ e" l4 u) ~- \
5.NULL_BRUSH Null brush (equivalent to HOLLOW_BRUSH).
# I; p2 C# y0 {- x7 R% v! Q0.WHITE_BRUSH White brush.
: E7 J. a% S+ Q+ n1 p# s7.BLACK_PEN Black pen.( A1 J! w0 c' t3 }( {2 `
8.NULL_PEN Null pen.- \0 R( b% j: m3 |0 C: i1 U5 U; a4 K/ L
6.WHITE_PEN White pen.7 X$ |* H' r! d- [ G
11.(0B)ANSI_FIXED_FONT Windows fixed-pitch (monospace) system font." l+ Y' O$ V; Y) N6 n
12.(0C)ANSI_VAR_FONT Windows variable-pitch (proportional space) system font.
# S3 f# C2 y' f' Z, P; e7 ~14.(0E)DEVICE_DEFAULT_FONT Windows NT only: Device-dependent font.6 Z( W9 L H. l, E$ l
17.(11)DEFAULT_GUI_FONT Windows 95 only: Default font for user interface objects such as menus and dialog boxes.(一般选这种)6 n. T( R+ I. f) _& r `/ h
10.(0A)OEM_FIXED_FONT Original equipment manufacturer (OEM) dependent fixed-pitch (monospace) font.# Y5 \- N1 C4 @ z
13.(0D)SYSTEM_FONT System font. By default, Windows uses the system font to draw menus, dialog box controls, and text. In Windows versions 3.0 and later, the system font is a proportionally spaced font; earlier versions of Windows used a monospace system font.) S' H" E: _1 T+ S. ~
16.(10)SYSTEM_FIXED_FONT Fixed-pitch (monospace) system font used in Windows versions earlier than 3.0. This stock object is provided for compatibility with earlier versions of Windows., N k& a0 ^2 t/ C- N- I0 K' v8 Q
15.DEFAULT_PALETTE Default palette. This palette consists of the static colors in the system palette.
2 }4 q; h0 ~- Y) O- V" S. B- ]" Z6 PIf the function succeeds, the return value identifies the logical object requested.3 ?8 n8 w9 }+ u) K: B1 m
If the function fails, the return value is NULL. ' C9 @1 O; Q+ E5 a
=================================================================================/ j7 Y7 Q, {' d/ U8 b# h: l* o
The GetACP function retrieves the current ANSI code-page identifier for the system.
) y' N' d& l: E$ N4 O/ OUINT GetACP(VOID)! ~ ?1 S- X6 D5 s; \& P, u
3 ?( v8 n* l8 X* V$ `3 }- w6 |
Parameters
1 ~. O! \/ Q0 G$ F% lThis function has no parameters.
! }8 M9 [) g0 _Return Values
7 F) E t# F. T6 X# x4 eIf the function succeeds, the return value is the current ANSI code-page identifier for the system, or a default identifier if no code page is current.$ S8 c. ~. q* l0 o" T& c0 _8 z* q9 `
Remarks1 p4 {. M4 F; i3 |
Following are the ANSI code-page identifiers:
5 j# s7 V- u5 n0 F2 @( oIdentifier Meaning R! [: @* k3 x( r0 F h+ g( |) n
874 Thai
! U$ T) l6 l3 m/ A932 Japan
9 W, z- a$ a9 S! U' J) E936 Chinese (PRC, Singapore)/ ]2 ?$ J5 G" N9 S6 s
949 Korean
, G4 Y" I. Q$ f# R( R950 Chinese (Taiwan, Hong Kong) % Y5 a, A3 c1 D/ t+ d9 X- u Y6 R
1200 Unicode (BMP of ISO 10646)
$ W" p1 \* x* U3 F( t& x, w; u1250 Windows 3.1 Eastern European
7 }4 E$ A' x, r% {1251 Windows 3.1 Cyrillic6 W3 j8 j% P/ d6 b; W
1252 Windows 3.1 Latin 1 (US, Western Europe)
+ b3 |+ X/ |$ e6 v1253 Windows 3.1 Greek; G3 }; o: z9 `' |8 N
1254 Windows 3.1 Turkish
! L y `1 |$ a1 ?% v1255 Hebrew) L, J9 p; ]3 `! T3 X% a( j
1256 Arabic1 `+ j2 x( x: Y3 `
1257 Baltic
3 T' v; @8 M8 g3 ]8 [. g" T=============================================================================* \' T% R3 s% z" ?% `$ B3 `
The GetOEMCP function retrieves the current OEM code-page identifier for the system. (OEM stands for original equipment manufacturer.) 0 A- G7 z4 V1 t4 Z* {1 I8 X
- n6 P/ i! N1 x
UINT GetOEMCP(VOID)8 Y& N) p* x0 K: n h
. P7 V* v' H( [, R% @ @; a+ O5 U ?" c/ ?8 i4 r& D
Parameters
$ l9 p3 |: S2 ?! o% n" a9 ]& n* U/ ]9 p$ K
This function has no parameters. 7 q6 E G7 k' p
8 B( ?! o8 I1 O; wReturn Values
5 J8 r2 q o! z- s% X+ y+ c& a& ^8 S" D# S3 h) P T; N4 o1 h( X% Z
If the function succeeds, the return value is the current OEM code-page identifier for the system or a default identifier if no code page is current.$ b( ^8 x5 p* i# g
' S5 J5 G: g1 q: C. h
Remarks
* ?0 o! x+ B1 E) s! w5 g9 Y8 P( E! B% V/ T. M- W: E$ ]
Following are the OEM code-page identifiers:
' K' t5 }; _6 l1 w" l. [, a" R
9 |' r* i7 b8 x7 ^7 v7 D) _Identifier Meaning# A0 n. h& g% l$ o2 l% y$ n
437 MS-DOS United States' ~) A. Q) j/ U; ]# }* T$ Z; _
708 Arabic (ASMO 708)/ j0 w s; C$ m( [( X
709 Arabic (ASMO 449+, BCON V4)) ?4 e0 u! N3 b" ^" ^
710 Arabic (Transparent Arabic)
$ N* h/ p: Q3 F& G$ P720 Arabic (Transparent ASMO)' j$ B9 F: ~. ^8 z/ L
737 Greek (formerly 437G)! C0 j% [9 n, m! y0 U5 F0 r
775 Baltic
/ V7 }0 ^/ o* \! v850 MS-DOS Multilingual (Latin I)
" w6 s$ G# l+ n/ ?" [! d852 MS-DOS Slavic (Latin II)
( z" y6 B" c2 s2 b8 ^855 IBM Cyrillic (primarily Russian)
0 v( j% h' D& e; _5 {857 IBM Turkish) O, F8 Z* p ~; i2 m1 _
860 MS-DOS Portuguese
3 j; j8 w2 X0 w1 h, y; N7 G+ m861 MS-DOS Icelandic$ D+ c( Z, A1 a; L- K
862 Hebrew* W9 v. q" E% c/ Z' z
863 MS-DOS Canadian-French
& R) v/ {' w* O, c3 e! q. H2 X864 Arabic' g" v# u$ l7 T4 z; u, t$ J g
865 MS-DOS Nordic( q7 q: r5 {' n% U8 s ]. `$ @
866 MS-DOS Russian (former USSR)
: Z% Z, L7 ^; c9 A; t869 IBM Modern Greek3 h! b) O+ x2 \) _
874 Thai7 P k I( Q. O
932 Japan
, N: h1 ^9 S7 X" i7 x i6 _: Z& t936 Chinese (PRC, Singapore), x5 R8 ~4 S& U, N
949 Korean
( u+ v! U# j+ n2 I0 j2 j950 Chinese (Taiwan, Hong Kong)
6 o8 j8 P3 N8 ]% a8 w7 H1361 Korean (Johab)
: m4 y, P: C* t& x2 N' t! Q===============================================================================" Q& V8 a" D% V0 l4 h
BOOL GetTextExtentPoint(
6 y: y! \4 Z3 C" g3 u0 n4 ?7 a$ k, ~1 `" h. T
HDC hdc, // handle of device context
: ?* h4 g- o9 L0 o1 WLPCTSTR lpString, // address of text string & g- a# ^4 X: F+ t
int cbString, // number of characters in string
: U/ V3 i8 o' ~( ?LPSIZE lpSize // address of structure for string size
1 N) t' `% x0 `& C0 @+ x/ H( l" i& |; i);
7 m) R! |1 R& V2 F$ F! S/ h, y. R5 M===============================================================================
7 X9 y f; S# `6 A; _7 } iThe EnumFontFamilies function enumerates the fonts in a specified font family that are available on a specified device. This function supersedes the EnumFonts function. 9 P9 z1 ^5 A5 s1 k+ u
int EnumFontFamilies(
+ i+ U5 I' R% g3 r" ^% ]HDC hdc, // handle to device control
, h8 x! x2 `# j. p6 A: ^LPCTSTR lpszFamily, // pointer to family-name string
. s2 l1 {9 O$ ?' S2 I. S; I# m9 IFONTENUMPROC lpEnumFontFamProc, // pointer to callback function 5 v' |' N" u8 G4 f" p3 b& h2 u
LPARAM lParam // address of application-supplied data
! ~ S- {( W6 Q# f2 }+ K5 [5 T# J. `);
* w3 V4 a3 ] z) b& Z1 G5 V1 b2 U
Parameters
# o d$ P c9 C! o$ fhdc" u- D9 ^( B/ o# m4 n$ M
Identifies the device context.
9 b2 @% D' O" MlpszFamily0 g4 w, O% X0 w! E7 F# m/ {
Points to a null-terminated string that specifies the family name of the desired fonts. If lpszFamily is NULL, EnumFontFamilies randomly selects and enumerates one font of each available type family. 6 N, c/ Y/ Q7 i- }2 {0 U+ n
lpEnumFontFamProc
$ W- D- y9 _- Z9 g1 }( aSpecifies the procedure-instance address of the application-defined callback function. For information about the callback function, see the EnumFontFamProc function. 0 Z8 U9 }- a3 i7 U# M: A& G
lParam: u, p8 ~5 p# ]9 C2 _6 r
Points to application-supplied data. The data is passed to the callback function along with the font information. ) a9 a, Y( T: f' ?( g
% @! G5 s$ w" r8 R- E* ~! EReturn Values
# r( s1 }( d4 ~& ^If the function succeeds, the return value is the last value returned by the callback function. Its meaning is implementation specific.
6 f9 `- z& e$ ?=============================================================================
: [6 S* P6 r! H1 g5 x2 w# _* DThe EnumFontFamiliesEx function enumerates all fonts in the system that match the font characteristics specified by the
; k5 t7 J0 l8 m- h" g, R8 BLOGFONT structure. EnumFontFamiliesEx enumerates fonts based on typeface name, character set, or both. It is recommended that Win32-based applications use this function rather than EnumFontFamilies to enumerate fonts.4 Z j8 ?) {& K4 l8 k! I% R" c
: X* E- K9 T) ]$ V. T
int EnumFontFamiliesEx(7 l% @# ~+ f, J5 L2 q( I" ^# O
HDC hdc, // handle to device context! f& S$ l% e' E& s. l2 l
LPLOGFONT lpLogfont, // pointer to logical font information. @ ~2 q- Y7 O) V1 g9 s
FONTENUMPROC lpEnumFontFamExProc, // pointer to callback function
( L! O/ ?. O+ K! U0 @3 NLPARAM lParam, // application-supplied data
5 c6 M1 U7 l& z6 X2 h, }DWORD dwFlags // reserved; must be zero
$ }2 [1 z/ s, o' K7 I1 {- H);/ C) {& Z8 n& e# e# |- Z7 } u, o
================================================================================= W; ^: R' c m; t, V
The EnumFonts function enumerates the fonts available on a specified device. For each font with the specified typeface name, the EnumFonts function retrieves information about that font and passes it to the application-defined callback function. This callback function can process the font information as desired. Enumeration continues until there are no more fonts or the callback function returns zero. 0 d/ h2 ]) l( M$ Y' H }. m
This function is provided for compatibility with earlier versions of Microsoft Windows. Win32-based applications should use the EnumFontFamilies function.' h) X" t% w+ T8 m
, l% z$ v8 L$ N9 S/ j& s* ?int EnumFonts(4 [( {1 j1 `6 a4 @; y/ H+ R
HDC hdc, // handle to device context ; f9 U* g; K" @ t A7 ~2 O3 z
LPCTSTR lpFaceName, // pointer to font typeface name string 1 C+ N/ Y; {( s4 d$ g }
FONTENUMPROC lpFontFunc, // pointer to callback function * W7 q3 R0 A; @$ P4 T2 l- S
LPARAM lParam // address of application-supplied data
3 q8 O0 c7 N# z);
7 B5 K7 H2 ]6 K* X+ c! l3 |. i" i4 j6 G! x; r! P$ s, Q1 `
Parameters& c2 p7 k4 v* m6 U. c) H3 y! _2 [
hdc
, t4 o* g1 N- v' HIdentifies the device context. ! Q. c+ C; R* ]
lpFaceName( b% ^3 |7 c$ i5 |" b# G& O2 _
Points to a null-terminated character string that specifies the typeface name of the desired fonts. If lpFaceName is NULL, EnumFonts randomly selects and enumerates one font of each available typeface.
# E7 H4 D1 @; f8 T8 tlpFontFunc/ s/ i y: W6 D& L8 J
Points to the application-defined callback function. For more information about the callback function, see the EnumFontsProc function. E& _2 r& U: a* x
lParam4 t, d1 C' s" X" r4 ]0 ]& C \+ M
Points to any application-defined data. The data is passed to the callback function along with the font information.
1 o2 M$ d4 K' n- Z
% [9 D4 ~8 ]) G* R, D7 ~1 N, Z9 x, a) h& e4 d
Return Values
, ~( a/ ~: G; j3 Q: rIf the function succeeds, the return value is the last value returned by the callback function. Its meaning is defined by the application.
% N2 ]4 a! r% O+ ]======================================================================2 m3 |4 W, H5 k/ t4 e3 ]
The GetSystemDefaultLangID function retrieves the system default language identifier.
; ?4 d2 q+ m+ n9 k0 @0 \1 J, J; d% o6 {4 \$ P4 m/ @* D" l
LANGID GetSystemDefaultLangID(VOID)& p7 L9 R" h/ v: R- w; y
. H/ W. r1 U. BParameters
1 E {: l/ J" y6 bThis function has no parameters. 8 U: e$ B, |4 M9 f; j2 I- u! a$ l
Return Values- W8 O9 J2 X: D; n1 _& N
If the function succeeds, the return value is the system default language identifier.
O( L5 H0 q$ v: _================================================================================( w: y4 V) T# D. O
The GetUserDefaultLangID function retrieves the user default language identifier.
, y- p/ ~0 s% J+ T
" R2 X' \" L) r) L6 r3 x$ E7 ?LANGID GetUserDefaultLangID(VOID)3 a9 J2 M8 v8 P. v5 x
, _1 g4 O) y$ b) D* YParameters
# q$ M# d+ D) d( J7 V4 S; OThis function has no parameters.
0 ?$ i& r0 M# f$ V' M* T" w% y" d4 \! a' jReturn Values& _' ]# N- M' w8 v
If the function succeeds, the return value is the user default language identifier.
3 c0 M: |" J( L================================================================================0 z$ T9 J7 r3 `4 n8 {' M
& d8 G& E8 F a" n6 L1 CBOOL GetStringTypeA(7 k, B2 j. o H5 M3 E' r+ X
3 H* I# `& e8 n" |( v- i
LCID Locale, // locale identifer
( P9 r4 O$ p6 IDWORD dwInfoType, // information-type options : R" i" h% X7 s1 S* f3 |" x
LPCSTR lpSrcStr, // pointer to the source string 2 \7 l m3 C9 q/ I/ O
int cchSrc, // size, in bytes, of the source string
: E4 \% F5 `8 x4 L( x1 NLPWORD lpCharType // pointer to the buffer for output 9 u: n8 [- Y3 e5 ^- }
);$ [7 s3 X! S2 s# {
Parameters
" y5 I" t$ ^2 ~) @" }* dLocale! ?$ J1 c3 R0 e- O% G
LOCALE_SYSTEM_DEFAULT Default system locale
) w' G) W0 t ]! g9 C; R* U' Q, CLOCALE_USER_DEFAULT Default user locale2 }8 ?2 f. \) t! j
dwInfoType
2 g6 s6 T, c/ I# v) ]CT_CTYPE1 Retrieve character type information.9 X6 F( [, S8 L4 B$ k- f3 ^: W6 M( ]
CT_CTYPE2 Retrieve bidirectional layout information.5 q+ V4 A5 I a M0 G- M
CT_CTYPE3 Retrieve text processing information.
$ C2 `0 H9 p) F- n3 KlpSrcStr
; i( d* Y9 B& K! d4 T X9 cPoints to the string for which character types are requested. If cchSrc is -1, the string is assumed to be null terminated. This must be an ANSI string. Note that this can be a double-byte character set (DBCS) string if the locale is appropriate for DBCS.
( S: }* @5 x; @5 E0 |& ^' kcchSrc$ y" M8 v' `2 `' s& {6 L1 V$ s2 I" g* m1 a
Specifies the size, in bytes, of the string pointed to by the lpSrcStr parameter. If this count includes a null terminator, the function returns character type information for the null terminator. If this value is -1, the string is assumed to be null terminated and the length is calculated automatically. ) c- U% ]$ ^& n* @8 P8 R
lpCharType; v9 ]* R' Q: ~0 _8 A
Points to an array of 16-bit values. The length of this array must be large enough to receive one 16-bit value for each character in the source string. When the function returns, this array contains one word corresponding to each character in the source string. ) E. Z( g# W. x6 F
5 v6 @* n+ ~+ B+ ]
Return Values7 ^0 S/ j% J+ m P3 ?
If the function succeeds, the return value is nonzero.6 X0 B% o0 f0 V
=================================================================8 ~$ T3 M( d, G. V9 [2 C
BOOL GetStringTypeW(
9 e4 \7 u* x8 g5 k- _2 p. J. p, R( l* Q3 I
DWORD dwInfoType, // information-type options / @3 O9 |' N7 D' l
LPCWSTR lpSrcStr, // address of source string
2 P; D7 f0 t3 p% fint cchSrc, // number of characters in string
6 H8 f- H& e8 J0 C" x6 YLPWORD lpCharType // address of buffer for output ) L& O) _. k* K8 V! l. U7 V: J
);! d: w3 f; X8 }. G; a# L
==========================================================================
4 \2 w% m4 d, z9 JThe GetSystemDefaultLangID function retrieves the system default language identifier. % A' z! l) v. d% L8 f
LANGID GetSystemDefaultLangID(VOID)0 g0 t! {3 h/ H
7 c' V" e! P; g- u. f- x+ U
2 @4 e0 m4 _5 P1 OParameters r4 R; v) f) u z- X3 v
This function has no parameters. # L2 c7 ^6 J, b1 u: j D
9 N4 J/ `/ U$ Q4 Y& _2 o4 Q3 O& x
Return Values8 K0 {" K! p- W" m! b, V" w
If the function succeeds, the return value is the system default language identifier.' O. m+ }- j) i" p# B# O9 g+ f
5 J1 ?9 y+ J" c* G+ Z+ ^, n- Z. D
Remarks+ X5 R1 Q6 |+ Z. U' E4 B! ]
For more information about language identifiers, see Language Identifiers and Locales.& _! m) M5 X: e+ v: i. C C( p `
===============================================================================+ R: E$ P$ O4 j1 W. h
int WideCharToMultiByte(: [8 {2 D% m/ W
& b- m# l, D$ B. C0 U3 w6 X- d3 _
UINT CodePage, // code page
/ @% B+ Z$ \0 H- W8 h. I, F' cDWORD dwFlags, // performance and mapping flags
. A2 E1 g) t6 H" s! m( ~; Q& B0 VLPCWSTR lpWideCharStr, // address of wide-character string 1 T& C( W" v' j m* O2 M; Y$ S' j
int cchWideChar, // number of characters in string
$ V* i) r; \8 J, N4 C' mLPSTR lpMultiByteStr, // address of buffer for new string , p% @( ~7 s; ?8 Q" K1 U
int cchMultiByte, // size of buffer 4 n1 r) s; [& Y/ _2 g% w1 h
LPCSTR lpDefaultChar, // address of default for unmappable characters 9 S) ^% ]" k; w+ E$ }' p
LPBOOL lpUsedDefaultChar // address of flag set when default char. used
; s/ m- h9 ^( x6 V, v* N% f* x- \, |); & z7 T1 h8 i( k. ~& [
% D1 i, L$ p7 W1 \: s" m! m. S
2 W) L$ L# D+ O$ k4 G4 r* G
Parameters
o# Z! F4 V M. |
( l) O6 d* b x, G$ o1 s2 MCodePage" n- X9 N! J& r& i9 P! F7 J
Specifies the code page used to perform the conversion. This parameter can be given the value of any codepage that is installed or available in the system. The following values may be used to specify one of the system default code pages:
- ?( X+ w5 C, m' ~6 ^
8 o: {: ]! ~& m! s EValue Meaning4 ?0 I& ^& @! V6 w( C
CP_ACP ANSI code page4 y. |: `+ x) j, K6 Z' P/ ~$ H% N
CP_MACCP Macintosh code page n/ ~6 A v/ |# X* W4 w
CP_OEMCP OEM code page
9 g3 U0 N# S/ `+ f: S
) j# ~: O g" OdwFlags
4 r9 }: `. i6 g$ N# F K2 U$ iA set of bit flags that specify the handling of unmapped characters. The function performs more quickly when none of these flags is set. The following flag constants are defined:
8 L5 O; z. s1 B) t! ~- I# M# V3 [9 \3 \8 K- P9 L' |/ t) @! ?) Z
Value Meaning
: J7 X6 v% {+ {4 a0 {7 gWC_COMPOSITECHECK Convert composite characters to precomposed characters.
+ Q8 P3 g2 g; f) b& tWC_DISCARDNS Discard nonspacing characters during conversion.. [2 V( N: L9 M0 Z9 |! N
WC_SEPCHARS Generate separate characters during conversion. This is the default conversion behavior./ R' l( ]6 I' k9 k2 X
WC_DEFAULTCHAR Replace exceptions with the default character during conversion.
' H" ]" D8 t1 X" G {
, Z. R" \3 o+ f5 Y+ MWhen WC_COMPOSITECHECK is specified, the function converts composite characters to precomposed characters. A composite character consists of a base character and a nonspacing character, each having different character values. A precomposed character has a single character value for a base/nonspacing character combination. In the character ? the
* K( G/ f( {7 |# J# ?e is the base character, and the accent grave mark is the nonspacing character.- {) [, J# w3 u
3 G; o# B: i' K$ z2 W
When an application specifies WC_COMPOSITECHECK, it can use the last 3 flags in this list (WC_DISCARDNS, WC_SEPCHARS, and WC_DEFAULTCHAR) to customize the conversion to precomposed characters. These flags determine the functions behavior when there is no precomposed mapping for a base/nonspace character combination in a wide-character string. These last 3 flags can only be used if the WC_COMPOSITECHECK flag is set.. q3 y$ Z$ V3 X- m7 \6 t
The functions default behavior is to generate separate characters (WC_SEPCHARS) for unmapped composite characters.( p* g/ E! D7 D% z- p, U
+ y5 Q: _3 g3 I. [8 s
lpWideCharStr% E, b2 V" ?! L* ]
Points to the wide-character string to be converted. ; i5 U1 ]* `. L: \ n' ~$ m# t
" ^" J" @# Q' ucchWideChar
" N( s Y4 B0 l/ q* ZSpecifies the number of characters in the string pointed to by the lpWideCharStr parameter. If this value is -1, the string is assumed to be null-terminated and the length is calculated automatically.
) K+ e4 }/ ?" t1 |
- c( g0 D- X/ D% {9 F4 L! P* `lpMultiByteStr" f8 X# V) ?, V0 G- i2 N, {
Points to the buffer to receive the translated string.
" H) u* b2 ]0 m0 ^8 B* T) t+ ?2 L0 {" p
cchMultiByte. P) c% e8 C7 \2 \
Specifies the size in characters of the buffer pointed to by the lpMultiByteStr parameter. If this value is zero, the function returns the number of bytes required for the buffer. (In this case, the lpMultiByteStr buffer is not used.)
' N9 r% s3 d+ W* x1 d# z$ d* O! ?; n) w; k3 A7 [* Y, ]+ U
lpDefaultChar' W, h2 {" k# k8 j
Points to the character used if a wide character cannot be represented in the specified code page. If this parameter is NULL, a system default value is used. The function is faster when both lpDefaultChar and lpUsedDefaultChar are NULL. ( @) c5 p% a# @' A
& l3 z, ~) H( T' s$ blpUsedDefaultChar
4 l8 d* r# Q& DPoints to a flag that indicates whether a default character was used. The flag is set to TRUE if one or more wide characters in the source string cannot be represented in the specified code page. Otherwise, the flag is set to FALSE. This parameter may be NULL. The function is faster when both lpDefaultChar and lpUsedDefaultChar are NULL. 5 y% `2 D# E* a3 z G0 B+ U& a9 L3 Y
) }' |! c( g T) M0 y+ L2 h4 \! A$ \# z) ~+ f# j/ m, k8 i
; u$ P' A& w) T+ dReturn Values! H0 v1 `: c9 \. P6 O+ f0 N- P
& }8 Z2 r/ q- s- R+ rIf the function succeeds, and cchMultiByte is nonzero, the return value is the number of bytes written to the buffer pointed to by lpMultiByteStr. 5 Y* ?6 K) y* Y7 N
If the function succeeds, and cchMultiByte is zero, the return value is the required size, in bytes, for a buffer that can receive the translated string. ' L/ s9 R+ ? O' C. ]
If the function fails, the return value is zero. To get extended error information, call GetLastError. GetLastError may return one of the following error codes:' m2 P9 n; i+ h7 Q& F
" W9 c9 H* p" Q7 j# lERROR_INSUFFICIENT_BUFFER
4 X& i8 q3 b- q& T( sERROR_INVALID_FLAGS1 [0 [9 i: ?( H$ V0 `& U* `) k% k
ERROR_INVALID_PARAMETER |