Precise alignment of text with toolbar button
Posted on 2013-11-25
First: I hope this is the right forum for this question, I couldn't find any "MFC" forum?
I am struggling to align a static text directly under a toolbar button in an MFC dialog. But I can't get it totally precise, it seems to be offset to the left by a small amount.
// I start finding the existing window of the text to be moved. It should keep it's vertical //placement.
// Then I find the window of the button
int nIndex = m_wndToolBar.GetToolBarCtrl().CommandToIndex(buttonId);
// I change the left/right values of the window of the text
rcText.left = rcButton.left;
rcText.right = rcButton.right;
but the text ends up a little too far to the left. I expect GetItemRect is returning it's coordinates relative to some client window upperleft corner inside the toolbar. But how do I find those values? Calling GetClientRect on the toolbar has both left and top 0.
Thanks for any help!