您的位置:首页 > 编程语言 > C语言/C++

关于CDialog::DoModal

2015-07-12 23:00 453 查看

CDialog::DoModal

virtual int DoModal( );  虚函数

Return Value  返回值
An int value that specifies the value of the nResult parameter that was passed to the
CDialog::EndDialog member function, which is used to close the dialog box. The return value is –1 if the function could not create the dialog box, or
IDABORT if some other error occurred.

一个标识nResult的int值作为参数传递给CDialog::EndDialog成员函数,这个函数用来关闭一个对话框。如果函数不能创建一个对话框,则返回-1,否则,如果其他错误发生的话,将返回IDABORT值

Remarks   注释
Call this member function to invoke the modal dialog box and return the dialog-box result when done. This member function handles all interaction with the user while the dialog box is active. This is what makes the dialog box modal; that is, the user cannot
interact with other windows until the dialog box is closed.

调用这个函数去产生一个模态对话框,且当完成后会返回对话框的结果。当此对话框在激活状态时,这个成员函数会处理用户与对话框的交互。除非这个对话框被关闭了,要不然用户没法与其他对话框完成交互。

If the user clicks one of the pushbuttons in the dialog box, such as OK or Cancel, a message-handler member function, such as
OnOK or OnCancel, is called to attempt to close the dialog box. The default
OnOK member function will validate and update the dialog-box data and close the dialog box with result
IDOK, and the default OnCancel member function will close the dialog box with result
IDCANCEL without validating or updating the dialog-box data. You can override these message-handler functions to alter their behavior.

如果用户点击了对话框上的按钮,如Ok或Cancel,将会调用对应的消息句柄成员函数,如OnOk或OnCancel,将会被调用,然后关闭这个对话框。默认的OnOk成员函数将会更新对话框的数据然后返回结果IDOK,接着关闭对话框。而默认的OnCancel成员函数将会返回结果IDCANCEL后关闭对话框,并不使得有效或是更新对话框数据,你可以重载这两个函数去改变他们的行为。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  windows function c++ MFC