CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Apr 2009

    [DC's] - how can i create an empty DC with window size?

    struct ImageInfo
        HBITMAP ImageImage;
        BITMAP Imagebm;
        HDC ImagehdcMem;
        HBITMAP ImageMaskImage;
        BITMAP ImageMaskbm;
        HDC ImageMaskhdcMem;
    ImageInfo DoubleBuffer;
    DoubleBuffer.ImagehdcMem  = CreateCompatibleDC (Console.WindowDC);//Console.WindowDC is window DC        
    DoubleBuffer.ImageImage   = CreateCompatibleBitmap (Console.WindowDC,rec.right-rec.left ,  rec.bottom-rec.top); //rec is the window RECT
    SelectObject (Console.WindowDC , Console.WindowHandle); //Console.WindowHandle is the window handle
    TextOut(DoubleBuffer.ImagehdcMem,10,10, "Hello world",strlen("Hello world"));
    BitBlt(Console.WindowDC,0,0,DoubleBuffer.Imagebm.bmWidth  , DoubleBuffer.Imagebm.bmHeight ,DoubleBuffer.ImagehdcMem,0,0,SRCCOPY);     
    why the text isn't show in window after use BitBlt()?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Hanover Germany

    Re: [DC's] - how can i create an empty DC with window size?

    Where do you call this code from?
    Victor Nijegorodov

  3. #3
    Join Date
    Apr 2009

    Re: [DC's] - how can i create an empty DC with window size?

    Quote Originally Posted by VictorN View Post
    Where do you call this code from?
    (in my Menu() function)
    finally i resolve it. but i don't know why wasn't
    GetWindowRect(Console.WindowHandle, &rectWindow);  
        HDC DoubleBuffer = CreateCompatibleDC(NULL);
        HBITMAP mbmp =  CreateCompatibleBitmap(Console.WindowDC,rectWindow.right- rectWindow.left ,  rectWindow.bottom-rectWindow.top); // width, height, 1, bit_depth, NULL
        HBITMAP moldbmp = (HBITMAP)SelectObject(DoubleBuffer,mbmp);
    but think on that: why 2 handle (mbmp and moldbmp ) variables and what is the handle that we need?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.