Need help understanding SetTextMargin for MFC CButton?

401 Views Asked by At

I need some guidance on understanding how SetTextMargin works for CButton. What I am trying to do is have a CButton which has BS_LEFT style and using SetIcon setting an icon on the button which will appear on the left. Now the text needs to be set with some margin so that it doesn't stick too close to the icon. I have some calculations on what the margin should be. Now the CButton::SetTextMargin takes in a CRect parameter and I need help understanding what my rect.right and rect.left should be. I have tried all sorts of tests but I am not able to get how the margin rectangle gets incorporated. My calculations of the margin and the actual margin is way off. Any help would be appreciated. Thanks!

1

There are 1 best solutions below

0
On

Just answering this part of the question:

Now the CButton::SetTextMargin takes in a CRect parameter and I need help understanding what my rect.right and rect.left should be.

The CRect represents how large you want the margins to be. Setting rect.right = 0 will give you no margin on the right.