KHMEXP void KHMAPI khui_ilist_draw_bg(khui_ilist * il, int idx, HDC dc, int x, int y, int opt, COLORREF bgcolor) { HDC dcm; HBITMAP hb_oldm, hb_mem; HBRUSH hbr; RECT r; dcm = CreateCompatibleDC(dc); hb_mem = CreateCompatibleBitmap(dc, il->cx, il->cy); hb_oldm = SelectObject(dcm, hb_mem); hbr = CreateSolidBrush(bgcolor); r.left = 0; r.top = 0; r.right = il->cx; r.bottom = il->cy; FillRect(dcm, &r, hbr); khui_ilist_draw(il,idx,dcm,0,0,opt); BitBlt(dc,x,y,il->cx,il->cy,dcm,0,0,SRCCOPY); SelectObject(dcm, hb_oldm); DeleteObject(hb_mem); DeleteObject(hbr); DeleteDC(dcm); }
LRESULT khm_toolbar_notify(LPNMHDR notice) { switch(notice->code) { case TBN_GETINFOTIP: { LPNMTBGETINFOTIP git = (LPNMTBGETINFOTIP) notice; int cmd; khui_action * a; cmd = git->iItem; a = khui_find_action(cmd); if (a) { if (a->caption) { StringCchCopy(git->pszText, git->cchTextMax, a->caption); } else if (a->tooltip) { StringCchCopy(git->pszText, git->cchTextMax, a->tooltip); } else if (a->is_caption) { wchar_t buf[INFOTIPSIZE]; buf[0] = L'\0'; LoadString(khm_hInstance, a->is_caption, buf, ARRAYLENGTH(buf)); StringCchCopy(git->pszText, git->cchTextMax, buf); } else { StringCchCopy(git->pszText, git->cchTextMax, L""); } } else { StringCchCopy(git->pszText, git->cchTextMax, L""); } } break; case TBN_HOTITEMCHANGE: { LPNMTBHOTITEM hi = (LPNMTBHOTITEM) notice; if (hi->dwFlags & HICF_LEAVING) { khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, L""); } else { khui_action * a; int cmd; wchar_t buf[256]; cmd = hi->idNew; a = khui_find_action(cmd); buf[0] = L'\0'; if (a) { if (a->tooltip) StringCbCopy(buf, sizeof(buf), a->tooltip); else if (a->is_tooltip) { LoadString(khm_hInstance, a->is_tooltip, buf, ARRAYLENGTH(buf)); } } khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, buf); } } break; case TBN_DROPDOWN: { LPNMTOOLBAR nmtb = (LPNMTOOLBAR) notice; RECT r; GetWindowRect(khui_hwnd_standard_toolbar, &r); if (nmtb->iItem == KHUI_ACTION_DESTROY_CRED) { khm_menu_show_panel(KHUI_MENU_DESTROY_CRED, r.left + nmtb->rcButton.left, r.top + nmtb->rcButton.bottom); } else if (nmtb->iItem == KHUI_ACTION_RENEW_CRED) { khm_menu_show_panel(KHUI_MENU_RENEW_CRED, r.left + nmtb->rcButton.left, r.top + nmtb->rcButton.bottom); } else { return TBDDRET_NODEFAULT; } return TBDDRET_DEFAULT; } break; case NM_CUSTOMDRAW: { LPNMTBCUSTOMDRAW nmcd = (LPNMTBCUSTOMDRAW) notice; if(nmcd->nmcd.dwDrawStage == CDDS_PREPAINT) { return CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTERASE; } else if(nmcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT) { return CDRF_NOTIFYPOSTPAINT; } else if(nmcd->nmcd.dwDrawStage == CDDS_ITEMPOSTPAINT) { /* draw the actual icon */ int iidx; int ibmp; HBITMAP hbmp; RECT r; khui_action * act = khui_find_action((int) nmcd->nmcd.dwItemSpec); if(!act || !act->ib_normal) return CDRF_DODEFAULT; if((act->state & KHUI_ACTIONSTATE_DISABLED) && act->ib_disabled) { ibmp = act->ib_disabled; } else if(act->ib_hot && ((nmcd->nmcd.uItemState & CDIS_HOT) || (nmcd->nmcd.uItemState & CDIS_SELECTED))){ ibmp = act->ib_hot; } else { ibmp = act->ib_normal; } iidx = khui_ilist_lookup_id(ilist_toolbar, ibmp); if(iidx < 0) { hbmp = LoadImage(khm_hInstance, MAKEINTRESOURCE(ibmp), IMAGE_BITMAP, KHUI_TOOLBAR_IMAGE_WIDTH, KHUI_TOOLBAR_IMAGE_HEIGHT, 0); iidx = khui_ilist_add_masked_id(ilist_toolbar, hbmp, KHUI_TOOLBAR_BGCOLOR, ibmp); DeleteObject(hbmp); } if(iidx < 0) return CDRF_DODEFAULT; CopyRect(&r, &(nmcd->nmcd.rc)); r.left += ((r.bottom - r.top) - KHUI_TOOLBAR_IMAGE_HEIGHT) / 2; r.top += ((r.bottom - r.top) - KHUI_TOOLBAR_IMAGE_HEIGHT) / 2; #if 0 r.left += ((r.right - r.left) - KHUI_TOOLBAR_IMAGE_WIDTH) / 2; #endif khui_ilist_draw(ilist_toolbar, iidx, nmcd->nmcd.hdc, r.left, r.top, 0); return CDRF_DODEFAULT; } } break; } return 0; }