发布网友 发布时间:2022-04-23 13:29
共2个回答
热心网友 时间:2023-10-15 18:22
建立一个PictureBox1,窗体中引用API,在得到CDN_SELCHANGE时,调用GetFilesName得到此时用户选中的 文件,代码如下:
Private Function GetFilesName(hWindow As Long) As String
Dim hParent As Long
Dim lRetValue As Long
Dim theFileName(1024) As Byte
For i = 0 To UBound(theFileName)
theFileName(i) = 0
Next
hParent = GetParent(hWindow)
lRetValue = SendMessage(hParent, CDM_GETFILEPATH, 1024, theFileName(0))
GetFilesName = StrConv(theFileName, vbUnicode)
End Function
调用GetOpenFileName API的方法如下:
Public Function ShowOpenFileDlg(hParent As Long) As Long
On Error GoTo lblExit
Static strFilter As String
strFilter = "All Pictures" & Chr(0) & "*.bmp;*.dib;*.jpg;*.gif;*.wmf;*.emf;*.ico;*.cur" & Chr(0) & _
"Bitmap (*.bmp;*.dib)" & Chr(0) & "*.bmp;*.dib" & Chr (0) & _
"JPEG (*.jpg)" & Chr(0) & "*.jpg" & Chr(0) & _
"GIF (*.gif)" & Chr(0) & "*.gif" & Chr(0) & _
"Metafile (*.wmf;*.emf)" & Chr(0) & "*.wmf;*.emf" & Chr(0) & _
"Icons (*.ico;*.cur)" & Chr(0) & "*.ico;*.cur" & Chr (0) & _
"All files (*.*)" & Chr(0) & "*.*" & Chr(0) & Chr (0)
FrmPreview.Hide
pointer = GetProcAddr(AddressOf wndProc)
Dim MyID As Long
With openfile
.lStructSize = Len(openfile)
.hwndOwner = hParent
.hInstance = App.hInstance
.lpstrFilter = strFilter
.lpstrCustomFilter = ""
.nMaxCustFilter = 0
.nFilterIndex = 0
.lpstrFile = filesname
.nMaxFile = 1023
.lpstrFileTitle = ""
.nMaxFileTitle = 0
.lpstrInitialDir = ""
.lpstrTitle = ""
.flags = OFN_ENABLEHOOK + OFN_HIDEREADONLY + OFN_ENABLETEMPLATE + OFN_EXPLORER
.nFileOffset = 0
.nFileExtension = 0
.lpstrDefExt = ""
.lCustData = 0
.lpfnHook = pointer
.lpTemplateName = "DLGOPENTEMP"
End With
ShowOpenFileDlg = GetOpenFileName(openfile)
lblExit:
End Function
在窗体中CALL函数模块,让Picture装载到VSPrint,,设置代码如下:
'---------------------预览报表
VSPrinter1.StartDoc
VSPrinter1.Zoom = 100 '显示比例为100%
VSPrinter1.RenderControl = Form1.Picture1.hWnd
'----------------------设置
With VSPrinter1
'设置标题
.FontSize = 16
.FontBold = True
.TextAlign = taCenterMiddle
.Paragraph = "打印人:张三"
.Footer = "打印日期: " & Format(Date, "yyyy/mm/dd ") & " 第 " & ipage & "页,共 " & pages & "页 "
.FontBold = True
.FontSize = 10
.TextAlign = taRightTop
.Paragraph = " "
.FontBold = False
.FontSize = 10
End With
VSPrinter1.EndDoc
热心网友 时间:2023-10-15 18:23
没用过VSPRINTER控件,对方必定给你一些说明和示例的.你查看一下或咨询控件的提供方吧.
热心网友 时间:2023-10-15 18:22
建立一个PictureBox1,窗体中引用API,在得到CDN_SELCHANGE时,调用GetFilesName得到此时用户选中的 文件,代码如下:
Private Function GetFilesName(hWindow As Long) As String
Dim hParent As Long
Dim lRetValue As Long
Dim theFileName(1024) As Byte
For i = 0 To UBound(theFileName)
theFileName(i) = 0
Next
hParent = GetParent(hWindow)
lRetValue = SendMessage(hParent, CDM_GETFILEPATH, 1024, theFileName(0))
GetFilesName = StrConv(theFileName, vbUnicode)
End Function
调用GetOpenFileName API的方法如下:
Public Function ShowOpenFileDlg(hParent As Long) As Long
On Error GoTo lblExit
Static strFilter As String
strFilter = "All Pictures" & Chr(0) & "*.bmp;*.dib;*.jpg;*.gif;*.wmf;*.emf;*.ico;*.cur" & Chr(0) & _
"Bitmap (*.bmp;*.dib)" & Chr(0) & "*.bmp;*.dib" & Chr (0) & _
"JPEG (*.jpg)" & Chr(0) & "*.jpg" & Chr(0) & _
"GIF (*.gif)" & Chr(0) & "*.gif" & Chr(0) & _
"Metafile (*.wmf;*.emf)" & Chr(0) & "*.wmf;*.emf" & Chr(0) & _
"Icons (*.ico;*.cur)" & Chr(0) & "*.ico;*.cur" & Chr (0) & _
"All files (*.*)" & Chr(0) & "*.*" & Chr(0) & Chr (0)
FrmPreview.Hide
pointer = GetProcAddr(AddressOf wndProc)
Dim MyID As Long
With openfile
.lStructSize = Len(openfile)
.hwndOwner = hParent
.hInstance = App.hInstance
.lpstrFilter = strFilter
.lpstrCustomFilter = ""
.nMaxCustFilter = 0
.nFilterIndex = 0
.lpstrFile = filesname
.nMaxFile = 1023
.lpstrFileTitle = ""
.nMaxFileTitle = 0
.lpstrInitialDir = ""
.lpstrTitle = ""
.flags = OFN_ENABLEHOOK + OFN_HIDEREADONLY + OFN_ENABLETEMPLATE + OFN_EXPLORER
.nFileOffset = 0
.nFileExtension = 0
.lpstrDefExt = ""
.lCustData = 0
.lpfnHook = pointer
.lpTemplateName = "DLGOPENTEMP"
End With
ShowOpenFileDlg = GetOpenFileName(openfile)
lblExit:
End Function
在窗体中CALL函数模块,让Picture装载到VSPrint,,设置代码如下:
'---------------------预览报表
VSPrinter1.StartDoc
VSPrinter1.Zoom = 100 '显示比例为100%
VSPrinter1.RenderControl = Form1.Picture1.hWnd
'----------------------设置
With VSPrinter1
'设置标题
.FontSize = 16
.FontBold = True
.TextAlign = taCenterMiddle
.Paragraph = "打印人:张三"
.Footer = "打印日期: " & Format(Date, "yyyy/mm/dd ") & " 第 " & ipage & "页,共 " & pages & "页 "
.FontBold = True
.FontSize = 10
.TextAlign = taRightTop
.Paragraph = " "
.FontBold = False
.FontSize = 10
End With
VSPrinter1.EndDoc
热心网友 时间:2023-10-15 18:23
没用过VSPRINTER控件,对方必定给你一些说明和示例的.你查看一下或咨询控件的提供方吧.