TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: NEIL HELLER
from: THOMAS MAEDER
date: 1997-10-24 19:16:00
subject: C++ Inheritance

NH> void CComUI::OnCancel()
NH> {
NH>     CWnd * pbutton = GetDlgItem(IDCANCEL);
NH>     pbutton->EnableWindow(FALSE);
NH>            .
NH>            .
NH>            .
NH>     CDialog::OnCancel();
NH> }
NH> Does the line containing the call to the parent "percolate" up to th
Never  heard  the  word  "percolate". "CDialog::OnCancel();" calls the
OnCancel method as implemented in or inherited by class CDialog. It is
very  common  for  overriding  virtual  methods  to call the overriden
method of the base class.
NH> child?  What is the purpose of this call in the first place if
If the method CComUI::OnCancel() is  meant  to  add  behavior  to  the
standard behavior of the dialog when the Cancel button is pressed, the
most common way to do it is to first do your stuff and then invoke the
inherited behavior, exactly as in the code snippet above.
NH> CDialog::OnCancel() had never been specifically fleshed out (or even
NH> mentioned) anywhere in the code?
If  there weren't an implementation of CDialog:OnCancel(), you'd get a
linker error.
NH> As an aside, I commented this line out and the software ran as
NH> expected.  With that line left in the code there was always a premat
NH> closing of the dialog box.  Does this mean that the method,
NH> CDialog::OnCancel(), was performing some action on its own without m
NH> even being aware of it?
Yes. The standard behavior of a  dialog  when  the  Cancel  button  is
pressed  is  to close itself. That's what happens when you invoke this
standard behavior with "CDialog::OnCancel();".
If you don't want the dialog to close when Cancel  is  pressed,  don't
call  "CDialog::OnCancel();".  But  since  the Cancel button's purpose
generally is to close the dialog, you  had  better  look  for  another
solution to your task.
Thomas
---
 þ MM 1.0 #0113 þ Worship my merciful god, or I'll kill you.
---------------
* Origin: McMeier & Son BBS (2:301/138)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.