- Option Explicit
-
- Private Declare Function BitBlt Lib "gdi32.dll" ( _
- ByVal hDestDC 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 dwRop As Long) As Long
-
- Private Declare Function GetDesktopWindow Lib _
- "user32.dll" () As Long
-
- Private Declare Function GetDC Lib "user32.dll" ( _
- ByVal hWnd As Long) As Long
-
- Private Const SRCCOPY As Long = &HCC0020
-
- Public Sub SaveMSChart(ByRef Pic As PictureBox, _
- ByRef mform As Form, ByVal mObj As Object, _
- ByVal mFileName As String)
- Pic.Visible = False
- Pic.AutoRedraw = True
- Pic.Cls
- mform.ScaleMode = vbTwips
- Dim Temp As Double
- Dim XU As Double, YU As Double
- Dim XD As Double, YD As Double
- Temp = (mform.Width - mform.ScaleWidth) / 2
- XU = mform.Left + Temp + mObj.Left
- YU = mform.Top + (mform.Height - mform.ScaleHeight) - _
- Temp + mObj.Top
- XD = XU + mObj.Width
- YD = YU + mObj.Height
- Pic.Width = (XD - XU)
- Pic.Height = (YD - YU)
- XU = XU / Screen.TwipsPerPixelX
- YU = YU / Screen.TwipsPerPixelY
- XD = XD / Screen.TwipsPerPixelX
- YD = YD / Screen.TwipsPerPixelY
- BitBlt Pic.hDC, 0&, 0&, Screen.Width, _
- Screen.Height, GetDC(GetDesktopWindow()), _
- CLng(XU), CLng(YU), SRCCOPY
- SavePicture Pic.Image, mFileName
- End Sub
Option Explicit
Private Declare Function BitBlt Lib "gdi32.dll" ( _
ByVal hDestDC 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 dwRop As Long) As Long
Private Declare Function GetDesktopWindow Lib _
"user32.dll" () As Long
Private Declare Function GetDC Lib "user32.dll" ( _
ByVal hWnd As Long) As Long
Private Const SRCCOPY As Long = &HCC0020
Public Sub SaveMSChart(ByRef Pic As PictureBox, _
ByRef mform As Form, ByVal mObj As Object, _
ByVal mFileName As String)
Pic.Visible = False
Pic.AutoRedraw = True
Pic.Cls
mform.ScaleMode = vbTwips
Dim Temp As Double
Dim XU As Double, YU As Double
Dim XD As Double, YD As Double
Temp = (mform.Width - mform.ScaleWidth) / 2
XU = mform.Left + Temp + mObj.Left
YU = mform.Top + (mform.Height - mform.ScaleHeight) - _
Temp + mObj.Top
XD = XU + mObj.Width
YD = YU + mObj.Height
Pic.Width = (XD - XU)
Pic.Height = (YD - YU)
XU = XU / Screen.TwipsPerPixelX
YU = YU / Screen.TwipsPerPixelY
XD = XD / Screen.TwipsPerPixelX
YD = YD / Screen.TwipsPerPixelY
BitBlt Pic.hDC, 0&, 0&, Screen.Width, _
Screen.Height, GetDC(GetDesktopWindow()), _
CLng(XU), CLng(YU), SRCCOPY
SavePicture Pic.Image, mFileName
End Sub