开发者

width of the dropdown arrow

开发者 https://www.devze.com 2023-01-10 14:39 出处:网络
So in winforms, every dropdown combobox has this little arrow thingy to the right that tells the user it\'s a dropdown, kinda like this:

So in winforms, every dropdown combobox has this little arrow thingy to the right that tells the user it's a dropdown, kinda like this:

width of the dropdown arrow

Now how do I figure out how wide that is in pixels? Reason is, I'm using ControlDrawToBitmap, this doesn't draw the text properly for the combo boxes, and I can redraw the contents, I just whack some开发者_开发百科 of the arrows (which are drawn properly).


First idea that comes to mind: Check to see if the combobox button width tracks with the scrollbar width. The scrollbar width can be modified in user preferences. Use GetSystemMetrics() API to get the width of the various scrollbar pieces. If you change your system scrollbar width and it does not affect the size of a normal combobox, then ignore this.

Second idea: use the edit control's formatting rect to find out what the edit control thinks is the usable display area (minus the combo box). See EM_GETRECT in MSDN.

However, it sounds like this is just a hack workaround for your real problem: If you could get the controls to draw correctly to bitmap, then you wouldn't need this hackery.


I calculated it to be 9 pixels wide in photoshop

0

精彩评论

暂无评论...
验证码 换一张
取 消