frank5@mars.njit.edu (Frank D. Greco CIS Adj. Prof.) (07/24/89)
I'm a little puzzled on two points in MS Windows, perhaps someone out there could help me. 1. I am a little unsure on the differences between: InvalidateRect() and UpdateWindow(). Are the following equivalent or not: InvalidateRect(hwnd, NULL, TRUE); UpdateWindow(hwnd); If these are functionally the same, which is preferred and why? 2. Regarding timers... I can set one timer fine, but when I try to create more than one (i.e, two !) the first one doesn't seem to work anymore. Is there something fundamental that I've missed? Thanks all, Frank
ano@blake.acs.washington.edu (John Michael Ano) (08/13/89)
In article <654@njitgw.njit.edu> frank5@mars.njit.edu (Frank D. Greco CIS Adj. Prof.) writes: > >1. I am a little unsure on the differences between: InvalidateRect() > and UpdateWindow(). Are the following equivalent or not: > > InvalidateRect(hwnd, NULL, TRUE); > > UpdateWindow(hwnd); No, these are not equivalent. First of all InvalidateRect (and InvalidateRgn) specify areas to be updated on the client area of the app in question. Calling UpdateWindow without a previously specified update region will not have any effect -- no repainting gets done. The InvalidateRect function puts a WM_PAINT message in your application's message queue but only if the queue is empty and if no other applications have messages waiting in their respective queues. Windows places relatively low priority on WM_PAINT messages and therefore waits until message-processing demand drops before sticking it in your app's message queue. The skinny of it all is that InvalidateRect() will not always give you an immediate repaint of your app's client area. If you want your app to redraw the client area immediately, (as you specified with the NULL parameter in InvalidateRect) that's where UpdateWindow comes in. When you call this function, it forces Windows to send a WM_PAINT message to your app's window function immediately, bypassing any other application's message queue, as well as any incoming messages for your app. The result is an immediate repaint of your client area, but slower processing of other messages. >2. Regarding timers... I can set one timer fine, but when I try to > create more than one (i.e, two !) the first one doesn't seem to > work anymore. Is there something fundamental that I've missed? There could be a number of reasons why you're experiencing this problem. I'd suggest running through the SDK function directory listing for SetTimer() and making sure all your parameters are correct. You might check that your Timers are sending WM_TIMER messages to separate functions in your application. I'm not sure about this, but if you don't specify different procedure-instance addresses for each timer, they will both send messages to the same procedure. If you didn't specify any proc-inst address, i.e., wTimer = SetTimer(hWnd, /*handle to parent window */ nIDEvent, wInterval, NULL) ; /* no special timer functions */ then both timers send to the application's message queue. In any event, both timers will send to the same destination, and unless wInterval is different for both timers, well, one WM_TIMER message looks like any other WM_TIMER message... so it might appear that only one timer is sending a message to your function. You'd have to provide a little more info about what you're trying to accomplish before I or anyone else could provide useful suggestions. --John Ano Department of Psychology, NI-25 University of Washington Seattle, WA 98195