Updating multiple views in MFC

Hi,

I’m writing a program in MFC with OpenGL and i have many views. when i press a key in one of the view it changes my model and all the other views are updated. the problem is there is a huge time difference between when the view with the focus updates and when all the other views update. does anyone know of a way i can synchronize this?

so say i hold the ‘q’ key down repeatedly; I want all the views to have updated before it processes the next WM_KEYDOWN message or something like that.

all i do at the moment is call UpdateAllViews in the OnKeyDown message handler.

thanks,
kev.

how many views you have?
most of the time there is a huge performance slowdown, because of the call of wglMakeCurrent() - you may profile your application, to see if this is the reason

[This message has been edited by martin_marinov (edited 01-29-2001).]

it lags with only 2 views but i want to have up to 4 running in MDI child windows.

the views are all instances of the same view Class. i’m not sure about the wglMakeCurrent. do you have any idea how to speed it up? someone must of done something similar.

regards,
kev.

How do you actually refresh your views ???

I suppose you get the WM_KEYDOWN message in one of the views. Then, I suppose you send a message to all the others to tell them to redraw themselves, right ?

What your problem might be is that you probably use PostMessage instead of SendMessage to tell the windows to be redrawn…

I do not use the messaging system at all (at least not directly !) for redrawing my views: when something happens in a view that should make all the others to be redrawn, I use GetDocument() and call a member function of my document class called RenderAllViews().

This function uses GetFirstViewPosition() and GetNextView() to retrieve pointers to all the views attached to the document and calls directly their Render() member…

I suppose the SendMessage stuff should work as well…

Best regards.

Eric

P.S.: for those who are wondering, PostMessage puts a message in the message queue (i.e. it will processed later on) while SendMessage sends the message directly to the window (i.e. it is processed immediately).

[This message has been edited by Eric (edited 01-29-2001).]

Ah yes. That seems to do the trick.

I was using UpdateAllViews(NULL) which just sent a WM_PAINT message to all the views. i guess this must have been posted?

anyway, i did what you sugested and now i have it calling a specific drawing method on each view in turn bypassing the need for an invalidation and a subsequesnt WP_PAINT message.

works a treat.
thanks,
kev