I have a CPropertySheet class with 3 tabs.
I have put in the workaround below to make it modeless.
Howver when I press Alt+Tab to change application it crashes.
Has anyone seen anything similiar?
Why did you have to do that? Call Create member instead.
If your property sheet is a child of another window you problem most likely due to infinite loop that property sheet is entering trying to restore focus, not a crush.
If that is a case it can be fixed by specifying extended style: WS_EX_CONTROLPARENT passed in Create function.
There are only 10 types of people in the world: Those who understand binary and those who do not.
I don't think you're supposed to call OnInitDialog () implicitly.
NMTop40 calls CPropertySheet implementation of OnInitDialog and this call is essential. This holds true also for property pages and dialogs. Base class implementation make necessary calls to initialize all created controls and calls UpdateData to transfer data and subclass controls by invoking DDX.
Originally Posted by NMTop40
It gets called from a DoModal call. (Would be best if the method were private).
I do not agree.
Firstly, OnInitDialog is not called from DoModal but from WM_INITDIALOG message handler. WMINITDIALOG message is send to a dialog by the system as a result of any API call that creates modal or non modal dialog, after dialog and controls are created.
DoModal is sole MFC implementation of creating modal dialog box that is not really modal. WM_INITDIALOG is a system generated message.
Secondly, OnInitDialog virtual override gives derived class chance to initialize own data and controls. Making virtual function as private defeats its purpose.
As you can see encapsulating everything is not always the best idea.
Nevertheless the way NMTop40 created modeless property sheet remains a mystery.
There are only 10 types of people in the world: Those who understand binary and those who do not.
Why would you want to?
You are creating modeless property sheet by calling Create instead of DoModal.
The code is for inserting default buttons that modeless property sheet does not have by fooling property sheet into thinking it creates modal.
Do you really need buttons in non modal propery sheet?
I am pretty sure your problem is elsewhere and if you read my previous post and apply extended style change, your problem most likely will go away. Did you try it?
If after that you still have problem post your entire project here.
There are only 10 types of people in the world: Those who understand binary and those who do not.
I am afraid that I have exhausted my ability to guide you and without actually debugging your code I will not be able to assist you further.
Are you running debug build? You should see similar message and button, allowing for debugging. After that you can step into a code, follow stack to the point in your code that causes this problem.
Another way is to post your entire project here to allow debugging.
Before you do, try to find any un-initialized or NULL pointer that usually is a culprit.
Write test application as bare as possible using property sheet in the same manner and see if you can reproduce error.
There are only 10 types of people in the world: Those who understand binary and those who do not.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.