Lm th? no ? tnh ton n v? c b?n h?p tho?i v?i cc h? th?ng d?a Font

D?ch tiu ? D?ch tiu ?
ID c?a bi: 125681
Bung t?t c? | Thu g?n t?t c?

TM T?T

Bi vi?t ny ch?ng t? lm th? no ? tnh ton n v? c b?n h?p tho?i cho cc h?p tho?i b?ng cch s? d?ng m?t phng ch? khc v?i Font h? th?ng trong Windows 95. B?n c th? s? d?ng tnh ton ny ? xy d?ng m?u h?p tho?i trong b? nh? ho?c tnh ton Kch th?c h?p tho?i.

THNG TIN THM

M?i m?u h?p tho?i ch?a cc php o ch? ra v? tr, Chi?u r?ng v chi?u cao c?a h?p tho?i v ki?m sot n ch?a. y o ?c l thi?t b? ?c l?p, do , m?t ?ng d?ng c th? s? d?ng m?t ?a n m?u ? t?o ra cng m?t h?p tho?i cho t?t c? cc lo?i thi?t b? hi?n th?. i?u ny ?m b?o r?ng m?t h?p tho?i s? c cng m?t t? l? v xu?t hi?n trn mn h?nh t?t c? m?c d ? phn gi?i khc nhau v t? l? kha c?nh gi?a mn h?nh.

Hn n?a, cc o ?c h?p tho?i ?c cho theo n v? c b?n h?p tho?i. M?t trong nh?ng n v? c s? ngang l tng ng v?i m?t ph?n t chi?u r?ng nhn v?t trung cho font h? th?ng. M?t trong nh?ng n v? d?c c s? l tng ng v?i m?t th? tm c?a cc trung b?nh chi?u cao nhn v?t cho font h? th?ng. M?t ?ng d?ng c th? truy xu?t s? i?m ?nh trn m?t n v? c s? cho vi?c hi?n th? hi?n t?i b?ng cch s? d?ng cc Ch?c nng GetDialogBaseUnits. T? th?p th? t? c?a gi tr? tr? l?i, t? ch?c nng GetDialogBaseUnits, ch?a cc n v? c s? ngang v cc cao-tr?t t? t? c?a gi tr? tr? l?i, t? ch?c nng GetDialogBaseUnits, ch?a cc n v? c s? d?c.

S? d?ng thng tin ny, b?n c th? tnh ton cc h?p tho?i n v? c s? cho m?t h?p tho?i h?p b?ng cch s? d?ng phng ch? khc v?i font h? th?ng:
horz pixels == 2 * horz dialog units * (average char width  of dialog font
                        / average char width of system font)
vert pixels == 2 * vert dialog units * (average char height of dialog font
                        / average char height of system font)
				
Nh font ch? c?a m?t thay ?i h?p tho?i, kch th?c th?c t? v v? tr c?a m?t ki?m sot c?ng thay ?i.

M?t trong nh?ng n v? c b?n h?p tho?i l tng ng v?i s? i?m ?nh trn m?i h?p tho?i h?p n v? nh sau:
1 horz dialog base unit == (2 * average char width  dialog font / 
                                average char width  system font) pixels
1 vert dialog base unit == (2 * average char height dialog font / 
                                average char height system font) pixels
				
Nhn v?t trung b?nh chi?u r?ng v chi?u cao c?a m?t phng ch? c th? ?c tnh nh sau:
hFontOld = SelectObject(hdc,hFont);
GetTextMetrics(hdc,&tm);
GetTextExtentPoint32(hdc,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrst"
            "uvwxyz",52,&size);
avgWidth = (size.cx/26+1)/2;
avgHeight = (WORD)tm.tmHeight;
				
L?nh v?c tmAveCharWidth c?u trc TEXTMETRIC ch? x?p x? cc th?c t? trung r?ng (th?ng n mang l?i cho ? r?ng c?a cc ch? ci "x") v do , s? th?t trung r?ng ph?i ?c tnh ton ? ph h?p v?i gi tr? ?c s? d?ng b?i h? th?ng.

B?n c th? s? d?ng ch?c nng MapDialogRect ? chuy?n ?i n v? h?p tho?i vo pixel, nhng khng c ch?c nng m s? chuy?n ?i pixel vo h?p tho?i n v?. B?n c th? s? d?ng cng th?c hi?n th? ? y ? th?c hi?n chuy?n ?i ny.

THAM KH?O

? bi?t thm chi ti?t v? ch? ? ny, xin vui l?ng xem bi vi?t sau trong c s? ki?n th?c Microsoft:
145994 Lm th? no ? tnh ton n v? h?p tho?i khi khng s? d?ng Font h? th?ng

Thu?c tnh

ID c?a bi: 125681 - L?n xem xt sau cng: 17 Thang Tam 2011 - Xem xt l?i: 2.0
T? kha:
kbdlg kbhowto kbmt KB125681 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:125681

Cung cp Phan hi

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com