I just read in a book that OnOk() and OnCancel() functions are member functions of the CDialog class ,from which my class derives.When someone presses Esc Or Enter it automatically calls one of this functions.I will try to solve this.But help is also needed.