Click here to Skip to main content
15,847,077 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to change the position and size of static element in dialog based Mfc?

I have a CStatic box by drag and drop now I want to change the position and size of that element in the code. How can I do this?
C++
CStatic *pWnd= (CStatic *)GetDlgItem(IDC_STATIC_PICTURE); //Id of CStatic Control
	pWnd->GetClientRect(rcRect);
	pWnd->ClientToScreen(rcRect);

I got rcRect but how to set the new rect value what is the function used to set new rect values.
Posted
Updated 28-Jul-23 0:34am
v4

I guess GetClientRect and MoveWindow Will help you on that.
Look at this link. [^]
 
Share this answer
 
Comments
chaiein 4-May-12 5:14am    
no move window making it disappear
Chandrasekharan P 4-May-12 5:19am    
Did you try setWindowPos function?
chaiein 4-May-12 5:38am    
Thank u for suggesting this solution:) but its showing how to drag and drop dynamically but I need to show the position using CRect(value1,value2,value3,value4));
chaiein 4-May-12 5:42am    
I need to use CRect because I have png of different size so if i change the element size so i can adjust the picture
chaiein 4-May-12 6:15am    
please check my updated question.
CRect rc;
CWnd *wnd = GetDlgItem(IDYES);
wnd->GetWindowRect(&rc);
ScreenToClient(rc);
wnd->SetWindowPos(NULL, rc.left, rc.top+10, rc.Width(), rc.Height(), SWP_SHOWWINDOW);
 
Share this answer
 

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