⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmsetpaper.frm

📁 金算盘软件代码
💻 FRM
📖 第 1 页 / 共 2 页
字号:
'                              私有过程
'
Private Sub PaperSize(intIndex As Integer)
Dim lngTemp As Long
    OptPortrait.Value = mclsFset.GIsPortrait
    OptLandscape.Value = Not OptPortrait.Value
    If intIndex = 55 Then  '如果是默认纸张
        SpiWidth.Text = CLng(Printer.width / 56.7 * 10)       '把Twips转换为0.1毫米
        SpiHeight.Text = CLng(Printer.Height / 56.7 * 10)
    ElseIf intIndex = 256 Then '自定义纸张
        SpiWidth.Text = mclsFset.GPaperWidth
        SpiHeight.Text = mclsFset.GPaperHeight
    Else
        SpiWidth.Text = CLng(strX(intIndex) / 56.7 * 10)
        SpiHeight.Text = CLng(strY(intIndex) / 56.7 * 10)
        If OptLandscape.Value Then      '横向
            lngTemp = Val(SpiWidth.Text)
            SpiWidth.Text = SpiHeight.Text
            SpiHeight.Text = lngTemp
        End If
    End If
    
    If intIndex = 256 Then '自定义纸
        SpiWidth.Enable = True
        SpiHeight.Enable = True
    Else
        SpiWidth.Enable = False
        SpiHeight.Enable = False
    End If
End Sub
Private Sub LoadResMap()
    Me.HelpContextID = 10006
    Me.Icon = Utility.GetFormResPicture(139, vbResIcon)
    CmdOK.Picture = GetFormResPicture(1001, vbResBitmap)
    CmdCancel.Picture = GetFormResPicture(1002, vbResBitmap)
End Sub


Private Sub AddItemPaper()
Dim intIndex As Integer, intTempSize As Integer
Dim intPrintSize As Integer
Dim intSuccess As Integer
Dim strIndex As String
    
    strIndex = "55,8,9,12,13,39,45"
    If Printer.PaperSize <> 0 Then
        Do While strIndex <> ""
            intIndex = Val(StringOut(strIndex, ","))
            If intIndex > 0 Then
                intTempSize = GetPaperSizeByName(mArrayPapersize(intIndex))
                intSuccess = CheckPaperSize(Printer.DeviceName, Printer.Port, intTempSize)
                If intSuccess = 1 And mArrayPapersize(intIndex) <> "" Then
                    CboSize.AddItem mArrayPapersize(intIndex)
                    CboSize.ItemData(CboSize.NewIndex) = intIndex
                End If
            End If
        Loop
        
        '''''''特别处理
        intTempSize = GetPaperSizeByName(mArrayPapersize(56))
        intSuccess = CheckPaperSize(Printer.DeviceName, Printer.Port, intTempSize)
        If intSuccess = 1 And mArrayPapersize(56) <> "" Then
            CboSize.AddItem mArrayPapersize(56)
            CboSize.ItemData(CboSize.NewIndex) = 256
        End If
    End If
End Sub
Private Sub ResetPaper()
Dim lngWidth As Long, lngHeight As Long

    If OptMM.Value = True Then
        lngWidth = Val(mclsFset.GPaperHeight)
        lngHeight = Val(SpiHeight.Text)
    Else
        lngWidth = InchToMM(Val(SpiWidth.Text))
        lngHeight = InchToMM(Val(SpiHeight.Text))
    End If
    mclsFset.GPaperHeight = lngHeight
    mclsFset.GPaperWidth = lngWidth
    mclsFset.GIsPortrait = OptPortrait.Value
    If CboSize.ListIndex = 0 Then   '如果为系统默认时,直接改变其打印对象的纵横属性
        Printer.Orientation = IIf(OptPortrait.Value, 1, 2)
    End If
    mclsFset.GPaperIndex = CboSize.ItemData(CboSize.ListIndex)
    mclsFset.GPaperTypeIndex = GetPaperSizeByName(CboSize.Text, False)
    mclsFset.GPaperTypeIndex1 = GetPaperSizeByName(CboSize.Text, True)
    mclsFset.IsSaveToDB = mblnChange
