15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Order of: OnActivateView, OnInitialUpdate

Jeff Wishnie -- jwishnie@swellsoft.com
Tuesday, February 20, 1996

Configuration: VisC++ 4.0, MFC 4.0, Win95, MSDN Jan '96, MDI application

I have written a CView subclass which performs some initialization in
OnInitialUpdate.
This initialization code _must_ take place _before_ OnActivateView.

Not a problem right? The calling order is:

When a view is created MFC calls OnInitialUpdate and _then_ calls OnActivateView

BUT when I put my view in a CSplitterWnd, the order is _reversed_

MFC calls OnActivateView _before_ OnInitialUpdate BLOWING up my code.

why, Why, WHY do they switch the order. I am going to _hate_ having to write
special handling code for the case where the view is in a SplitterWnd.

I may be able to move the initialization back into OnCreate, but thats
really too early...

Thanks for any illumination,

Jeff
jwishnie@swellsoft.com
415 552-3125(w)




Niels Ull Jacobsen -- nuj@kruger.dk
Thursday, February 22, 1996

> 
> Configuration: VisC++ 4.0, MFC 4.0, Win95, MSDN Jan '96, MDI application
> 
> I have written a CView subclass which performs some initialization in
> OnInitialUpdate.
> This initialization code _must_ take place _before_ OnActivateView.

Hmm - why? (If it can be explained simple?) The only thing
OnActivateView does is conditionally calling SetFocus().

> 
> Not a problem right? The calling order is:
> 
> When a view is created MFC calls OnInitialUpdate and _then_ calls OnActivateView
> 
> BUT when I put my view in a CSplitterWnd, the order is _reversed_
> 
> MFC calls OnActivateView _before_ OnInitialUpdate BLOWING up my code.
> 

Could you just add a m_bAfterInitialUpdate variable?  Then just ignore
any OnActivateView before OnInitialUpdate and call SetFocus() if your
OnInitialUpdate()?

> why, Why, WHY do they switch the order. I am going to _hate_ having to write
> special handling code for the case where the view is in a SplitterWnd.
> 
> I may be able to move the initialization back into OnCreate, but thats
> really too early...
> 
> Thanks for any illumination,
> 
> Jeff
> jwishnie@swellsoft.com
> 415 552-3125(w)
> 
> 
> 


--
Niels Ull Jacobsen, Kruger A/S

Everything stated herein is THE OFFICIAL POLICY of the entire Kruger
group and should be taken as legally binding in every respect. Pigs
will grow wings and fly.









| Вернуться в корень Архива |