Private Const WM_PAINT=& amp; HF
Private Const WM_PRINT=& amp; H317
Private Const PRF_CLIENT=& amp; H4 & amp;
Private Const PRF_CHILDREN=& amp; H10 & amp;
Private Const PRF_OWNED=& amp; H20 & amp;
Private Const PHYSICALOFFSETX As Long=112
Private Const PHYSICALOFFSETY As Long=113
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal HWND _
As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam) As Long As Long
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal HDC As Long, ByVal nindex _
As Long As Long)
Private Sub Command1_Click ()
Dim the rv As Long
The rv=SendMessage (Frame1 HWND, the WM_PAINT, Picture1. HDC, 0)
The rv=SendMessage (Frame1 HWND WM_PRINT, Picture1. HDC, PRF_CHILDREN + PRF_CLIENT + PRF_OWNED)
Printer. Print "
"Printer. PaintPicture Picture2. Image, 100-50
Printer. EndDoc
End Sub
CodePudding user response:
Why not use setparent?CodePudding user response:
Can't readBut changing the second sentence to this, there is no border
The rv=SendMessage (Frame1 HWND WM_PRINT, Picture1. HDC, PRF_CHILDREN + PRF_NONCLIENT
CodePudding user response:
I can't, the second sentence toThe rv=SendMessage (Frame1 HWND WM_PRINT, Picture1. HDC, PRF_CHILDREN + PRF_NONCLIENT + PRF_OWNED)
Is no border, but the text of the frame, frame controls all not loaded into the picture1 container, only load label control, equal to I commented out the second sentence
CodePudding user response:
Setparent can be loaded into the picture1 container, but seems to be directly copied into the picture1, use Printer. PaintPicture Picture2. Image, 100-50Printing is blank
CodePudding user response:
With the frame and put a picture control, put all controls on the pictureCodePudding user response:
With two PictureBox beforehand, one of the forms controls container, another for print media (empty), note: the two don't nested, each other will be hidden behind the first, second SendMessage send PictureBox1, here are two examples of the Label form print,Private Const twipFactor=1440
Private Const WM_PAINT=& amp; HF
Private Const WM_PRINT=& amp; H317
Private Const PRF_CLIENT=& amp; H4 & amp; 'the Draw the window' s client area.
Private Const PRF_CHILDREN=& amp; H10 & amp; 'the Draw all the visible child Windows.
Private Const PRF_OWNED=& amp; H20 & amp; 'the Draw all owned Windows.
Private Declare Function SendMessage Lib "user32 Alias" _
"SendMessageA" (ByVal HWND As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam) As Long As Long
Private Sub Form_Load ()
Dim sWide As Single, sTall As Single
Dim the rv As Long
Me. The ScaleMode default=vbTwips'
SWide=8.5
'stall=11 or 14, etc.
Me. Width=twipFactor * sWide
Me. Height=twipFactor * stall
With Picture1
. The Top=0
. The Left=0
. Width=twipFactor * sWide
The Height=twipFactor * stall
End With
With Picture2
. The Top=0
. The Left=0
. Width=twipFactor * sWide
The Height=twipFactor * stall
End With
With Label1
The Caption="Top"
. Left=Me. Width/2
. The Top=0
End With
With Label2
The Caption="Bottom"
. The Top=(twipFactor * stall) -. The Height * 2
. Left=Me. Width/2
End With
Me. The Visible=True
DoEvents
Picture1. SetFocus
Picture2. AutoRedraw=True
The rv=SendMessage (Picture1. HWND, WM_PAINT, Picture2. HDC, 0)
The rv=SendMessage (Picture1. HWND WM_PRINT, Picture2. HDC, _
PRF_CHILDREN + PRF_CLIENT + PRF_OWNED)
Picture2. Picture=Picture2. Image
Picture2. AutoRedraw=False
Printer. Print "
"Printer. PaintPicture Picture2. Picture, 0, 0
Printer. EndDoc
End Sub