转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> VB.NET程序 >> 正文
完美支持98、2000系统自定义打印纸张的VB代码         ★★★★

完美支持98、2000系统自定义打印纸张的VB代码

作者:闵涛 文章来源:闵涛的学习笔记 点击数:2799 更新时间:2009/4/23 15:04:10
sp;  .cy = FormSize.cy
      End With
      With .ImageableArea
          .Left = 0
          .Top = 0
          .Right = FI1.Size.cx
          .Bottom = FI1.Size.cy
      End With
  End With
  ReDim aFI1(Len(FI1))
  Call CopyMemory(aFI1(0), FI1, Len(FI1))
  RetVal = AddForm(PrinterHandle, 1, aFI1(0))
  If RetVal = 0 Then
      If Err.LastDllError = 5 Then
          MsgBox "You do not have permissions to add a form to " & _
             Printer.DeviceName, vbExclamation, "Access Denied!"
      Else
          MsgBox "Error: " & Err.LastDllError, , "Error Adding Form"
          ''''MsgBox "Error: " & Err.LastDllError, "Error Adding Form"
      End If
      AddNewForm = "none"
  Else
      AddNewForm = FI1.pName
  End If
End Function
Public Sub PrintTest()
  '''' Print two test pages to confirm the page size.
  Printer.Print "Top of Page 1."
  Printer.NewPage
  '''' Spacing between lines should reflect the chosen page height.
  Printer.Print "Top of Page 2. - Check the page Height (Length.)"
  Printer.EndDoc
  MsgBox "Check Printer " & Printer.DeviceName, vbInformation, "Done!"
End Sub
Public Function PtrCtoVbString(ByVal Add As Long) As String
  Dim sTemp As String * 512, X As Long
 
  X = lstrcpy(sTemp, ByVal Add)
  If (InStr(1, sTemp, Chr(0)) = 0) Then
       PtrCtoVbString = ""
  Else
       PtrCtoVbString = Left(sTemp, InStr(1, sTemp, Chr(0)) - 1)
  End If
End Function
Public Function IsNtOs() As Boolean
  Dim ver As OSVERSIONINFO
 
  ver.dwOSVersionInfoSize = 148
  GetVersionEx ver
  With ver
      Select Case .dwPlatformId
          Case 0, 1
            IsNtOs = False
          Case 2
            IsNtOs = True
      End Select
  End With
End Function
Public Function UseForm(FormName As String, sHwnd As Long) As Integer
  Dim RetVal As Integer
  Dim FormSize As SIZEL '''' Size of desired form
     
  RetVal = SelectForm(FormName, sHwnd) ''''选择纸张类型
  UseForm = RetVal
  Select Case RetVal
      Case FORM_NOT_SELECTED   '''' 0
          '''' 选择纸张失败!
          ''''MsgBox "Unable to retrieve From name", vbExclamation, _
             ''''"Operation halted!"
      Case FORM_SELECTED   '''' 1
          '''' 选择成功!
          ''''PrintTest     '''' Comment this line to avoid printing
      Case FORM_ADDED   '''' 2
          '''' 添加并选择成功.
          ''''PrintTest     '''' Comment this line to avoid printing
  End Select
End Function

''''调用,在Form1上放置Command1、Command2,复制下列代码:
Option Explicit

Private Sub Command1_Click()
  Dim FormName As String, RetValue As Integer

  ''''自定义打印纸张
  FormName = "广东省发票"
  RetValue = UseForm(FormName, Me.hwnd)
  ''''If RetValue = 0 Then GoTo errPrint
  PrintTest
End Sub

Private Sub Command2_Click()
  Dim FormName As String, RetValue As Integer
 
  ''''自定义打印纸张
  FormName = "80列报表"
  RetValue = UseForm(FormName, Me.hwnd)
  ''''If RetValue = 0 Then GoTo errPrint
  PrintTest
End Sub

Private Sub Form_Load()
  Command1.Caption = "打印发票"
  Command2.Caption = "打印报表"
End Sub

上一页  [1] [2] [3] 


没有相关教程
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台