When I create a simple CComboBox in a dialog that is to overlay a placeholder, then the font that I when I enter characters in the edit box is boldface. If the box is created from a resource, then the font is normal.
What I want to do is create simple combobox with normal dialog box font.
Here is the code snippet from OnInitDialog():
// this will overlay the placeholder text with a simple
// combobox of the same size
// ?? the problem is that the text is boldface in the edit box
CWnd* pPlaceHolder = GetDlgItem(IDC_PLACEHOLDER);
m_cbNewBox.Create(CBS_SIMPLE | CBS_SORT | CBS_AUTOHSCROLL
| WS_CHILD | WS_VISIBLE
| WS_TABSTOP | WS_VSCROLL
, rect, this, IDC_COMBO3);
// now we look at the style and font
pWnd = GetDlgItem(IDC_COMBO3);
hwnd = pWnd->GetSafeHwnd();
style = GetWindowLong(hwnd, GWL_STYLE);
// ?? why is this font return null?
pFont = pWnd->GetFont();
pFont = NULL;
When I step thru this with the debugger, the style is 0x50010341 which corresponds to a simple combobox created from a resource. The combobox that is actually created is the correct size and is a simple box with no list so it looks just like an edit control - fine so far! However when I type, the characters are boldface. In the code above, I thought I could check the font but the pFont returned is null.
When I put a combobox into the dialog via the resource editor, and doing the same thing as above, then the pFont points somewhere and I get the LOGFONT struct filled. Inside the lf struct as seen from the debugger are the following nonzero items:
lfFaceName "MS Sans Serif"
I'm not sure what the weight means but typing in the box produces normal weight characters for a dialog box.