Re: Fun with CStatic destructor
- From: "Doug Harrison [MVP]" <dsh@xxxxxxxx>
- Date: Fri, 18 Aug 2006 10:23:55 -0500
On 18 Aug 2006 02:08:14 -0700, "Paul S. Ganney" <paul.ganney@xxxxxxxxxx>
wrote:
The odd code in OnOK() is because of the self-validating controls.
Basically, if you pressed Return, they didn't validate until after the
dialog had been dismissed, which meant they were examining the contents
of windows that weren't there. This piece of code allowed the controls
to validate before the dialog closed. I appreciate it looks clunky, but
it works.
The code in question was this:
void CInputDlg::OnOK()
{
if(GetFocus()!=&m_ok) // came here by pressing RETURN
{
m_ok.SetFocus(); // m_ok is the OK button
m_ok.PostMessage(WM_LBUTTONDOWN);
}
else CDialog::OnOK();
}
To be blunt, I don't see how this can be legitimate. The validation should
be accomplished like this:
void CInputDlg::OnOK()
{
ValidateControls();
CDialog::OnOK();
}
As to your actual problem, I don't have any new ideas. You might try #if
0'ing until you can't get it to fail, then add things back until it begins
to fail.
--
Doug Harrison
Visual C++ MVP
.
- Follow-Ups:
- Re: Fun with CStatic destructor
- From: Joseph M . Newcomer
- Re: Fun with CStatic destructor
- References:
- Re: Fun with CStatic destructor
- From: Paul S. Ganney
- Re: Fun with CStatic destructor
- Prev by Date: Re: edit control problem
- Next by Date: Re: new essay: Memory Damage
- Previous by thread: Re: Fun with CStatic destructor
- Next by thread: Re: Fun with CStatic destructor
- Index(es):