•
•
応用場合
プログラムで漢字がある文字列を切れる。
例えば、文字列改行/最後...にする
•
UnicodePageに日本語漢字の範囲で判断
BOOL ChkKanji(unsigned char c1,unsigned char c2) {
BOOL isknj1 = false;BOOL isknj2 = false;
//第1バイトチェック
if(((c1 >= 0x81) && (c1 <= 0x9F)) || ((c1 >= 0xED) && (c1 <= 0xFC))){
isknj1 = true;}
if(((c2 >= 0x40) && (c2 <= 0xFC) && (c2 != 0x7F))){isknj2 = true;}
if(isknj1 && isknj2)return TRUE;
return FALSE;
}
•
MS社のAPI IsDBCSLeadByte
Returns a nonzero value if the test character is potentially a lead
byte.
The function returns 0 if the test character is not a lead byte or if it
is a single-byte character.
•
応用場合
GDI
で文字列を表示するCustomizeComponentを作成する
•
Csize CDC::GetTextExtent
Call this member function to compute the width and height of a line of text using the current font to determine the dimensions.
•
Etc1
CSize cs = dc->GetTextExtent(lpStr, (int)_tcslen(lpStr));
if (cs.cx > 220){
dc->DrawText(lpStr, CRect(x, y, x+width, y+height), DT_LEFT |
DT_NOPREFIX);
}else{
dc->DrawText(lpStr, CRect(x, y, x+width, y+height),
DT_WORDBREAK| DT_CENTER | DT_NOPREFIX);
}
DT_END_ELLIPSIS / DT_PATH_ELLIPSIS /DT_NOPREFIX