-
May 11th, 2007, 01:05 PM
#1
SetWindowPos in CDialog
I have a modeless CDialog and im using WM_SIZING and overriding OnSizing(UINT, LPRECT) and SetWindowPos to resize it.
On my dialog there are about 20 buttons, which are also resized, using SetWindowPos. The problem im having is that i need to keep a gap between all controls. The controls are lined in 5 rows,
with a gap between all controls( ie above, to the sides and below). If i resize the controls, they overlap each other therefore removing all gaps.
Basically, how can i position the buttons once resized, to avoid overlapping?
Any help appreciated!
code so far:
void CMyDlg::OnSizing(UINT nSide, LPRECT lpRect)
{
CDialog::OnSize(nSide, lpRect)
CRect rect(lpRect);
GetClientRect(lpRect);
//Loop through all controls on the dialog - id's are in consequetive order
for (int i = IDC_CONTROL1; i < IDC_CONTROL20; i++)
{
CWnd* aWnd = GetDlgItem(i);
aWnd->SetWindowPos(NULL,0,0,rect.Width()/10, rect.Height()/10, SWP_NOMOVE);
}
}
-
May 11th, 2007, 01:10 PM
#2
Re: SetWindowPos in CDialog
Have you thought about enforcing a minimum size for the dialog? One that would prevent the buttons from overlapping?
Gort...Klaatu, Barada Nikto!
-
May 13th, 2007, 01:56 PM
#3
Re: SetWindowPos in CDialog
How will this help? i simply need to maintain a gap around all controls
-
May 13th, 2007, 02:30 PM
#4
Re: SetWindowPos in CDialog
Originally Posted by Laurio
How will this help? i simply need to maintain a gap around all controls
You need to both resize AND reposition controls.
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
May 14th, 2007, 06:45 AM
#5
Re: SetWindowPos in CDialog
If i set a min size rect, how do i go about repositioning the controls then? this is what i need help with!
-
May 14th, 2007, 07:37 AM
#6
Re: SetWindowPos in CDialog
Originally Posted by Laurio
... code so far:[/CODE]
void CMyDlg::OnSizing(UINT nSide, LPRECT lpRect)
{
CDialog::OnSize(nSide, lpRect)
CRect rect(lpRect);
GetClientRect(lpRect);
}[CODE]
if it is your actual code then it is wrong!
You should not call [B]CDialog::OnSize from CMyDlg::OnSizing handler !
Now about your "resizing" problem. As Mike and Vladimir mentuioned you probably need to handle WM_GETMINMAXINFO message to set the minimal possible size of the dialog window to prevent the child control overlap.
A ggod start coulb be checking out some article about this problem in www.codeguru.com / www.codeproject.com, for example:
ResizableLib
http://www.codeproject.com/dialog/#Control+Positioning
EasySize - Dialog resizing in no time!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|