Reputation: 1691
I have a CFormView that is dynamically created at runtime. However, something really weird is going on, because OnInitialUpdate never gets called for that view. I set a breakpoint in the function and it never gets hit once, even though I can see the view being displayed onscreen. This is a problem because whenever I try to work with the view's member controls, the program crashes because they aren't initialized. What gives?
Upvotes: 2
Views: 2538
Reputation: 500
I'm currently working round this issue by using CFormView::OnActivateView() instead, then testing/setting a member variable flag (m_bInitialised) so that I can ensure the code I wanted in CFormView::OnInitialUpdate() only gets run the first time.
Seems slightly more self-contained than manually calling OnInitialUpdate() from outside, but at best only slightly less icky :-/
Upvotes: 1
Reputation: 1691
EDIT: You can just call OnInitialUpdate manually; you don't necessarily need to override it.
I think I might be a victim of this bug. My workaround was to override OnInitialUpdate()
and call it manually, immediately after my view is dynamically created. This only worked if the very first line in the overridden function was a call to the parent CFormView::OnInitialUpdate()
.
Upvotes: 0