曾经尝试过,未果 
GetWindowDC得到的是显示设备场景上的句柄,所以遮掉就不行了不太清楚gdi是怎么把窗体画在设备场景上的,如果能重定位到想要的地方就好办了,(linux下就可以这样做)

解决方案 »

  1.   

    感谢您使用微软产品。以下文章中有一些将Screen、Form捕获到PictureBox的代码,您可以参考一下,希望能对您有所帮助:
    HOWTO: Capture and Print the Screen, a Form, or Any Window (Q161299)
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q161299 - 微软全球技术中心 VB技术支持本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
      

  2.   

    getdcex
    bitblt
    picturebox.autodraw=true
      

  3.   

    Option Base 0'一些API及其定义
    Private Type PALETTEENTRY
       peRed As Byte
       peGreen As Byte
       peBlue As Byte
       peFlags As Byte
    End TypePrivate Type LOGPALETTE
       palVersion As Integer
       palNumEntries As Integer
       palPalEntry(255) As PALETTEENTRY
    End Type
       
    Private Type GUID
       Data1 As Long
       Data2 As Integer
       Data3 As Integer
       Data4(7) As Byte
    End TypePrivate Const RASTERCAPS As Long = 38
    Private Const RC_PALETTE As Long = &H100
    Private Const SIZEPALETTE As Long = 104Private Type RECT
       Left As Long
       Top As Long
       Right As Long
       Bottom As Long
    End TypePrivate Type PicBmp
       Size As Long
       Type As Long
       hBmp As Long
       hPal As Long
       Reserved As Long
    End TypePrivate 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 GetDeviceCaps Lib "GDI32" (ByVal hDC As Long, ByVal iCapabilitiy As Long) As Long
    Private Declare Function GetSystemPaletteEntries Lib "GDI32" (ByVal hDC As Long, ByVal wStartIndex As Long, ByVal wNumEntries As Long, lpPaletteEntries As PALETTEENTRY) As Long
    Private Declare Function CreatePalette Lib "GDI32" (lpLogPalette As LOGPALETTE) 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 hDCDest As Long, ByVal XDest As Long, ByVal YDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hDCSrc As Long, ByVal XSrc As Long, ByVal YSrc As Long, ByVal dwRop As Long) As Long
    Private Declare Function DeleteDC Lib "GDI32" (ByVal hDC As Long) As Long
    Private Declare Function SelectPalette Lib "GDI32" (ByVal hDC As Long, ByVal hPalette As Long, ByVal bForceBackground As Long) As Long
    Private Declare Function RealizePalette Lib "GDI32" (ByVal hDC As Long) As Long
    Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDC As Long) As Long
    Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As PicBmp, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
    Private Declare Function GetPixel Lib "GDI32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long) As Long
    Private Declare Function SetPixel Lib "GDI32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long'创建一张Bmp的Picture
    Private Function CreateBitmapPicture(ByVal hBmp As Long, ByVal hPal As Long) As Picture
      Dim r As Long   Dim Pic As PicBmp
       Dim IPic As IPicture
       Dim IID_IDispatch As GUID   With IID_IDispatch
          .Data1 = &H20400
          .Data4(0) = &HC0
          .Data4(7) = &H46
       End With   With Pic
          .Size = Len(Pic)
          .Type = vbPicTypeBitmap
          .hBmp = hBmp
          .hPal = hPal
       End With   r = OleCreatePictureIndirect(Pic, IID_IDispatch, 1, IPic)   Set CreateBitmapPicture = IPic
    End Function'生成PictureBox的Picture
    Private Function CaptureWindow(ByVal hWndSrc As Long, ByVal LeftSrc As Long, ByVal TopSrc As Long, ByVal WidthSrc As Long, ByVal HeightSrc As Long) As Picture  Dim hDCMemory As Long
      Dim hBmp As Long
      Dim hBmpPrev As Long
      Dim r As Long
      Dim hDCSrc As Long
      Dim hPal As Long
      Dim hPalPrev As Long
      Dim RasterCapsScrn As Long
      Dim HasPaletteScrn As Long
      Dim PaletteSizeScrn As Long
      Dim LogPal As LOGPALETTE  hDCSrc = GetDC(hWndSrc)  hDCMemory = CreateCompatibleDC(hDCSrc)
      hBmp = CreateCompatibleBitmap(hDCSrc, WidthSrc, HeightSrc)
      hBmpPrev = SelectObject(hDCMemory, hBmp)  RasterCapsScrn = GetDeviceCaps(hDCSrc, RASTERCAPS)
      HasPaletteScrn = RasterCapsScrn And RC_PALETTE
      PaletteSizeScrn = GetDeviceCaps(hDCSrc, SIZEPALETTE)   If HasPaletteScrn And (PaletteSizeScrn = 256) Then
          LogPal.palVersion = &H300
          LogPal.palNumEntries = 256
          r = GetSystemPaletteEntries(hDCSrc, 0, 256, LogPal.palPalEntry(0))
          hPal = CreatePalette(LogPal)
          hPalPrev = SelectPalette(hDCMemory, hPal, 0)
          r = RealizePalette(hDCMemory)
       End If   r = BitBlt(hDCMemory, 0, 0, WidthSrc, HeightSrc, hDCSrc, LeftSrc, TopSrc, vbSrcCopy)   hBmp = SelectObject(hDCMemory, hBmpPrev)   If HasPaletteScrn And (PaletteSizeScrn = 256) Then
          hPal = SelectPalette(hDCMemory, hPalPrev, 0)
       End If   r = DeleteDC(hDCMemory)
       r = ReleaseDC(hWndSrc, hDCSrc)   Set CaptureWindow = CreateBitmapPicture(hBmp, hPal)
    End Function
    呵呵
    这样使用
    Set Picture2.Picture = CaptureWindow(Me.hwnd, 0, 0, 80, 80)明白?不知道来得及不哦?
     
      

  4.   

    简单
    有个API函数叫什么SETPATER,设置指定控件为另一个控件的父类
    SETPATER  子类句柄,父类句柄
      

  5.   

    透明窗口(非 Win2000)???
    想过,没有做过.
    试一下 GetDcEx 函数,它可以从窗口的缓存里面获取场景,成功的话发个 Emain
    [email protected]
      

  6.   

    在 Win98,WinMe 里面好象不能实现哦!散分好了,小弟(好象你自己说的,年纪小)