Probably, this code explain you something.
Code:
#Compile Exe #Register None #Dim All #Include "Win32Api.Inc" %ID_Label = 101 %ID_TextBox = 101 %ID_Button = 301 CallBack Function DlgProc Static hWndT As Long, hFontT As Long Select Case CbMsg Case %WM_INITDIALOG hWndT = GetDlgItem(CbHndl, %ID_LABEL) hFontT = CreateFont(-14, 0, 0, 0, %FW_BOLD, %True, 0, 0, _ %RUSSIAN_CHARSET, 0, 0, 0, 0, "Times New Roman") SendMessage hWndT, %WM_SETFONT, hFontT, 0 Case %WM_DESTROY DeleteObject hFontT Case %WM_COMMAND If CbCtl = %ID_BUTTON Then Local hDC As Long, tm As TextMetric, lf As LOGFONT, hFont As Long, hFontOld As Long hFont = SendMessage(hWndT, %WM_GETFONT, 0, 0) hDC = GetDC(hWndT) hFontOld = SelectObject(hDC, hFont) GetTextMetrics hdc, tm SelectObject hdc, hFontOld ReleaseDC hWndT, hDC GetObject hFont, SizeOf(lf), ByVal VarPtr(lf) MsgBox lf.lfFaceName + _ " lf.lfHeight = " + Format$(lf.lfHeight) + _ " lf.lfWidth = " + Format$(lf.lfWidth) + _ " tm.tmHeight = " + Format$(tm.tmHeight) + _ " tm.tmAveCharWidth = " + Format$(tm.tmAveCharWidth) End If End Select End Function Function PbMain Local hDlg As Long Dialog New 0, "",,, 300, 150, %WS_SYSMENU Or %WS_CAPTION To hDlg Control Add Label, hDlg, %ID_Label, "Label", 10, 5, 280, 10, %SS_RIGHT Control Add TextBox, hDlg, %ID_TextBox, "", 10, 20, 280, 90, _ %ES_WANTRETURN Or %ES_MULTILINE, %WS_EX_CLIENTEDGE Control Add Button, hDlg, %ID_Button, "Show", 10, 120, 280, 15 Dialog Show Modal hDlg Call DlgProc End Function
Leave a comment: