|
-
Oct 28th, 2002, 06:12 PM
#1
Thread Starter
Addicted Member
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...
-
Oct 28th, 2002, 06:20 PM
#2
Monday Morning Lunatic
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
-
Oct 28th, 2002, 06:26 PM
#3
Thread Starter
Addicted Member
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...
-
Oct 29th, 2002, 03:06 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|