End Sub

Private Sub InitForm()
Dim lngMinHeight As Long
Dim intRows As Integer
    
    OptMM.Value = True
    OptLandscape.Value = Not OptPortrait.Value
    PicLandscape.Visible = OptLandscape.Value
    PicPortrait.Visible = OptPortrait.Value
    CboSize.Text = CboSize.list(GetListIndex(mclsFset.GPaperIndex))
    PaperSize CboSize.ItemData(CboSize.ListIndex)
    If OptLandscape.Value And CboSize.ItemData(CboSize.ListIndex) <> 55 And CboSize.ItemData(CboSize.ListIndex) > 256 Then '为横向,且纸张不为自定义
        Exchange
    End If
    
    intRows = IIf(mclsFset.IsReport, 3, 8)
    lngMinHeight = intRows * mclsFset.GHeightPerRow + mclsFset.GPaperBorder(0) + mclsFset.GPaperBorder(1) + mlngHeaderHeight + 4
    lngMinHeight = lngMinHeight * Screen.TwipsPerPixelY / 5.67         '把像素转换为0.1毫米
    SpiWidth.Min = 300                 '宽度最小值 30毫米
    SpiWidth.Max = 5000                '宽度最大值420毫米
    SpiHeight.Min = lngMinHeight       '高度最小值 lngMinHeight
    SpiHeight.Max = 5000               '高度最大值297 毫米
End Sub




Private Sub CheckEmpty(XSpiText As SpinEdit)
    If XSpiText.Text = "" Then
        XSpiText.Text = mstrOld
    End If
End Sub


Private Sub Exchange()
Dim strTemp As String
    mblnSize = False
    strTemp = SpiWidth.Text
    SpiWidth.Text = SpiHeight.Text
    SpiHeight.Text = strTemp
    mblnSize = True
End Sub
Private Sub InitArray()
     
'    mArrayPapersize(2) = "+A611 小型信笺, 8 1/2 x 11 英寸"
 '   mArrayPapersize(3) = "小型报, 11 x 17 英寸"
'    mArrayPapersize(4) = "宽行打印纸, 17 x 11 英寸"
'    mArrayPapersize(5) = "法律文件, 8 1/2 x 14 英寸"
'    mArrayPapersize(6) = "声明书,5 1/2 x 8 1/2 英寸"
'    mArrayPapersize(7) = "行政文件,7 1/2 x 10 1/2 英寸"
    mArrayPapersize(8) = "A3 297 x 420 毫米"
    mArrayPapersize(9) = "A4 210 x 297 毫米"
'    mArrayPapersize(10) = "A4小号, 210 x 297 毫米"
    mArrayPapersize(11) = "A5 148 x 210 毫米"
    mArrayPapersize(12) = "B4 250 x 354 毫米"
    mArrayPapersize(13) = "B5 182 x 257 毫米"
'    mArrayPapersize(14) = "对开本, 8 1/2 x 13 英寸"
'    mArrayPapersize(15) = "四开本, 215 x 275 毫米"
'    mArrayPapersize(16) = "10x14 英寸"
'    mArrayPapersize(17) = "11x17 英寸"
'    mArrayPapersize(18) = "便条,8 1/2 x 11 英寸"
'    mArrayPapersize(19) = "#9 信封, 3 7/8 x 8 7/8 英寸"
'    mArrayPapersize(20) = "#10 信封, 4 1/8 x 9 1/2 英寸"
'    mArrayPapersize(21) = "#11 信封, 4 1/2 x 10 3/8 英寸"
'    mArrayPapersize(22) = "#12 信封, 4 1/2 x 11 英寸"
'    mArrayPapersize(23) = "#14 信封, 5 x 11 1/2 英寸"
'    mArrayPapersize(24) = "C 尺寸工作单"
'    mArrayPapersize(25) = "D 尺寸工作单"
'    mArrayPapersize(26) = "E 尺寸工作单"
'    mArrayPapersize(27) = "DL 型信封, 110 x 220 毫米"
'    mArrayPapersize(29) = "C3 型信封, 324 x 458 毫米"
'    mArrayPapersize(30) = "C4 型信封, 229 x 324 毫米"
'    mArrayPapersize(28) = "C5 型信封, 162 x 229 毫米"
'    mArrayPapersize(31) = "C6 型信封, 114 x 162 毫米"
'    mArrayPapersize(32) = "C65 型信封,114 x 229 毫米"
'    mArrayPapersize(33) = "B4 型信封, 250 x 353 毫米"
'    mArrayPapersize(34) = "B5 型信封,176 x 250 毫米"
'    mArrayPapersize(35) = "B6 型信封, 176 x 125 毫米"
'    mArrayPapersize(36) = "信封, 110 x 230 毫米"
'    mArrayPapersize(37) = "信封大王, 3 7/8 x 7 1/2 英寸"
'    mArrayPapersize(38) = "信封, 3 5/8 x 6 1/2 英寸"
    mArrayPapersize(39) = "宽行打印纸, 14 7/8 x 11 英寸"
'    mArrayPapersize(40) = "德国标准复写簿, 8 1/2 x 12 英寸"
'    mArrayPapersize(41) = "德国法律复写簿, 8 1/2 x 13 英寸"
    mArrayPapersize(45) = "窄行打印纸, 10 x 11  英寸"
    mArrayPapersize(55) = "默认纸张"
    mArrayPapersize(56) = "自定义纸张"
    

    ''相应纸的高度和宽度
    '单位为mm
    strX(0) = ""
    strY(0) = ""
    
    strX(2) = "2080"                         '"8.5 in"
    strY(2) = "2700"                         '"11 in"
    strX(3) = "2700"                         '"11 in"
    strY(3) = "4170"                         '"17 in"
    strX(5) = "2080"                         '"8.5 in"
    strY(5) = "3430"                         '"14 in"
    strX(6) = "1350"                         '"5.5 in"
    strY(6) = "2080"                         '"8.5 in"
    strX(7) = "1780"                         '"7.25 in"
    strY(7) = "2570"                         '"10.5 in"
    strX(8) = "16840 "
    strY(8) = "23814 "
    strX(9) = "11907 "
    strY(9) = "16840 "
    strX(10) = "2100 "
    strY(10) = "2970 "
    strX(11) = "8392 "
    strY(11) = "11907 "
    strX(12) = "14175 "
    strY(12) = "20072 "
    strX(13) = "10319 "
    strY(13) = "14572 "
    strX(14) = "2080"                        '"8.5 in"
    strY(14) = "3190"                        '"13 in"
    strX(15) = "2150"
    strY(15) = "2750"
    strX(16) = "2450"                        '"10 in"
    strY(16) = "3430"                        '"14 in"
    strX(17) = "2700"                        '"11 in"
    strY(17) = "4170"                       '"17 in"
    strX(18) = "2080"                        '"8.5 in"
    strY(18) = "2700"                        ' "11 in"
    strX(19) = "980"             '3 7/8 in''
    strY(19) = "2250"               '8 7/8 in''
    strX(20) = "1080"           '4 1/8 in''
    strY(20) = "2410"           '9 1/2 in''
    strX(21) = "1140"           '4 1/2 in''
    strY(21) = "2120"           '10 3/8 in''
    strX(22) = "1140"           '4 1/2 in''
    strY(22) = "2790"           '11 in''
    strX(23) = "1270"           '5 in''
    strY(23) = "2920"           '11 1/2 in''
    strX(24) = ""
    strY(24) = ""
    strX(25) = ""
    strY(25) = ""
    strX(26) = ""
    strY(26) = ""
    strX(27) = "1100"
    strY(27) = "2200"
    strX(28) = "1620"
    strY(28) = "2290"
    strX(29) = "3240"
    strY(29) = "4580"
    strX(30) = "2290"
    strY(30) = "3240"
    strX(31) = "1140"
    strY(31) = "1620"
    strX(32) = "1140"
    strY(32) = "2290"
    strX(33) = "2500"
    strY(33) = "3530"
    strX(34) = "1760"
    strY(34) = "2500"
    strX(35) = "1760"
    strY(35) = "1250"
    strX(36) = "1100"
    strY(36) = "2300"
    strX(37) = "980"
    strY(37) = "1900"
    strX(38) = "920"
    strY(38) = "1650"
    strX(39) = "21420"                         '"14 7/8 in"
    strY(39) = "15840"                         '"11 in"
    strX(40) = "2160"
    strY(40) = "3050"
    strX(41) = "2160"
    strY(41) = "3300"
    strX(45) = "14400"                         '"10 in"
    strY(45) = "15840"                         '"11 in"
    strX(54) = "12240"                         '"8.5 in"
    strY(54) = "15840"                         '"11 in"
    strX(56) = ""
    strY(56) = ""

