Private Const PW_CLIENTONLY As Long = 1
Private Const WM_PRINT As Long = &H317Private Const PRF_CHILDREN As Long = &H10&
Private Const PRF_CLIENT As Long = &H4&
Private Const PRF_ERASEBKGND As Long = &H8&
Private Const PRF_LOOKFOREXT As Long = &H3
Private Const PRF_OWNED As Long = &H20&
Private Const PRF_QUALIFY As Long = &H4
Private Const PRF_WIN31 As Long = &H8Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End TypePrivate 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 Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongPrivate Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function PrintWindow Lib "user32" (ByVal SrcHwnd As Long, ByVal DesHDC As Long, ByVal uFlag As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (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 CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As LongPrivate Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function EmptyClipboard Lib "user32" () As Long
'Private Declare Function SetClipboardData Lib "user32" Alias "SetClipboardDataA" (ByVal wFormat As Long, ByVal hMem As Long) As Long
Private Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As LongPrivate Sub Command1_Click()
    Dim hw&, hdc&, x As RECT
    hw = Val(Text1)
    
    hdcScreen = GetDC(hw)
    GetWindowRect hw, x
    'hdcScreen = CreateDC("DISPLAY", vbNullString, vbNullString, 0)
    hdc = CreateCompatibleDC(hdcScreen)
    hbmp = CreateCompatibleBitmap(hdcScreen, x.Right - x.Left, x.Bottom - x.Top)
    SelectObject hdc, hbmp
    PrintWindow hw, hdc, PW_CLIENTONLY    BitBlt Picture1.hdc, 0, 0, x.Right - x.Left, x.Bottom - x.Top, hdc, 0, 0, vbSrcCopy    DeleteDC hdc
    DeleteObject hbmp
   
   'SendMessage hw, WM_PRINT, Picture1.hdc, PRF_CHILDREN Or PRF_CLIENT Or PRF_ERASEBKGND Or PRF_NONCLIENT Or PRF_OWNED
    Picture1.Refresh
End Sub
  
Private Sub Form_Load()
    Picture1.AutoRedraw = True
    Me.ScaleMode = 3
    Picture1.ScaleMode = 3
End Sub我测试被挡住的话可以截图出来,但是最小化就不行了,不知道别人的后台取色取图是不是这么写的?怎么取最小化后的图??
还有SendMessage那句貌似不行,why??