简体   繁体   中英

Need help understanding SetTextMargin for MFC CButton?

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM