Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to resize controls in a dialog box?

Status
Not open for further replies.

nexius

Programmer
Jul 8, 2000
109
CA
Hi

I'm trying to move my controls around (ie. buttons, textboxes, etc) whenever the user resizes the window. Sounds simple enough, but it's just not working...

What I'm doing is getting the button window pointer and trying to change its rect through MoveWindow(...) but it crashes _every_ time and I have no idea why.

CWnd* button = GetDlgItem(ID_OK);
button ->MoveWindow(0, 0, 100, 100, false);

Any ideas? Thanks!
 
try CWnd* pButton = (CWnd*)GetDlgItem(ID_OK);
pButton->....

else look in the debuger, is pButton holding a valid value ? (you may not need the cast, I can't remember what GetDlgItem returns off the top of my head)

Ask if youve more questions !
 
hmmm Yes pButton doesn't seem to be a valid pointer.

I figured it was executing OnSize(..) before it created all the controls in the window so I added a boolean, initially false, that I set as true once InitDialog was completed.

This seems to work... but if anyone has a better way, let me know!

Bye now.
 
I'd suggest theat maybe CWnd is not the appropriate type for a Button, but I'd need to check my docs, gald you figured it out anyway,

K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top