Window updating via Win32 API

YL3GDY

New member
Joined
Apr 7, 2008
Messages
80
Reaction score
0
Points
0
Location
QRA-Locator KO26CX
Hi All,

currently I am doing my homework on programming: a programm on C++ which draws in the window an analog clock using LineTo(), Ellipse() and TextOut() functions. I had a problem: I can't force window to redraw it's client area(the clock simply looks stopped). I tried to use SetTimer, and in timer procedure call UpdateWindow, but I had no success.

Can anyone explain, how it can be solved?

P.S. I've written a class, which contains repaint routine. Object of this class is defined as global variable(I know that it's stupid, but I haven't thought of something more clever that works in callback and regular functions).
 

GLS

Well-known member
Orbiter Contributor
Addon Developer
Joined
Mar 22, 2008
Messages
5,927
Reaction score
2,937
Points
188
Website
github.com
There has been sometime since I've done Win32 apps...:hmm:
I think you should draw the clock when you recieve the WM_PAINT message.
To *force* a redraw, send a WM_PAINT message, using SendMessage(), from a SetTimer call.

Hope it works....;)
 

agentgonzo

Grounded since '09
Addon Developer
Joined
Feb 8, 2008
Messages
1,649
Reaction score
4
Points
38
Location
Hampshire, UK
Website
orbiter.quorg.org
To *force* a redraw, send a WM_PAINT message, using SendMessage(), from a SetTimer call.
Actually, it's much better to call InvalidateRect() or Invalidate() to force a redraw rather than manually sending the MW_PAINT message. Assuming you're using GDI/MFC that is...
 

YL3GDY

New member
Joined
Apr 7, 2008
Messages
80
Reaction score
0
Points
0
Location
QRA-Locator KO26CX
Thank you for your info! I've tried to use GetClientRect and InvalidateRect(), looks like it works (at least!).
 
Top