What does the hWnd value in the VC Modal Dialog Box mean when it is null?

Source: Internet
Author: User

The modal dialog box is used when I write a login box today. It is similar to QQ login. I used to think that if the user name or password entered by the user is wrong, I will send an error message to MessageBox, tell it that the input is incorrect. Now it's annoying to think about it. It's better to get a static box and write a red word on it to prompt. So I followed this idea. In the two edit boxes, the corresponding CEdit variables are m_teacherno_ctrl and m_teachaerpassword_ctrl. They are dumbfounded and run

Logindlg. m_teacherno_ctrl.GetWindowText (teacherno );
Logindlg. m_teacherpassword_ctrl.GetWindowText (password)

An error occurs.

Logindlg is a dialog box object, which corresponds to the modal dialog box resource.

After debugging and running, I found that this dialog box and the hWnd variable corresponding to all the preceding controls are empty. I am dizzy. This means that the GetDlgItem (), GetWindowText, functions such as SetWindowText cannot be used.

Why? Now I have no time to investigate and implement more important functions. Modal dialogs are intended to do some simple work, and there may be no need to store those values. The functions I want to implement can be fully implemented using non-modal dialogs.

 

In addition, how can we retrieve the values of the two edit boxes in the modal dialog box? We can bind them with CString variables. After OnOK (), we can get the values entered in the edit box.

 

Now we know why. To generate a modal dialog box, let's write:

CDiaolg mydlg;

If (mydlg. DoModal () = IDOK)

{

..............

}

The condition that if is true is that onok () is called, that is, the default OK button is clicked. Think about it, then the dialog box is closed! Although the mydlg class may still exist, the m_hwnd value is empty. This may be because the framework has done some work for us, it also shows the connection and difference between the window class and the window, and the window is no longer used. It is reasonable to release the window resource handle.

If you want to do something when you click the OK button, you can go to the member function of mydlg, instead of at the position of "..." above.

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.