今天要求做一个打印,需要用到vsprinter控件,可是网上没有一点可以使用的信息,
希望朋友帮我找个初级使用帮助或者怎么样的例子让我有个认识,现在一点头绪都没有,
谢谢

解决方案 »

  1.   

    Option ExplicitDim g_Sizing%
    Const TOL = 100Private Sub Form_Load()
        vp.ShowGuides = gdShow
        CreateDoc
    End SubPrivate Sub vp_BeforeUserScroll(Cancel As Boolean)    ' prevent scrolling while dragging margins
        If g_Sizing Then Cancel = True
        
    End SubPrivate Sub VP_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        With vp
        
            ' already resizing? show resizing line using client coordinates
            If Button = 1 Then
                Select Case g_Sizing
                    Case 1, 2
                        ctlLine.X1 = X
                        ctlLine.X2 = X
                        ctlLine.Y1 = 0
                        ctlLine.Y2 = 32000
                        ctlLine.Visible = True
                    Case 3, 4
                        ctlLine.X1 = 0
                        ctlLine.X2 = 32000
                        ctlLine.Y1 = Y
                        ctlLine.Y2 = Y
                        ctlLine.Visible = True
                    Case Else
                        ctlLine.Visible = False
                End Select
                Exit Sub
            End If
            
            ' convert client to page coordinates
            .ClientToPage X, Y
            
            ' offer resizing
            If Abs(X - .MarginLeft) < TOL Then
                g_Sizing = 1
                .MousePointer = mpSizeEW
            ElseIf Abs(X - (.PageWidth - .MarginRight)) < TOL Then
                g_Sizing = 2
                .MousePointer = mpSizeEW
            ElseIf Abs(Y - .MarginTop) < TOL Then
                g_Sizing = 3
                .MousePointer = mpSizeNS
            ElseIf Abs(Y - (.PageHeight - .MarginBottom)) < TOL Then
                g_Sizing = 4
                .MousePointer = mpSizeNS
            Else
                g_Sizing = 0
                .MousePointer = mpDefault
            End If
        End With
    End SubPrivate Sub vp_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        
        ' left button only
        If Button <> 1 Then Exit Sub
        
        ' adjust margins
        With vp
        
            .ClientToPage X, Y
            Select Case g_Sizing
                Case 1
                    If X > 0 And X < .PageWidth - .MarginRight - 300 Then
                        .MarginLeft = X
                        CreateDoc
                    End If
                Case 2
                    If X < .PageWidth And X > .MarginLeft + 300 Then
                        .MarginRight = .PageWidth - X
                        CreateDoc
                    End If
                Case 3
                    If Y > 0 And Y < .PageHeight - .MarginBottom - 300 Then
                        .MarginTop = Y
                        CreateDoc
                    End If
                Case 4
                    If Y < .PageHeight And Y > .MarginTop + 300 Then
                        .MarginBottom = .PageHeight - Y
                        CreateDoc
                    End If
            End Select
        
            ' reset all
            ctlLine.Visible = False
            g_Sizing = 0
            .MousePointer = mpDefault
        End With
    End SubSub CreateDoc()
        With vp
            .StartDoc
                .SpaceAfter = 200
                .TextAlign = taJustTop
                .FontSize = 18
                .Paragraph = "Hello, World."
                .FontSize = 12
                .Paragraph = "This is a VSPrinter document. You can set " & _
                             "the margins by dragging them with the mouse."
                .Paragraph = "Right now the margins are set as follows:"
                
                .SpaceAfter = 0
                .AddTable "3000|1000", "Property|Value", _
                    "MarginLeft|" & Int(.MarginLeft) & ";" & _
                    "MarginTop|" & Int(.MarginTop) & ";" & _
                    "MarginRight|" & Int(.MarginRight) & ";" & _
                    "MarginBottom|" & Int(.MarginBottom) & ";", RGB(200, 200, 200)
                .Paragraph = ""            .SpaceAfter = 200
                Dim i%, s$
                s = "Some extra content just to fill up a couple of pages. "
                For i = 1 To 20
                    .Paragraph = s & s & s & s & " (" & i & ")."
                Next
                
            .EndDoc
        End With
    End SubPrivate Sub Command1_Click()
        Dim s$
        On Error Resume Next
        Open App.Path & "\readme.txt" For Binary As #1
        s = Input(LOF(1), 1)
        Close #1
        If Err > 0 Or Len(s) = 0 Then s = "Sorry, can't find Readme.txt."
        MsgBox s, vbInformation, "Readme.txt"
        On Error GoTo 0
    End SubPrivate Sub Form_Resize()
        On Error Resume Next
        vp.Move vp.Left, vp.Top, ScaleWidth - vp.Left * 2, ScaleHeight - vp.Left - vp.Top
    End Sub
      

  2.   

    readme.txt
    MARGINS
    ------------------------------------------------------------
    Allow users to adjust margins using the mouse.The sample handles the MouseMove and MouseUp events, converting
    mouse coordinates into page coordinates. If the user moves the mouse
    close to the guides, the mouse pointer changes to show that he can
    start dragging the margin.When the user releases the mouse button, the margin is adjusted and 
    the document is regenerated to show the changes.The BeforeUserScroll event is used to prevent scrolling the document
    with the mouse while the margins are being dragged.The main methods, events, and properties used in this sample are:
    ClientToPage, BeforeUserScroll, MousePointer, 
    MarginLeft, MarginTop, MarginRight, MarginBottom.
      

  3.   

    I have more samples about vsprinter...
      

  4.   

    网上没有解释它属性的信息,看起来真费尽啊:(,我现在是要从vsflexgird中取得数据来进行打印,
    我就不明白怎么输入到vsprinter里面去,让它们显示出来