Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overriding OnOk with CDialog

Status
Not open for further replies.

MinnisotaFreezing

Programmer
Jun 21, 2001
120
KR
I need some help and advice. I don't usually use the default CDialog::OnOk function, mostly because I don't know how to use it very well. So in the class I derived from CDialog, I overode it and didn't call the CDialog version, like so.
virtual void OnOK();

void BillTo::OnOK()
{
DoSomeStuff
.
EndDialog(5);

}

Then, I derived(derove?) a class from BillTo and in the declaration put
void OnOk();

void VendorBillTo::OnOK()
{
SomeStuff
.
EndDialog(5);
}

I then get the error message
error C2509: 'OnOK' : member function not declared in 'VendorBillTo'

To me, it is clearly declared in the class. I have run into this problem in the past, and simply renamed the OnOk function to OnSave, changed the button ID to != IDOK, and MessageMaped it myself, and everything works ok. But I kind of want to know why this isn't working. I don't want to use work arounds all the time.

So my second question is, do you all use CDialog::OnOk, or do you make your own exit function. I rarely use UpdateData, but it would be hand in some cases. Also, Return by default triggers OnOk, that would be nice not to have to hook that for every dlg box. Is it worth the hasle?

 
OK, I figured out my mistake, the CDialog function is OnOK, I was calling OnOk. I would still like to know if people use the CDialog::OnOK or if they usually make their own function.

Thanks,

CJB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top