Results 1 to 4 of 4

Thread: HELP W/ Device Contexts!!!

  1. #1

    Thread Starter
    Addicted Member Virtual24's Avatar
    Join Date
    May 2001
    Posts
    228

    Question HELP W/ Device Contexts!!!

    I am trying to set up a double buffering system for a program I am making so that I can draw images to a blank window without flicker. One problem!!! Lemme explain my code first, and then tell you the problem:
    Code:
    HDC prime, second;
    HBITMAP hbmp;
    
    prime = GetDC( hWnd );
    second = CreateCompatibleDC( prime );
    hbmp = CreateCompatibleBitmap( prime, wndWidth, wndHieght );
    SelectObject( second, hbmp );
    // Draw something on secondd here...
    //
    BitBlt( prime, 0, 0, wndWidth, wndHeight, second, 0, 0, SRCCOPY );
    wndWidth and wndHeight are set to equal the width and height of the client rect, and hWnd is set to the window's handle.

    My problem is: Whe i run the program the client rect is filled with all sorts of colors, looks like a mixed-up, jumbled picture of vc++ and my code!!! I even tried to set the DC to completely white first, but it doesnt work!!! I can still draw to the DC, but i can't figure out why its doing that. Does anyone know?
    To protect time is to protect everything...

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Does it only do it when you've *first started* the program? Try drawing a grey rectangle (filled) across the entire DC right after you've created it. Sounds like the memory isn't being reset properly somewhere (which it shouldn't be, I don't think).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Addicted Member Virtual24's Avatar
    Join Date
    May 2001
    Posts
    228
    I have tried that, not only with white, but with other colors. It's so wierd!!! I can draw anything on the DC but when I try to draw a rectangle the whole size of the window, it doesnt do anything!!! It just gives me that jumbled up picture.
    To protect time is to protect everything...

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Post the code.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width