Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub CalcTextSize(szCaption as wstring, szFntName as zString, fntSz as integer, _
- fStyle as integer, byref x as integer, byref y as integer)
- dim as integer fw, fi
- if (fstyle and FS_BOLD) then fw = FW_BOLD else fw = FW_NORMAL
- if (fstyle and FS_ITALIC) then fi = True else fi = False
- var hDC = GetDC(0)
- dim as integer fontPt = -MulDiv(fntSz, GetDeviceCaps(hDC, LOGPIXELSY), 72)
- var hFont = CreateFont(fontPt,0,0,0,fw,fi,0,0,DEFAULT_CHARSET,0,0,_
- NONANTIALIASED_QUALITY,0,szFntName)
- SelectObject(hDC, hFont)
- static as TEXTMETRIC textMetrics
- static as SIZE txtSize
- GetTextMetrics(hDC, @textMetrics)
- GetTextExtentPoint32W(hDC, szCaption, len(szCaption),@txtSize)
- dim as integer TXTSZ = txtSize.cx
- dim as integer TXYY = txtSize.cy
- if (fstyle and FS_ITALIC) then
- if textMetrics.tmOverhang then
- TXTSZ += textMetrics.tmOverhang
- else
- TXTSZ += 1+(fntSz/2)
- end if
- TXYY += 1+(fntSz/8)
- end if
- if (fstyle and FS_ANTIALIAS) then
- #if GAMMA>1 and GAMMA <= 2
- TXTSZ += GAMMA*2
- #endif
- end if
- TXTSZ -= 1
- TXYY -= 1
- DeleteObject(hFont)
- x = TXTSZ: y = TXYY
- end sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement