hi
i'm trying to add a CComboBoxEx to the SearchFrame, in order to add icons next to the strings "audio" - "video" - etc for the file type.
everything seems fine, except one thing: the texts of the combo don't get colored, and their background stays white
after googling, i found GargoyleMT has faced the same exact problem, it's very well explained here:
http://groups.yahoo.com/group/wtl/message/7995
with my own words, i explained it here:
http://www.codeproject.com/script/comme ... x1525976xx
the advice of putting a transparent background mode given in the WTL list doesn't seem to change anything.
i'm wondering if it is the control that is buggy, and if i'm going to really need to use ownerdraw stuff, or if any clue could be found.
thanks
a problem adding a CComboBoxEx to SearchFrame
Moderator: Moderators
-
- Posts: 72
- Joined: 2004-01-23 14:45
i'm using ownerdraw and it works correctly
Code: Select all
...
MESSAGE_HANDLER(WM_DRAWITEM, onDrawItem)
...
LRESULT SearchFrame::onDrawItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
HWND hwnd = 0;
if(wParam == IDC_FILETYPES) return ListDraw(hwnd, wParam, (DRAWITEMSTRUCT*)lParam);
...
BOOL SearchFrame::ListDraw(HWND /*hwnd*/, UINT /*uCtrlId*/, DRAWITEMSTRUCT *dis) {
TCHAR szText[MAX_PATH+1];
int idx;
switch(dis->itemAction) {
case ODA_FOCUS:
if(!(dis->itemState & 0x0200))
DrawFocusRect(dis->hDC, &dis->rcItem);
break;
case ODA_SELECT:
case ODA_DRAWENTIRE:
ctrlFiletype.GetLBText(dis->itemID, szText);
if(dis->itemState & ODS_SELECTED) {
SetTextColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
SetBkColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHT));
} else {
SetTextColor(dis->hDC, WinUtil::textColor);
SetBkColor(dis->hDC, WinUtil::bgColor);
}
idx = dis->itemData;
ExtTextOut(dis->hDC, dis->rcItem.left+22, dis->rcItem.top+1, ETO_OPAQUE, &dis->rcItem, szText, lstrlen(szText), 0);
if(dis->itemState & ODS_FOCUS) {
if(!(dis->itemState & 0x0200 ))
DrawFocusRect(dis->hDC, &dis->rcItem);
}
ImageList_Draw(searchTypes, dis->itemID, dis->hDC,
dis->rcItem.left + 2,
dis->rcItem.top,
ILD_TRANSPARENT);
break;
}
return TRUE;
}