Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i'm working on a dialog with a bitmap background. i've implemented the background bitmap by a CStatic ctrl with SS_BITMAP style set. this causes the ctrl to be stretched to the bitmap dimensions so that the bitmap can be shown as the dialog background. but i need to resize the dialog dimensions too, so that it also fits the bitmap dimensions. if i do this by SetWindowPos, the resulting client size is less than the bitmap size, because the dialog contains caption and border. i don't want to add a fixed size to this value. because based on the appearance of the Windows the dialog appears on, the size of caption and border may differ.
what's the best method for changing the size of the dialog so that the bitmap can fit inside it?
thx
Posted
Comments
What is the number 911224 - in the title of Question ?
ilostmyid2 14-Mar-13 4:46am    
it's just for me to know when i've posted the question. because i'm not familiar with gregorian date, i use our own calendar. today is 1391/12/24.

1 solution

The difference in size between the client area of the dialog and the outer dimensions is generally referred to as the "trim". One relatively easy way of determining the trim is to call GetClientRect and GetWindowRect. The latter delivers the outer size of the dialog window. Subbtract the client size and you have the trim.

In order to enlarge your dialog in way that your CStatic will fit inside, you have to add the trim to the size of the static control.

Another method to calculate the trim is the MFC function CaclWindowRect, which basically does the same as described above.

Hope that gets you going.
 
Share this answer
 
Comments
ilostmyid2 14-Mar-13 5:19am    
thanx 4 the solution :)
i couldn't communicate with the second paragraph. how that i've to add the trim to the size of the static ctrl?!
nv3 14-Mar-13 5:46am    
The size of your CStatic should fit into the client area of the dialog. Hence the outer bounds of your dialog must be larger to include the trim, i.e. the borders and title bar.
ilostmyid2 14-Mar-13 5:57am    
yes, but for this trim must be added to the dialog size not to the CStatic size.
nv3 14-Mar-13 6:07am    
Of course.

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