Dealing with the everlasting MDI bug
The "MDI bug" is one of those Clarion-related issues that's been around for a long time, but which is somewhat lacking in hard documentation. The usual manifestation is multiple minimize, restore and close buttons on the MDI child window.
You've probably heard the story of how SoftVelocity spent a lot of time tracking down the bug, finally sending some sample code to Microsoft. And Microsoft verified the problem, said it would not be fixed, and changed the documentation,.
I was reminded of this by a post Gustavo Pinsard made in the sv.clarion.clarion8 newsgroup. In response, Diego Borogovitch said:
The problem is not with MDI but with threaded MDI. MS does not support windows to be open in multi threaded MDI because the part of code in the OS that manage the MDI is not thread safe.
Lee White pointed out that problem manifests itself when you maximize child windows, and several other devs agreed that as long as you get rid of the maximize option you should be good to go. Resizing windows is fine.
Gustavo noted that removing the MDI Tab feature seems to have fixed his issue.
So, what's the moral of this story? The MDI bug is there and most likely will be around for as long as MDI is around. Just don't let your users maximize MDI child windows.
On this link http://msdn.microsoft.com/en-us/library/windows/desktop/ms644908%28v=vs.85%29.aspx#child_creation MS state "A more efficient way to create an MDI child window is to call the CreateWindowEx function, specifying the WS_EX_MDICHILD extended style."
When I looked back at this problem some months ago, the Clarion 8 RTL was calling CreateMDIWindowA and not CreateWindowEx, but lets look at the parameters that are sent to the CreateMDIWindowA api. http://msdn.microsoft.com/en-us/library/windows/desktop/ms644923%28v=vs.85%29.aspx
Below is the API call and parameters which are called by the VS2005 example app sent to MS, its almost identical to the CW RTL.
CreateMDIWindowA ( 49573, "Test Child 00392620", 1187971072, -2147483648, -2147483648, 400, 400, 0x001a012e, 0x00400000, 3745312 )
Having seen the parameters and looking at what MS have to say, these questions come to mind.
The X & Y parameters contain the value -2147438648, which would put the window off the screen, why cant the run time get the window position before it creates the window? Is this the same value that appears in ini files when a window displays off screen? If anyone does experience the ini-file-window-not-visible problem it will be interesting to see if its the same number.
The nWidth & nHeight are set to 400, again why cant the runtime lookup the window size & position from the ini file or reg setting before opening the window, and where necessary setting the window to the maximised state (dwStyle = WS_MAXIMIZE) as well.
It would be interesting to see if the recommended API gets rid of the MDI bug problem. I also wonder about the order some of the other api's are called as well.