at will ... for X screens of Y buttons. . . .
buttons -- fast and easy. If I get the pointer to all my buttons (not
they are not -- my mistake.
Thanks for your help.
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
The problem is that you think using GetDlgItem is a reasonable approach.
Don't use it; if
you are writing more than one a year, you are not using MFC correctly.
Note that if you are creating a new class, you almost certainly do NOT
want to include the
same files as your dialog. In fact, due to terminal brain damage and a
failure to
comprehend how software should really be built, Microsoft erroneously
does
#include "project.h"
where "project" represents the name of your project, in each derived
class. This has
never made sense, and I either delete the line entirely, or replace it
with
#include "resource.h"
The correct approach is to create a control variable for each control you
wish to access,
and use the control by name.
You should not be writing it at all, and in any case, if you are in a
derived class of a
control, it is erroneous to assume that it knows anything about any other
control in the
dialog. So you would not need the HWND in any case.
Stop using GetDlgItem.
Neither question makes sense
(a) you don't need GetDlgItem
(b) you don't need the handle to your dialog to access a control
Note that in the very, very, VERY rare cases where you need an HWND, the
m_hWnd member of
the window class is the handle. I see no evidence in your description
that you have such
a case.
Note that if you have some random class *not* derived from CWnd, then it
has no business
touching the controls of the dialog; this violates so many principles of
good OO
programming that it is not worthy of discussion of how to do it. It
would be like
explaining why a 'goto' is the ONLY reasonable control structure to use
for looping. You
need to rethink and redesign what you are doing so that some random class
does not require
access to your dialog's controls.
joe
On Mon, 6 Apr 2009 22:52:36 -0500, "Kevin Waite"
<kevin001.waite@gmail.com> wrote:
Newbie here -- in my default wizard MFC Dlg.cpp -- I can use
GetDlgItem with a single parm, say the ID of a button -- and it
works great -- in fact both decls are present -- the single parm
ID and the ( HWND hdle, ID ) ......
When I make a new class module -- xxx.cpp --- and include
exactly the same includes from Dlg.cpp -- exactly the same!
I don't get the single parm GetDlgItem( ID ) -- booo -- I only
get the 2 parm (HWND, ID) ver . . . . rats rats rats
Worse yet -- I really can't seem to figure out how to get my
HWND hndle on the fly to meet this two parm version. . . .
so I am stuck again . . . . .
So -- either solution would be great --
a) how to get the single parm version of GetDlgItem vialbe from xxx.cpp
b) or how to querry the Dialog Handle in the form of HWND
Either would be fantastic . . . . .
Thanks in advance.
Sincerely,
Kevin Waite
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm