2

I want to change the default behaviour of a combobox (c++, win32 api). I make the combobox drop down when something is entered in its edit control I want to avoid the default behaviour that the combobox searches for the first match in the list, selects it, and enters the selected string into the edit control. Can I suppress this behaviour by catching the respective (LB_SETCURSEL etc.) messages out of the message queue myself with GetMessage()?

Does anyone habe a different idea of how to do it?

Greets Michbeck

Michbeckable
  • 1,851
  • 1
  • 28
  • 41

1 Answers1

1

You likely want to implement Window subclassing. This allows you to insert your own WndProc function into the combobox control that gets called before the control's own WndProc is called. You can filter out (and drop) window messages you don't want the control to get.

I'm not booted into my windows partition right now to run Spy++ on a combobox to see what messages it actually receives. My guess is that you want to filter out WM_CHAR from being received by the combobox.

selbie
  • 100,020
  • 15
  • 103
  • 173
  • Thx! I have tried subclassing the edit control or the list control, to prevent them from their default behaviour in a combobox. The subclassing worked, but i could not get the right messages. I tried to catch WM_COMMAND msg or LBN_SELCHANGE, but it doesnt work, so I guess this was wrong. I assume that the combobox itself sends an LB_SETCURSEL msg to its listbox and also WM_SETTEXT and EM_SETSEL to the edit control to do the expected bevhiour. What do you think? – Michbeckable Oct 18 '11 at 08:49
  • Subclassing is somewhat tricky. In order to catch WM_COMMAND you must subclass the parent window. – RED SOFT ADAIR Oct 18 '11 at 08:52