Handle to Static Text / Group Box

I have a Static Text control in my Form View based SDI application. I need to dynamically resize the Static Text control's border on resizing the main frame (Window).

I attempt to obtain a pointer to the Static Text control using the conventional way -

CWnd *ptr = (CWnd*)GetDlgItem(IDC_STATIC);

But, ptr is always found to be NULL.

Doing the same on a button control in the same Form View gave me a valid pointer.

Is it not possible to obtain a handle to Static Text / Group Box frames in a dialog for the purpose of resizing ?

Can someone give me some hints ?
[621 byte] By [humble_learner] at [2007-11-19 22:58:48]
# 1 Re: Handle to Static Text / Group Box
Rename the control to something other than IDC_STATIC.
GCDEF at 2007-11-10 23:32:35 >
# 2 Re: Handle to Static Text / Group Box
and simply move them as follows:

GetDlgItem(IDC_STAT1)->MoveWindow(x,y,dx,dy);
GetDlgItem(IDC_STAT2)->MoveWindow(x,y,dx,dy);

etc
jim enright at 2007-11-10 23:33:41 >
# 3 Re: Handle to Static Text / Group Box
Thanks. Basically I needed a frame around a button which maximizes and minimizes as the button size increases and decreases. The Static Text Control actually overwrites the button and the button cannot be seen on running the application.
The other solution is to use a Group Box but then GetDlgItem() returns a NULL pointer in case of a Group Box (even after changing IDC_STATIC to something else.)

Is there any other option ?
humble_learner at 2007-11-10 23:34:40 >
# 4 Re: Handle to Static Text / Group Box
Open "resource.h" and make sure that IDC_YOURCONTROL has an ID other than -1.
philkr at 2007-11-10 23:35:34 >
# 5 Re: Handle to Static Text / Group Box
Thanks for the answer Phil
humble_learner at 2007-11-10 23:36:38 >