Thread View: fj.lang.visualbasic
1 messages
1 total messages
Started by tkata
Wed, 22 Apr 1998 00:00
任意の位置にフォームを印刷する方法は?
Author: tkata
Date: Wed, 22 Apr 1998 00:00
Date: Wed, 22 Apr 1998 00:00
75 lines
3596 bytes
3596 bytes
任意の位置にフォームを印刷する方法は?
通常、VBでフォームを印刷するには、PrintFormメソッドを使います。
(例:frm1.PrintForm
Printer.EndDoc )
しかし、PrintFormメソッドだと、用紙の任意の位置にフォームを印刷する
ことができません。
ちなみに、マイクロソフトのサンプルソースも試してみたのですが、ダメ
でした。A4用紙が白紙のままプリントアウトされるのです。
よろしくご教授願います。
回答例:
・この本を見たら
・ここのWebへ行ってみれば
・直接の答えは知らないが、APIの○○○を使ったら?
・APIは知らんけど、やり方は○○○と思うよ (PaintPictureメソッド?)
・その他[ ]
----------------------------------------------------------------------
・PrintForm を使わないフォーム イメージの印刷
http://www.microsoft.com/japan/developer/vbasic/
http://www.microsoft.com/japan/developer/vbasic/techinfo/
http://www.microsoft.com/japan/developer/vbasic/resource/sample.htm
Attribute VB_Name = "PrnFrmEx"
Option Explicit
'これら 2 つの Decrare 宣言は API ビューワーを利用するのが確実です。
#If Win32 Then
Private Declare Function StretchBlt Lib "gdi32" (ByVal hDC As Long, _
ByVal X As Long, ByVal Y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hSrcDC As Long, _
ByVal XSrc As Long, ByVal YSrc As Long, _
ByVal nSrcWidth As Long, _
ByVal nSrcHeight As Long, _
ByVal dwRop As Long) As Long
#Else
Private Declare Function StretchBlt Lib "GDI" (ByVal hDC As Integer, _
ByVal X As Integer, ByVal Y As Integer, _
ByVal nWidth As Integer, ByVal nHeight As Integer, _
ByVal hSrcDC As Integer, _
ByVal XSrc As Integer, ByVal YSrc As Integer, _
ByVal nSrcWidth As Integer, ByVal nSrcHeight As Integer,
_
ByVal dwRop As Long) As Integer
#End If
Private Const SRCCOPY = &HCC0020
Public Sub PrintFormEx(frm As Form)
' 引数
' frm : 印刷したいフォーム
'
' 使用例
' PrintFormEx Form1
Dim result As Long
' Visual Basic にプリンタの使用を認識させるためのダミー コード
Printer.Print " "
Printer.CurrentX = 0
Printer.CurrentY = 0
result = StretchBlt(Printer.hDC, 0, 0, _
frm.ScaleWidth / Printer.TwipsPerPixelX, _
frm.ScaleHeight / Printer.TwipsPerPixelY, _
frm.hDC, 0, 0, _
frm.ScaleWidth / Screen.TwipsPerPixelX, _
frm.ScaleHeight / Screen.TwipsPerPixelY, _
SRCCOPY)
Printer.EndDoc
End Sub
----------------------------------------------------------------------
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads