NO

Author Topic: Combobox - problematic interface  (Read 6040 times)

Yates

  • Guest
Combobox - problematic interface
« 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.

severach

  • Guest
Combobox - problematic interface
« Reply #1 on: January 29, 2007, 05:32:22 PM »
#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.

Offline DMac

  • Member
  • *
  • Posts: 272
Combobox - problematic interface
« Reply #2 on: January 29, 2007, 11:40:36 PM »
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
No one cares how much you know,
until they know how much you care.

Yates

  • Guest
Combobox - problematic interface
« Reply #3 on: January 30, 2007, 08:43:21 AM »
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.

ivanhv

  • Guest
Combobox - problematic interface
« Reply #4 on: March 10, 2007, 12:22:47 AM »
I didn't know that WS_VSCROLL would have any effect on the combo's list.

Nice info, thanks.