Public Group

Archived

This topic is now archived and is closed to further replies.

stupid WIN32 GDI crappy $#@#@$#@$&(@#(*$@(#*

This topic is 5296 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

how can i force a win32 app to re-paint itself. im making a stopwatch type app and the output is obviously text in a window that updates itself a gajillion times per second (as fast as computer can call gettickcount and calculate minutes and secs from it). so... i either need to force repaint because all of my textdraw is in that function or i need a way to draw outside of the paint function so that i can keep the stopwatch updated as often as computationly possible. i suck at life. please help. [edited by - machiavelli on February 21, 2004 1:01:41 AM]

Share on other sites
You need to invalidate the window rectangle. A call to InvalidateRect() after your calculations should tell windows to update the display.

Something like InvalidateRect(hWnd, NULL, true); should work well enough.

-Arek the Absolute

[edited by - Arek the Absolute on February 21, 2004 1:07:50 AM]

Share on other sites
thanks for your help that works but it produces a buttload of flickering... any other suggestions?

Share on other sites
there should be a window message for that, look at msdn, i would, but msdn is your friend ill let you get to know it :-D (translation: im lazy)

Share on other sites
There are a number of things you can do... Sorry if my memory''s a bit fuzzy on this though, it''s been a long time since I''ve done much in the way of graphics with GDI.

Basically, you see flicker because it takes time between when it erases what it draws, and when it prints the new text on the screen. You''d see less flicker if you passed the function false instead of true, because it wouldn''t erase the background, but instead your text would be illegible after one or two printouts. However, this will work fine if you draw every pixel within the rectangle though, for instance with BitBlt. If you need more suggestions, try looking into double buffering.

Sorry I''m not being more specific. The first time it was just not knowing a function, but this is something you should try to reason your way through. Hopefully I''ve given you hints enough to point you in the right direction. If you can''t get it after a while, feel free to ask again and I''ll be more specific, but it would really benefit you to be able to figure out the code yourself.

-Arek the Absolute

Share on other sites
quote:
Original post by machiavelli
thanks for your help that works but it produces a buttload of flickering... any other suggestions?

Double buffer whatever you''re drawing.

"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud

Share on other sites
Dubblebuffring in the gdi sample:

	// Initialize backbuffer	HDC hdc = GetDC( hwnd );	HDC hdcBackBuffer = CreateCompatibleDC( hdc );	HBITMAP hbBackBuffer = CreateCompatibleBitmap( hdcBackBuffer, 640, 480 );	SelectObject( hdcBackBuffer, (HANDLE)hbBackBuffer );		ReleaseDC( hwnd, hdc );// in the main loop do thiswhile(1){	// Get Dc & clear surface		HDC hdc = GetDC( hwnd );		BitBlt( hdcBackBuffer, 0, 0, 640, 480, 0, 0, 0, WHITENESS);// Paint your stuff here, target hdc is the backbuffer// for instance, draw text:TextOut(hdcBackBuffer, 150, 35, "hello", (int)strlen("hello"));// last thing you do is this:// Flip surfaces		BitBlt( hdc, 0, 0, 640, 480, hdcBackBuffer, 0, 0, SRCCOPY);		ReleaseDC( hwnd, hdc );}

1. 1
2. 2
JoeJ
20
3. 3
frob
19
4. 4
5. 5

• 10
• 11
• 12
• 13
• 9
• Forum Statistics

• Total Topics
632206
• Total Posts
3004772

×