Product : Engine, Version : 5.0.1.1036, ArticleID : 41023919

HowTo : Pick window to print using my own customized printer setup window

Article41023919
TypeHowTo
ProductEngine
Version5.0.1.1036
Date Added4/8/2005
Submitted byIndira Restrepo
Keywords

Subject

Pick window to print using my own customized printer setup window

Summary

Pick window to print using my own customized printer setup window

Solution

Let's assume that you have a form1 that contains VectorDraw component and you have a button that when you click on it, it displays a new form called frmpreview.

Here is the code you have to add in the frmpreview (also add a button called "PickWindow" and a picturebox called "PictureBox1") in order to achieve this goal.


Private Sub Form_Load()
    With Form1.vdraw.ActiveDocument.Printer
        .PrintExtends
        .PrintScaleToFit
        .AttachPreview (PictureBox1.hWnd)
    End With
End Sub

Private Sub PickWindow_Click()
Dim pt1 As Variant
Dim pt2 As Variant

    frmPreview.Hide
    pt1 = Form1.vdraw.Utility.GetPoint
    pt2 = Form1.vdraw.Utility.GetCorner(pt1)
    Form1.vdraw.ActiveDocument.ActiveLayOut.TransPoint pt1, 1, 2 'translate points from CCS to DCS
    Form1.vdraw.ActiveDocument.ActiveLayOut.TransPoint pt2, 1, 2 'translate points from CCS to DCS
    SelectWindow pt1, pt2
    frmPreview.Show
End Sub

Private Sub SelectWindow(LowerLeftPt As Variant, UpperRightPt As Variant)
Dim lox, loy, upx, upy

    lox = LowerLeftPt(0)
    If LowerLeftPt(0) > UpperRightPt(0) Then
        lox = UpperRightPt(0)
    End If
    loy = LowerLeftPt(1)
    If LowerLeftPt(1) > UpperRightPt(1) Then
        loy = UpperRightPt(1)
    End If
    upx = UpperRightPt(0)
    If UpperRightPt(0) < LowerLeftPt(0) Then
        upx = LowerLeftPt(0)
    End If
    upy = UpperRightPt(1)
    If UpperRightPt(1) < LowerLeftPt(1) Then
        upy = LowerLeftPt(1)
    End If
   
    With Form1.vdraw.ActiveDocument.Printer
        .PrintWindow = Array(lox, loy, upx, upy)
        .PrintScaleToFit
        .AttachPreview (PictureBox1.hWnd)
    End With
End Sub