This prints the text directly on a dialog using a large font size. Is there a more minimal way to create the large font? The MakeFont function is bigger than almost the rest of the code!
Code:
'Compilable Example: #Include "win32api.inc" Global hDlg, hFont As Dword, Letter$ Function PBMain() As Long Dialog New Pixels, 0, "Font",,,200,200, %WS_OverlappedWindow To hDlg Letter$ = "Z" Dialog Show Modal hDlg Call DlgProc End Function CallBack Function DlgProc() As Long Local ps As PaintStruct Select Case Cb.Msg Case %WM_InitDialog hFont = MakeFont("Arial",144,"B") Case %WM_Paint BeginPaint hDlg, ps hFont = SelectObject(ps.hDC, hFont) SetBkMode ps.hDC, %Transparent TextOut ps.hDC, 35,0, ByVal StrPtr(Letter$), Len(Letter$) EndPaint hDlg, ps Case %WM_ContextMenu : Dialog End hDlg End Select End Function Function MakeFont(ByVal fName As String, ByVal ptSize As Long, _ Opt ByVal attr As String) As Dword '-------------------------------------------------------------------- ' Create a desired font and return its handle. ' attr = "biu" for bold, italic, and underlined (any order) '-------------------------------------------------------------------- Local hDC As Dword, CharSet As Long, CyPixels As Long Local Bold, italic, uLine As Long If Len(attr) Then If InStr(LCase$(attr), "b") Then Bold = %FW_BOLD If InStr(LCase$(attr), "i") Then italic = 1 If InStr(LCase$(attr), "u") Then uLine = 1 End If hDC = GetDC(%HWND_Desktop) CyPixels = GetDeviceCaps(hDC, %LOGPIXELSY) ReleaseDC %HWND_Desktop, hDC PtSize = 0 - (ptSize * CyPixels) \ 72 Function = CreateFont(ptSize, 0, 0, 0, Bold, italic, uLine, _ %FALSE, CharSet, %OUT_TT_PRECIS, _ %CLIP_DEFAULT_PRECIS, %DEFAULT_QUALITY, _ %FF_DONTCARE , ByCopy fName) End Function
Comment