' Copy the image of this control onto the
' destination PictureBox.
Private Sub CopyControlImage(ByVal destination As _
PictureBox, ByVal target As Control)
destination.Width = target.Width + destination.Width - _
destination.ScaleWidth
destination.Height = target.Height + destination.Height _
- destination.ScaleHeight
destination.PaintPicture _
picHidden.Picture, 0, 0, _
target.Width, target.Height, _
target.Left + m_XOffset, target.Top + m_YOffset, _
target.Width, target.Height
destination.Picture = destination.Image
End Sub
' Get the offset from the corner of the border.
Private Sub GetFormOffset()
Dim pt As POINTAPI
pt.X = 0
pt.Y = 0
ClientToScreen Me.hwnd, pt
m_XOffset = pt.X - ScaleX(Me.Left, vbTwips, vbPixels)
m_YOffset = pt.Y - ScaleY(Me.Top, vbTwips, vbPixels)
End Sub
' Copythe form's image into picHidden.
Private Function GetFormPicture()
#Const WINDOWS_VERSION = "Windows2000"
Dim alt_key As Long
' Capture an image of the form in the clipboard.
' Press Alt.
alt_key = MapVirtualKey(VK_MENU, 0)
keybd_event VK_MENU, alt_key, 0, 0
DoEvents
' Press Print Scrn.
#If WINDOWS_VERSION = "Windows2000" Then
keybd_event VK_SNAPSHOT, 0, 0, 0
#Else
keybd_event VK_SNAPSHOT, 1, 0, 0
#End If
DoEvents
' Release Alt.
keybd_event VK_MENU, alt_key, KEYEVENTF_KEYUP, 0
DoEvents
' Make picHidden big enough.
picHidden.BorderStyle = vbBSNone
picHidden.Width = Me.Width
picHidden.Height = Me.Height
' Paste the image into picHidden.
picHidden.Picture = Clipboard.GetData(vbCFBitmap)
End Function
|