How to change combobox to ownerdraw at runtime?
I'd like to change a combobox control to owner-draw at runtime. In the resource script the control is layed out as a standard control.
I've experimented with setting the style bits to CBS_OWNERDRAW | CBS_HASSTRINGS but somehow this does not help.
Does anybody know the trick?
Re: How to change combobox to ownerdraw at runtime?
Try SetWindowLong() function
Re: How to change combobox to ownerdraw at runtime?
I used SetWindowLong to or in the CBS_OWNERDRAW | CBS_HASSTRINGS styles.
Thats the code I use:
// turn to ownerdraw
DWORD dwStyle = ::GetWindowLong(hCtrl, GWL_STYLE);
dwStyle |= CBS_OWNERDRAWFIXED | CBS_HASSTRINGS;
VERIFY(0 != ::SetWindowLong(hCtrl, GWL_STYLE, dwStyle));
This code is processed in the WM_INITDIALOG message handler.
Unfortunately it doesn't work.
Anybody already done that?