察看Platform SDK: International Features中的 GetUserDefaultLangID GetUserDefaultUILanguage 之类的函数看看
如何获得系统字体的大小 呵呵 补充一下了Option Explicit Private Declare Function GetDeviceCaps Lib "gdi32 " (ByVal hdc As Long, ByVal nIndex As Long) As Long Private Declare Function GetDC Lib "user32 " (ByVal hwnd As Long) As Long Private Const LOGPIXELSX = 88 ' Logical pixels/inch in X Private Sub Command1_Click() Debug.Print GetDeviceCaps(GetDC(0), LOGPIXELSX) End Sub
Function FontCheck(Idx) As Boolean '這個Function用來檢查字型載入是否發生錯誤 On Error GoTo DowithErrorPicture1.FontName = Screen.Fonts(Idx) FontCheck = True Exit Function DowithError: FontCheck = False End Function Private Sub Form_Load() 'Picture1.AutoRedraw要設為 True 喔!! Dim NullPic As New StdPicture '要用來清除Picture1的圖片內容用 Idx = 0 Cdx = 0 Do Until Idx = Screen.FontCount If FontCheck(Idx) = True Then Picture1.Picture = NullPic Picture1.Picture = Picture1.Image '上面兩段是要把Picture1清空 Picture1.CurrentY = 0 Picture1.FontSize = 18 Picture1.FontName = Screen.Fonts(Idx) '把Picture1的字型設定成螢幕字型裡的第 Idx 個 Picture1.Print Screen.Fonts(Idx) Picture1.Picture = Picture1.Image ImageList1.ListImages.Add Cdx + 1, "P" & CStr(Cdx + 1), Picture1.Picture '把圖片與字型名稱加到ImageList裡 Cdx = Cdx + 1 End If Idx = Idx + 1 Loop Set ImageCombo1.ImageList = ImageList1 '設定ImageCombo1使用ImageList裡的圖片 For Idx = 1 To ImageList1.ListImages.Count ImageCombo1.ComboItems.Add , , Screen.Fonts(Idx - 1), "P" & CStr(Idx) If ImageCombo1.ComboItems(Idx).Text = Me.FontName Then RecIdx = Idx '檢查目前的字型是否為表單字型,若是,則記下索引位置 Next ImageCombo1.ComboItems(RecIdx).Selected = True '再把預設值設成表單字型 End Sub
GetUserDefaultLangID
GetUserDefaultUILanguage
之类的函数看看
Private Declare Function GetDeviceCaps Lib "gdi32 " (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Declare Function GetDC Lib "user32 " (ByVal hwnd As Long) As Long
Private Const LOGPIXELSX = 88 ' Logical pixels/inch in X Private Sub Command1_Click()
Debug.Print GetDeviceCaps(GetDC(0), LOGPIXELSX)
End Sub
'這個Function用來檢查字型載入是否發生錯誤
On Error GoTo DowithErrorPicture1.FontName = Screen.Fonts(Idx)
FontCheck = True
Exit Function
DowithError:
FontCheck = False
End Function
Private Sub Form_Load()
'Picture1.AutoRedraw要設為 True 喔!!
Dim NullPic As New StdPicture
'要用來清除Picture1的圖片內容用
Idx = 0
Cdx = 0
Do Until Idx = Screen.FontCount
If FontCheck(Idx) = True Then
Picture1.Picture = NullPic
Picture1.Picture = Picture1.Image
'上面兩段是要把Picture1清空
Picture1.CurrentY = 0
Picture1.FontSize = 18
Picture1.FontName = Screen.Fonts(Idx)
'把Picture1的字型設定成螢幕字型裡的第 Idx 個
Picture1.Print Screen.Fonts(Idx)
Picture1.Picture = Picture1.Image
ImageList1.ListImages.Add Cdx + 1, "P" & CStr(Cdx + 1), Picture1.Picture
'把圖片與字型名稱加到ImageList裡
Cdx = Cdx + 1
End If
Idx = Idx + 1
Loop
Set ImageCombo1.ImageList = ImageList1
'設定ImageCombo1使用ImageList裡的圖片
For Idx = 1 To ImageList1.ListImages.Count
ImageCombo1.ComboItems.Add , , Screen.Fonts(Idx - 1), "P" & CStr(Idx)
If ImageCombo1.ComboItems(Idx).Text = Me.FontName Then RecIdx = Idx
'檢查目前的字型是否為表單字型,若是,則記下索引位置
Next
ImageCombo1.ComboItems(RecIdx).Selected = True
'再把預設值設成表單字型
End Sub