// JP opened flex table

Click to See Complete Forum and Search --> : How do I simply return handle of a dialog box?


Electroskill
February 18th, 2007, 03:15 PM
This is probably a simple question for most of you. On MSDN, GetDlgItem is defined as:
HWND GetDlgItem(

HWND hDlg,
int nIDDlgItem
hDlg
[in] Handle to the dialog box that contains the control.
nIDDlgItem
[in] Specifies the identifier of the control to be retrieved.

My question is: how do I get the handle to my child dialog box? What function do I use?

Thanks,

Electroskill

ovidiucucu
February 18th, 2007, 04:03 PM
[ Redirected thread ]

You have N ways to return the handle of a child dialog box.
If you have created that child dialog by a call of CreateDialog its handle is returned by that function, also you can call GetWindow, also EnumChildWindows, also FindWindowEx, aso so on, and so on...

Electroskill
February 18th, 2007, 05:27 PM
Well, I created my child window like this:

m_extended_inds.Create(IDD_EXTENDED_INDS,this);
m_extended_inds.ShowWindow(SW_SHOWNORMAL);

So, if I understand what you're recomending, I can call something like this from within my modeless dialog box to get the handle?

CWnd* mWnd =GetWindow(GW_CHILD);


Thanks,

Electroskill

ovidiucucu
February 18th, 2007, 05:54 PM
Well, I created my child window like this:

m_extended_inds.Create(IDD_EXTENDED_INDS,this);
m_extended_inds.ShowWindow(SW_SHOWNORMAL);

So, if I understand what you're recomending, I can call something like this from within my modeless dialog box to get the handle?

CWnd* mWnd =GetWindow(GW_CHILD);
Not quite.
From your OP, I have understood that you do not use MFC, but plain WinAPI.
Well, because from this snippet code m_extended_inds seems to be an object derived from CDialog (which is derived from CWnd), you can simply get its handle from its m_hWnd public member.
HWND hWndChild = m_extended_inds.m_hWnd

NOTE: GetWindow(GW_CHILD) returns a pointer to first child, but they can be more... ;)

Electroskill
February 18th, 2007, 07:42 PM
ovidiucucu,

Thanks. I understand now and it works well.

Electroskill

//JP added flex table