有一个窗体放三个控件,TEXT3,COMBO2,COMBO3
另一个窗体有两个空间,COMBUTTON2,PICTURE1,DATA2绑定一个表---字体设置
有一个标准模块font.bas代码如下:
font.bas中
Option ExplicitPublic Const LF_FACESIZE = 32
Public Const DEFAULT_CHARSET = 1
Type LOGFONT
        lfHeight As Long
        lfWidth As Long
        lfEscapement As Long
        lfOrientation As Long
        lfWeight As Long
        lfItalic As Byte
        lfUnderline As Byte
        lfStrikeOut As Byte
        lfCharSet As Byte
        lfOutPrecision As Byte
        lfClipPrecision As Byte
        lfQuality As Byte
        lfPitchAndFamily As Byte
        lfFaceName(0 To LF_FACESIZE - 1) As Byte
End Type
Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long
Declare Sub RtlMoveMemory Lib "KERNEL32" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)
////窗体模块中'读出打印字体信息,有一个表存储我的字体设置信息
'大体如下
  ID   字体大小     字体类型    是否为黑体  是否为斜体
   0     12           宋体        是            是
   1      ..          ..
   2     ...            ...
Private Sub ReadFontCon(PrintText As String, I As Long)
  '以下代码引子王国荣VB6.0API
    Dim font As LOGFONT
    Dim IFontName As String
    Dim IFontHeight As Integer
    Dim IFontWidth As Integer
    Dim IIFontWeight As Byte
    Dim IIFontItalic As Byte
    Dim hOldFont As Long, hFont As Long
    Dim SQL As String
     
     SQL = "SELECT * FROM 字体设置 WHERE ID=" & I
    Data2.RecordSource = SQL
    Data2.Refresh
     
 
    IFontName = Data2.Recordset.Fields(1)
    IFontHeight = Data2.Recordset.Fields(2)
    IFontWidth = Data2.Recordset.Fields(3)
    IIFontWeight = Data2.Recordset.Fields(4)
    IIFontItalic = Data2.Recordset.Fields(5)
    
    
    RtlMoveMemory font.lfFaceName(0), _
                   ByVal CStr(IFontName), _
                   LenB(StrConv(IFontName, vbFromUnicode)) + 1
                   
    font.lfHeight = (Val(IFontHeight) * -20) / Screen.TwipsPerPixelY
    font.lfWidth = (Val(IFontWidth) * -20) / Screen.TwipsPerPixelY
    font.lfWeight = IIf(IIFontWeight, 700, 400)
    font.lfItalic = IIFontItalic
    font.lfCharSet = DEFAULT_CHARSET
     
    hFont = CreateFontIndirect(font)
    hOldFont = SelectObject(Picture1.hDC, hFont)   '我想打印出来,
'将PICTURE1换成PRINTER,结果却不行.
     
   
   Picture1.Print PrintText
          
    SelectObject Picture1.hDC, hOldFont
    DeleteObject hFont
    
    
End SubPrivate Sub Command2_Click()
 
 Call ReadFontCon(Form1.Combo2.Text, 0)
 Call ReadFontCon(Form1.Combo3.Text, 1)
Call ReadFontCon(Form1.Text3.Text, 2)
 
End Sub
/////////
程序执行后在PICTURE1中按照我设置的字体显示了出来,我想打印出来,将PICTURE1换成 PRINTER,结果却是打印出同一类型的字体,没有按照表中设置的字体打印.WHY