Article View: borland.public.cppbuilder.nativeapi
Article #4788Ownerdrawn combo box problem
From: Martin Golm
Date: Tue, 22 Nov 2005 11:26
Date: Tue, 22 Nov 2005 11:26
66 lines
2744 bytes
2744 bytes
Hi,
in my WinAPI application I create an ownerdrawn combo box with the
following style attributes:
CBS_DISABLENOSCROLL, CBS_DROPDOWNLIST, CBS_HASSTRINGS,
CBS_OWNERDRAWFIXED, CBS_NOINTEGRALHEIGHT, WS_BORDER,
WS_CHILD, ~WS_TABSTOP
In its parent's WndProc I catch the appropriate messages like this:
switch (iMessage)
{
case WM_MEASUREITEM:
{
LPMEASUREITEMSTRUCT mis = (LPMEASUREITEMSTRUCT)lParam;
if (mis->CtlType == ODT_COMBOBOX)
{
mis->itemHeight = 17;
return TRUE;
}
break;
}
case WM_DRAWITEM:
{
LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
if (dis->CtlType == ODT_COMBOBOX)
{
if (dis->itemState & ODS_COMBOBOXEDIT)
{
//...
}
else
{
//... (*)
}
return TRUE;
}
break;
}
case WM_COMMAND:
if (HIWORD(wParam) == CBN_DROPDOWN)
{
SendMessage(mComboBox, WM_SETREDRAW, FALSE, 0);
SendMessage(mComboBox, CB_RESETCONTENT, 0, 0);
SendMessage(mComboBox, CB_ADDSTRING, 0,
(LPARAM)aString_1.c_str());
//...
SendMessage(mComboBox, CB_ADDSTRING, 0,
(LPARAM)aString_n.c_str());
SendMessage(mComboBox, WM_SETREDRAW, TRUE, 0);
}
break;
}
return DefWindowProc(mHandle, iMessage, wParam, lParam);
Now, if I set a break point in the else part of the WM_DRAWITEM message
handling (marked with (*)), the dis->itemID is always -1 (which should
be the list index, I think, and thus >= 0), and dis->rcItem is always
{0, -15, 199, 0} (which should also change, IMO). Thus, I don't see the
dropdown listbox, but the control behaves like it is displaying the
listbox.
What did I wrong here? Did I miss something?
Thanks,
Martin
Technical Details
Message-ID:
<4383006E.F33D5F94@gmx.de>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!feed5.newsreader.com!newsreader.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,963aa3ddf5359b86,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Message-ID: <4383006E.F33D5F94@gmx.de> Date: Tue, 22 Nov 2005 12:26:38 +0100 From: Martin Golm <golm@gmx.de> Organization: - X-Mailer: Mozilla 4.78 [de] (Windows NT 5.0; U) X-Accept-Language: de MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Ownerdrawn combo box problem Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 84.179.194.134 X-Trace: newsgroups.borland.com 1132658674 84.179.194.134 (22 Nov 2005 03:24:34 -0700) Lines: 66 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!feed5.newsreader.com!newsreader.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail