TransferData(tdSetData) is called at the end of TWindow::SetupWindow. This is unfortunate because SetupWindow is commonly overridden. The usual idiom is to call TWindow::SetupWindow first and then add custom setup:
:::C++
void TMyDialog::SetupWindow()
{
TDialog::SetupWindow(); // TransferData happens here!
CustomSetup(); // Setup too late for data transfer!
}
For this reason, I suggest moving the TransferData call out of SetupWindow and put it just after the SetupWindow calls in the window initialization sequence. The enclosed patch implements this solution.
Discussion: Upgrading from OWL: MDIClients in multiple DLL's
Wiki: OWL_Compatibility_modes
Wiki: Upgrading_from_OWL
Unidiff applicable to 6.31.5
Jogy, I just looked at your implementation you checked into SVN today. You have inserted the TransferData call in the wrong place in "propsht.cpp"; you have put it in TPropertySheet::SetupWindow. That will cause the same problem as described in my bug report. If a derivative of TPropertySheet overrides TSetupWindow then TransferData will be called within the setup sequence.
My patch had it right. The call to TransferData must be placed after the SetupWindow call in TPropertySheet::InitHandle.
Edit: Jogy's implementation was committed in [r386]. My correction for TPropertySheet was implemented in [r388].
Related
Commit: [r386]
Commit: [r388]
Last edit: Vidar Hasfjord 2020-01-06
One idea to enforce the proper calling sequence of setup and transfer in one place is to create a new protected function, say
and have TWindow, TDialog and TPropertySheet, i.e. the classes that performs the window initialisation sequence explicitly, call PerformSetupAndTransfer instead of the two functions separately.
It should be non-virtual so that the code using it can rely on its implementation (contract programming).
User classes that perform their own custom initialisation sequence, and assume TransferData is called as part of SetupWindow, will sadly break with this patch. The adviced fix for such classes would be to adapt the code to the corrected initialisation sequence. But presumably those user classes are few and far between. I assume most user classes rely on the initialisation sequence implemented in TWindow, TDialog or TPropertySheet.
Edit: This improvement was implemented in [r391].
Related
Commit: [r391]
Last edit: Vidar Hasfjord 2020-01-06