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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to edit OnOk()

Status
Not open for further replies.

nbgoku

Programmer
May 25, 2004
108
US
how do i edit the OnOK() function

i want to edit it so the program doesnt close when enter is pressed, ive tried searching about OnOK() but isnt it a built in function that cant be edited?
 
I have always just made a class for my dialog that inherits from CDialog. The CDialog::OnOK function can be overridden. Here is an example:

Code:
virtual void OnOK(); // declaration in header file

void MyDialog::OnOK()
{
	m_truckSpeed = GetDlgItemInt(IDC_EDIT_TRUCK);
	m_carSpeed = GetDlgItemInt(IDC_EDIT_CAR);
	CDialog::OnOK(); /* Now I call the real OnOK so I can gain its functionality as well */
}

I hope that can help, CDialog is MFC I believe :(

-Bones
 
If you overload the PreTranslateMessage and handle the enter key press, you can eat it before it gets to the OnOK command

Matt
 
damn BONES! VERY NICE!!! woot!!!

thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top