Click here to Skip to main content
15,889,724 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have one Parent dialog, two child dialog's, two buttons on parent dialog in my application and i want to show and hide the child dialog in appropriate size using those buttons

in coding 's' is object of one of the child dialog class...

What I have tried:

void CDialogControlDlg::OnBnClickedStudent()
{
	s.Create(IDD_STUDENT, this);
	SetRectangle(&s);
	s.ShowWindow(SW_SHOW);
}

void CDialogControlDlg::SetRectangle(CStudent* s)
{
	CRect tabRect, itemRect;
	int nX, nY, nXc, nYc;
 
	GetClientRect(&tabRect);
	m_lst.GetItemRect(0, &itemRect);
	 
	nX=itemRect.left;
	nY=itemRect.bottom+1;
	nXc=tabRect.right-itemRect.left-1;
	nYc=tabRect.bottom-nY-1;
	 
	s->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW);
}
Posted
Updated 13-Feb-17 16:59pm
Comments
Jochen Arndt 10-Feb-17 8:48am    
Assuming that s is a class member you should check if the dialog exists already and create it only if not. Otherwise you have multiple dead dialogs.
Premnath Mali 12-Feb-17 22:55pm    
after clicking button dialog is not showing in proper position it is showing at top left corner what i can do for that

is there any method to set location where ever we want
Jochen Arndt 13-Feb-17 3:14am    
You are setting nX to the left of the rectangle of a list control item which is usually zero. Use the debugger to check the values you are passing.
Premnath Mali 12-Feb-17 22:57pm    
can you provide the snippet code for setRectangle() and steps to do everything

1 solution

Where first parameter=left margin
second = top
third = width
fourth = height
CRect rect =CRect(150, 40, 831, 576);

m_CDialog1->MoveWindow(rect);
m_CDialog1->ShowWindow(SW_SHOW);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900