帮助覆盖OnOK [英] Help with overriding OnOK

查看:58
本文介绍了帮助覆盖OnOK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请有人可以帮助我。



我有一个对话框,其中包含一些必须加起来等于100的编辑控件。用户可以更改值编辑控件,但它们必须总是加起来为100.



我想知道如何覆盖OnOK,以便当用户点击ok时,如果总数为不等于100弹出一条消息并且对话框保持打开状态,这样用户可以更正值



或当用户点击OK按钮时,如果总数等于100对话框关闭。



如果总数不等于100,我已经弄清楚如何通过检查总数并弹出消息来覆盖OnOK消息弹出对话框关闭它不能做,而是必须保持打开,以便用户可以修复这些值。



谢谢

Please could someone assist me.

I have a dialog that has a few edit controls that must all add up to equal 100. The user can change the values of the edit controls but they must always add up to 100.

I would like to know how to overide OnOK so that when the user clicks ok, if the total does not equal 100 a message pops up and the dialog stays open so the user can correct the values

or when the user clicks the OK button, if the total does equal 100 the dialog closes.

I have figured out how to overide the OnOK by checking the total and popping up a message if the total doesn''t equal 100, but after the message pops up the dialog closes which it must not do, rather it must stay open so the user can fix the values.

Thanks

推荐答案

你好,



我自己整理了它,它按照我想要的方式工作。


代码如下:
Hi There,

I sorted it myself and it works as I want it to.

Code is as follow:
void CTestDlg::OnBnClickedOk()
{
    CString percentage;
    percentage.Format(L"Percentage total does not equal 100");

    if  ((inp_TestEdit) > 100)
        AfxMessageBox(percentage);

    else if ((inp_TestEdit) < 100)
        AfxMessageBox(percentage);

    else
        CDialog::OnOK();
}


这篇关于帮助覆盖OnOK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