a problem adding a CComboBoxEx to SearchFrame

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

Locked
poy
Posts: 83
Joined: 2006-04-03 15:55

a problem adding a CComboBoxEx to SearchFrame

Post by poy » 2006-06-11 10:21

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 :shock:

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 :)

Big Muscle
Posts: 72
Joined: 2004-01-23 14:45

Post by Big Muscle » 2006-06-11 12:47

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;
}

poy
Posts: 83
Joined: 2006-04-03 15:55

Post by poy » 2006-06-11 12:57

hehe, yes, i already have your code and i thought i could make it easier by removing the ownerdraw parts and using CComboBoxEx, which is exactly made to display icons. but the control seems buggy on many other parts too so i'm gonna stop with this idea :cry:

thanks Big Muscle good code 8)

Locked