Cdialog: oninitdialog () and "attempting to perform operations not supported by the system"

Source: Internet
Author: User

Bool cmapfiledlg: oninitdialog ()
{
Cdialog: oninitdialog ();

.......

}

 

Function: it is the processing function that responds to the wm_initdialog message.
Declaration: oninitdialog () Description:
Here we mainly describe the similarities and differences between a constructor and a constructor.
Similarities:
Can be initialized.
Differences:
Initdialog is a function to respond to the wm_initdialog message. constructor is a function called when you talk to an object instance. Here, constructor is called earlier than initdialog.
Constructor: the dialog box does not exist. Using hwnd or something will not work.
Initdialog: the dialog box already exists. If you need to allocate a large amount of memory at the beginning, it is more appropriate to put it in oninitdialog.
Control initialization should be placed in oninitdialog
The initialization of common member variables can be placed in the constructor.
But what is the difference between return true and return false?
On msdn:
Return Value
Specifies whether the application has set the input focus to one of the controls in the dialog box. if oninitdialog returns nonzero, Windows sets the input focus to the first control in the dialog box. the application can return 0 only if it has explicitly set the input focus to one of the controls in the dialog box.
As for the Application Scenario: assume that the input content is required on the dialog. If the dialog is displayed, the input focus is automatically placed on the first edit box. You can directly enter the content. At this time, oninitdialog () needs to return true.
In my personal summary, when true is returned, it indicates that Windows automatically places the input focus on an empty part at the top of the sequence; when false is returned, it only indicates that you manually change the input focus to another control.

 

 

Problem: cdialog: oninitdialog () An error is displayed, "trying to execute operations not supported by the system".

 

80% of the reason is that you have used a resource, such as an edit, and you have created a member in the class, such as cedit m_edittest; but now you have deleted this edit, m_edittest is not deleted. You only need to find this definition in classwizard and delete it.

 

Although blocking cdialog: oninitdialog () can allow the program to compile, it may cause a series of bugs.

For example:

1.

(Ctabctrl *) getdlgitem (idc_tab1)-> insertitem (0, "WMS local ");

// CTL. insertitem (0, "WMS local"); // After blocking, the label is incorrectly added and must be used as shown above
(Ctabctrl *) getdlgitem (idc_tab1)-> insertitem (1, "WFS online ");

 

2. Switch tabctrl Control

 

If (maid () = 0)
{
Wms_page.showwindow (sw_show );
Wfs_page.showwindow (sw_hide );
}
Else if (maid () = 1)
{
Wfs_page.showwindow (sw_show );
Wms_page.showwindow (sw_hide );
}
// Blocking will cause an error during tag switching

 

Cdialog: After oninitdialog () is initialized, some defined control variables (that is, the object name such as: ALB) are available. Otherwise, it must be as follows:

 

(Ctabctrl *) getdlgitem (idc_tab1)-> insertitem (0, "WMS local"); // (ctabctrl *) is used to tell the getitem () that the control calls (). You can use the relevant functions (such as insertitem () only after returning the handle of the control ())

Afxgetmainwnd ()-> m_hwnd, afxgetmainwnd () is used to obtain the main window that is dependent on the thread. In the callback function, the desired Main Window cannot be obtained.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.