I'm sure this problem has a simple solution: How do I find the pixel width of a given displayed string using a given font on a given device?
I know there must be some simple solution as some Window controls even have built in functions to do exactly this (i.e. ListViews have ListView_GetStringWidth, which is close to what I need, but instead I need one for use with a ComboBoxEx).
So far I've tried this:
However two problems arise: 1) lfWidth is only the *average* width of a character and 2) the lfWidth can be zero. I thought of using lfHeight instead but then realized that unlike string widths, string heights are mostly constant).
//Get Current Font
stringPixelWidth = strlen(string)*lf.lfWidth;
So is there a function or macro that I can use to find out the pixel width of a given string?
(in particular: this is for use with setting the width of the dropdown listbox of combo box)