Re: Basic question regarding checkboxes
- From: "Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp>
- Date: Mon, 14 Jan 2008 17:34:32 -0500
<stewb85@xxxxxxxxx> wrote in message news:25882ada-6759-4716-99e8-8de7cfb54c79@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Are you using MFC or the straight Win32 APIs? This is an MFC newsgroup.
I'll be honest with you. I don't actually know. I assume MFC, but as
I say, I've not done Windows before, and this Checkbox control is the
only thing I actually need to do. But its wasting valuable time I
could be spending on the actual algorithm I'm writing.
In the actual Dialog code, if I do
CheckDlgButton(IDC_CHECK1,BE_CHECKED) it works, but unfortunately this
isnt of much practical use to me.
How do I get the HWND that was returned when the dialog was created?
This is a program that has been passed to me, and unfortunately, the
person who gave it me isn't around to ask them.
I appreciate that this is basic, and all your help is very much
appreciated.
The fact that it works in the actual dialog code is a pretty good hint that you are using MFC. It appears that your real problem is not understanding that the above call is to a C++ member function. Your error message shows you are not calling the MFC version of CheckDlgButton but attempting to call the API version. The MFC version is a member function of the dialog and it "knows" the HWND of the dialog.
The solution is to call it this way:
pDialog->CheckDlgButton(IDC_CHECK1,BE_CHECKED);
No HWND required, but you have to have a pointer to the dialog object like pDialog. If you are making this call in some code module that is not part of the dialog then first you have to call that module, passing it the 'this' pointer from the dialog object. Your module would save this pointer for later use so it can call dialog functions. Do you understand this C++ idiom?
--
Scott McPhillips [VC++ MVP]
.
- Follow-Ups:
- Re: Basic question regarding checkboxes
- From: stewb85
- Re: Basic question regarding checkboxes
- References:
- Basic question regarding checkboxes
- From: stewb85
- Re: Basic question regarding checkboxes
- From: Scott McPhillips [MVP]
- Re: Basic question regarding checkboxes
- From: stewb85
- Basic question regarding checkboxes
- Prev by Date: Re: attaching child ClistCtrl window to resizable parent Dialog
- Next by Date: Re: Basic question regarding checkboxes
- Previous by thread: Re: Basic question regarding checkboxes
- Next by thread: Re: Basic question regarding checkboxes
- Index(es):