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);
}
}
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);
}
}