How to capture the screen with the “Tool Tips”?

后端 未结 2 2001
Happy的楠姐
Happy的楠姐 2020-12-15 16:31

I am using GDI to capture the screen, and I have noticed that the \"Tool Tips\" are not included in the screenshot. This is my basic code:

HDC hdcDesk = GetD         


        
2条回答
  •  臣服心动
    2020-12-15 17:19

    I had the exact problem a few years ago with a windows XP system. The code in the answer to my question solved the problem:

    Capture screenshot Including Semitransparent windows in .NET

    For you, you should be able to just change your stretchblt line to bitblt and add captureblt:

    HDC hdcDesk = GetDC(0);
    
    HDC hdcMem = CreateCompatibleDC(hdcDesk);
    HBITMAP hbmMem = CreateCompatibleBitmap(hdcDesk, 1920, 1080);
    SelectObject(hdcMem, hbmMem);
    
    BitBlt(hdcMem, 0, 0, 1920, 1080, hdcDesk, 0, 0, SRCCOPY | CAPTUREBLT);
    
    // Now save the bitmap...
    

    Tooltips, like transparent windows, are skipped by spec of bitblt. Plus, you're not resizing, so use bitblt. If that doesn't work, there might be something else wrong with what you are doing as the other commenters hint, so you can convert the answer to my question from C# to C, that did work for me on XP. (of course I don't have XP any more to test but that was definitely the issue).

提交回复
热议问题