[DC's] - how can i create an empty DC with window size?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

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

  1. #1
    Join Date
    Apr 2009
    Posts
    719

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

    Code:
    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);     
    system("pause");
    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
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,524

    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
    Posts
    719

    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
    Code:
    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

This is a CodeGuru survey question.


Featured


HTML5 Development Center