End Sub
Private Function GetListIndex(ByVal intNo As Integer) As Integer
Dim intCount As Integer
Dim blnFind As Boolean
    For intCount = 0 To CboSize.ListCount - 1
        If intNo = CboSize.ItemData(intCount) Then
            GetListIndex = intCount
            blnFind = True
            Exit For
        End If
    Next intCount
    If Not blnFind Then GetListIndex = 0
End Function

Private Function GetPaperSizeByName(ByVal StrPaperName As String, Optional ByVal blnZero As Boolean = False) As Integer
'根据ListIndex获得PaperSize属性
    Select Case StrPaperName
    Case "宽行打印纸, 14 7/8 x 11 英寸"
        GetPaperSizeByName = 39
    Case "窄行打印纸, 10 x 11  英寸"
        GetPaperSizeByName = 45
    Case "信笺, 8 1/2 x 11 英寸"
        GetPaperSizeByName = 1
    Case "分类帐, 17 x 11 英寸"
        GetPaperSizeByName = 4
    Case "A3 297 x 420 毫米"
        GetPaperSizeByName = 8
    Case "A4 210 x 297 毫米"
        GetPaperSizeByName = 9
    Case "A5 148 x 210 毫米"
        GetPaperSizeByName = 11
    Case "B4 250 x 354 毫米"
        GetPaperSizeByName = 12
    Case "B5 182 x 257 毫米"
        GetPaperSizeByName = 13
    Case "自定义纸张"
        GetPaperSizeByName = 256
    Case "默认纸张"
        If blnZero Then
            GetPaperSizeByName = 0
        Else
            GetPaperSizeByName = Printer.PaperSize
        End If
    Case Else
        If blnZero Then
            GetPaperSizeByName = 0
        Else
            GetPaperSizeByName = Printer.PaperSize
        End If
    End Select
End Function


Private Function MMToInch(ByVal lngValue As Long) As Long
    MMToInch = CLng(lngValue / 10 * 56.7 / 1440 * 100)
End Function
Private Function InchToMM(ByVal lngValue As Long) As Long
    InchToMM = CLng(lngValue / 100 * 1440 / 56.7 * 10)
End Function
Private Function MMToInch1(ByVal lngValue As Long) As Long
    MMToInch1 = CLng(lngValue * 56.7 / 1440 * 100)
End Function
Private Function MM1ToMM(ByVal lngValue As Long) As Long

    MM1ToMM = lngValue * 10
End Function
Private Function InchToMM1(ByVal lngValue As Long) As Long
    InchToMM1 = CLng(lngValue / 100 * 1440 / 56.7)
End Function
Private Function MMToMM1(ByVal lngValue As Long) As Long

    MMToMM1 = CLng(lngValue / 10)
End Function
Private Function TwipsToInch(ByVal lngValue As Long) As Long
    TwipsToInch = lngValue / 1440  '把其Twips转换为单位为英寸
End Function
Private Function TwipsToMM(ByVal lngValue As Long) As Long
    TwipsToMM = lngValue / 56.7 * 10
End Function


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -