Pelles C forum
C language => Windows questions => Topic started by: Yates on January 29, 2007, 05:03:47 PM
-
Hi,
I am creating a combobox like this:
hCombo =CreateWindowEx(WS_EX_CLIENTEDGE , WC_COMBOBOX, "",
WS_CHILD | WS_VISIBLE | CBS_HASSTRINGS| CBS_DROPDOWNLIST , X, Y, Width, 120, hOwner, NULL, NULL, NULL);
(and yes, initcommoncontrols etc are OK).
To this combobox I add strings with:
SendMessage((HWND) hCombo,(UINT) CB_ADDSTRING, (WPARAM) 0, (LPARAM) (LPCTSTR) txt);
There are two problems here:
1. The font on the combobox is the old win3.1-style bold ugly one. It is not the standard windows font and I don't understand why.
2. Even worse: If I add, say, 10 strings, the resulting combobox will be a dropdown without the vertical scroll bar. That means I can select perhaps 4 or 5 of the entires, but I can only access the other by using arrow keys (there is no way to scroll up or down the list with the mouse or the mouse wheel). What am I doing wrong? Can I force a vertical scroll bar?
I have googled quite a bit and have looked at the different styles available for the combobox. Playing around with it has not solved my problem. So, I go for the gold: Ask in Pelles C forum!
Good work, Pelle =D>
Y.
-
#1: I've only used comboboxes on dialog boxes and I suspect that the dialog manager sends a WM_SETFONT to every control to ensure that it uses the same font as the dialog box.
#2: Google ControlSpy.
-
Attached is a small demo project to show how to do the things you want to do.
For more advanced customizing, check out my Code Project article.
http://www.codeproject.com/win32/Win32AutoCompleteComboBox.asp
Regards,
D Mac
-
DMac,
many thanks for this example.
It did it for me, and better still, I think your code is so crystal clear to me that I can learn from your example. I realised quickly that my scrollbar problem had to do with a style called WS_VSCROLL, which (in retrospect: of course) is not documented at MSDN under the combobox styles, but is rather a generic (general??) window style. Man, I have a lot to learn.
Thanks a lot.
DMac for president! \:D/
Y.
-
I didn't know that WS_VSCROLL would have any effect on the combo's list.
Nice info, thanks.