If you find yourself working with MFC property sheets and run into a first-chance exception inside the ::OnInitDialog method, check that all your dialogs resources have the right windows styles.
If you are using dialog resources , check that the dialog resources have the following properties:
Border: Thin
Disabled: True
Style: Child
In my case, one of the dialog resource had the 'Border' property set to 'Dialog Frame' and 'Sytle' to 'Pop up'
In my case, one of the dialog resource had the 'Border' property set to 'Dialog Frame' and 'Sytle' to 'Pop up'
According to MSDN documentation , for the CPropertySheet::DoModal() method, all the windows styles should be disabled with the exception of :
DS_3DLOOK
|
Obsolete. The system automatically applies the three-dimensional look to dialog boxes created by applications.
|
DS_CONTROL
|
Creates a dialog box that works well as a child window of another dialog box, much like a page in a property sheet. This style allows the user to tab among the control windows of a child dialog box, use its accelerator keys, and so on.
|
WS_CHILD
0x40000000L
|
The window is a child window. A window with this style cannot have a menu bar. This style cannot be used with the WS_POPUP style.
|
WS_TABSTOP
0x00010000L
|
The window is a control that can receive the keyboard focus when the user presses the TAB key. Pressing the TAB key changes the keyboard focus to the next control with the WS_TABSTOP style.
You can turn this style on and off to change dialog box navigation. To change this style after a window has been created, use the SetWindowLong function. For user-created windows and modeless dialogs to work with tab stops, alter the message loop to call the IsDialogMessage function.
|
DS_SHELLFONT
|
Indicates that the dialog box should use the system font. The typeface member of the extended dialog box template must be set to MS Shell Dlg. Otherwise, this style has no effect. It is also recommended that you use the DIALOGEX Resource, rather than theDIALOG Resource. For more information, see Dialog Box Fonts.
The system selects a font using the font data specified in the pointsize, weight, and italicmembers. The system passes a handle to the font to the dialog box and to each control by sending them the WM_SETFONT message. For descriptions of the format of this font data, see DLGTEMPLATEEX.
If neither DS_SHELLFONT nor DS_SETFONT is specified, the extended dialog box template does not include the font data.
|
DS_LOCALEDIT
|
Applies to 16-bit applications only. This style directs edit controls in the dialog box to allocate memory from the application's data segment. Otherwise, edit controls allocate storage from a global memory object
|
WS_CLIPCHILDREN
0x02000000L
|
Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window.
|
If you dialog resources are Kosha and you still get a First-change exception is very likely you are experience an exception that is expected (by design) when calling CPropertySheet::DoModal() or CPropertySheet::Create()
You can find out more about this expected exception 'that is safely handled by the operating system' following this link.
On that Microsoft page you will find three methods for resolving the issue.
Until next time, see ya.
No comments:
Post a Comment