static void sttDrawNonLayeredSkinedBar(HWND hwnd, HDC hdc) { HDC hdc2; HBITMAP hbmp,hbmpo; RECT rc={0}; GetClientRect(hwnd,&rc); rc.right++; rc.bottom++; hdc2=CreateCompatibleDC(hdc); hbmp=ske_CreateDIB32(rc.right,rc.bottom); hbmpo=(HBITMAP)SelectObject(hdc2,hbmp); if (GetParent(hwnd)!=pcli->hwndContactList) { HBRUSH br=GetSysColorBrush(COLOR_3DFACE); FillRect(hdc2,&rc,br); } else ske_BltBackImage(hwnd,hdc2,&rc); SendMessage(hwnd,MTBM_LAYEREDPAINT, (WPARAM)hdc2, 0); BitBlt(hdc,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top, hdc2,rc.left,rc.top,SRCCOPY); SelectObject(hdc2,hbmpo); DeleteObject(hbmp); mod_DeleteDC(hdc2); SelectObject(hdc,(HFONT)GetStockObject(DEFAULT_GUI_FONT)); ValidateRect(hwnd,NULL); }
static int ModernSkinButtonPaintWorker(HWND hwnd, HDC whdc) { HDC hdc; RECT rc; ModernSkinButtonCtrl* bct = (ModernSkinButtonCtrl *)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (!bct) return 0; if (!IsWindowVisible(hwnd)) return 0; if (!whdc && !g_CluiData.fLayered) InvalidateRect(hwnd, nullptr, FALSE); if (whdc && g_CluiData.fLayered) hdc = whdc; else { //sdc = GetWindowDC(GetParent(hwnd)); hdc = CreateCompatibleDC(nullptr); } GetClientRect(hwnd, &rc); HBITMAP bmp = ske_CreateDIB32(rc.right, rc.bottom); HBITMAP oldbmp = (HBITMAP)SelectObject(hdc, bmp); if (!g_CluiData.fLayered) ske_BltBackImage(bct->hwnd, hdc, nullptr); { MODERNMASK Request = {}; // int res; //HBRUSH br = CreateSolidBrush(RGB(255,255,255)); char * Value = nullptr; { if (bct->ValueDBSection && bct->ValueTypeDef) { char * key; char * section; DWORD defval = 0; char buf[20]; key = mir_strdup(bct->ValueDBSection); section = key; if (bct->ValueTypeDef[0] != 's') defval = (DWORD)atol(bct->ValueTypeDef + 1); do { if (key[0] == '/') { key[0] = '\0'; key++; break; } key++; } while (key[0] != '\0'); switch (bct->ValueTypeDef[0]) { case 's': { Value = db_get_sa(0, section, key); if (!Value) Value = mir_strdup(bct->ValueTypeDef + 1); break; } case 'd': defval = db_get_dw(0, section, key, defval); Value = mir_strdup(_ltoa(defval, buf, _countof(buf))); break; case 'w': defval = db_get_w(0, section, key, defval); Value = mir_strdup(_ltoa(defval, buf, _countof(buf))); break; case 'b': defval = db_get_b(0, section, key, defval); Value = mir_strdup(_ltoa(defval, buf, _countof(buf))); break; } mir_free(section); } } g_clcPainter.AddParam(&Request, mod_CalcHash("Module"), "MButton", 0); g_clcPainter.AddParam(&Request, mod_CalcHash("ID"), bct->ID, 0); g_clcPainter.AddParam(&Request, mod_CalcHash("Down"), bct->down ? "1" : "0", 0); g_clcPainter.AddParam(&Request, mod_CalcHash("Focused"), bct->focus ? "1" : "0", 0); g_clcPainter.AddParam(&Request, mod_CalcHash("Hovered"), bct->hover ? "1" : "0", 0); if (Value) { g_clcPainter.AddParam(&Request, mod_CalcHash("Value"), Value, 0); mir_free(Value); } SkinDrawGlyphMask(hdc, &rc, &rc, &Request); SkinSelector_DeleteMask(&Request); } if (!whdc && g_CluiData.fLayered) { RECT r; SetRect(&r, bct->Left, bct->Top, bct->Right, bct->Bottom); ske_DrawImageAt(hdc, &r); //CallingService to immeadeately update window with new image. } if (whdc && !g_CluiData.fLayered) { RECT r = { 0 }; GetClientRect(bct->hwnd, &r); BitBlt(whdc, 0, 0, r.right, r.bottom, hdc, 0, 0, SRCCOPY); } SelectObject(hdc, oldbmp); DeleteObject(bmp); if (!whdc || !g_CluiData.fLayered) { SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT)); DeleteDC(hdc); } // if (sdc) // ReleaseDC(GetParent(hwnd),sdc); return 0; }
static LRESULT CALLBACK EventArea_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_MEASUREITEM: { MEASUREITEMSTRUCT *lpi = (LPMEASUREITEMSTRUCT) lParam; MENUITEMINFOA mii = {0}; mii.cbSize = sizeof(mii); mii.fMask = MIIM_DATA | MIIM_ID; if (GetMenuItemInfoA(g_CluiData.hMenuNotify, lpi->itemID, FALSE, &mii) != 0) { if (mii.dwItemData == lpi->itemData) { lpi->itemWidth = 8 + 16; lpi->itemHeight = 0; return TRUE; } } } break; case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lParam; if (dis->hwndItem == (HWND) g_CluiData.hMenuNotify) { NotifyMenuItemExData *nmi = 0; MENUITEMINFOA mii = {0}; mii.cbSize = sizeof(mii); mii.fMask = MIIM_DATA; if (GetMenuItemInfoA(g_CluiData.hMenuNotify, (UINT) dis->itemID, FALSE, &mii) != 0) { nmi = (NotifyMenuItemExData *) mii.dwItemData; if (nmi) { int iIcon = cli_GetContactIcon(nmi->hContact); ske_ImageList_DrawEx(g_himlCListClc, nmi->iIcon, dis->hDC, 2, (dis->rcItem.bottom + dis->rcItem.top - GetSystemMetrics(SM_CYSMICON)) / 2, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), CLR_NONE, CLR_NONE, ILD_NORMAL); ske_ImageList_DrawEx(g_himlCListClc, iIcon, dis->hDC, 2+GetSystemMetrics(SM_CXSMICON)+2, (dis->rcItem.bottom + dis->rcItem.top - GetSystemMetrics(SM_CYSMICON)) / 2, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), CLR_NONE, CLR_NONE, ILD_NORMAL); return TRUE; } } } break; } case WM_LBUTTONUP: if (g_CluiData.bEventAreaEnabled) SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_NOTIFYBUTTON, 0), 0); break; case WM_COMMAND: if (LOWORD(wParam) == IDC_NOTIFYBUTTON) { int iSelection; MENUITEMINFO mii = {0}; POINT pt; struct NotifyMenuItemExData *nmi = 0; int iCount = GetMenuItemCount(g_CluiData.hMenuNotify); BOOL result; GetCursorPos(&pt); mii.cbSize = sizeof(mii); mii.fMask = MIIM_DATA; if (iCount > 1) iSelection = TrackPopupMenu(g_CluiData.hMenuNotify, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL); else iSelection = GetMenuItemID(g_CluiData.hMenuNotify, 0); result = GetMenuItemInfo(g_CluiData.hMenuNotify, (UINT) iSelection, FALSE, &mii); if (result != 0) { nmi = (struct NotifyMenuItemExData *) mii.dwItemData; if (nmi) { CLISTEVENT *cle = MyGetEvent(iSelection); if (cle) { CLISTEVENT *cle1 = NULL; CallService(cle->pszService, (WPARAM) NULL, (LPARAM) cle); // re-obtain the pointer, it may already be invalid/point to another event if the // event we're interested in was removed by the service (nasty one...) cle1 = MyGetEvent(iSelection); if (cle1 != NULL) CallService(MS_CLIST_REMOVEEVENT, (WPARAM) cle->hContact, (LPARAM) cle->hDbEvent); } } } break; } break; case WM_SIZE: if (!g_CluiData.fLayered) InvalidateRect(hwnd,NULL,FALSE); return DefWindowProc(hwnd, msg, wParam, lParam); case WM_ERASEBKGND: return 1; case WM_PAINT: if (GetParent(hwnd) == pcli->hwndContactList && g_CluiData.fLayered) CallService(MS_SKINENG_INVALIDATEFRAMEIMAGE,(WPARAM)hwnd,0); else if (GetParent(hwnd) == pcli->hwndContactList && !g_CluiData.fLayered) { HDC hdc, hdc2; HBITMAP hbmp,hbmpo; RECT rc = {0}; GetClientRect(hwnd,&rc); rc.right++; rc.bottom++; hdc = GetDC(hwnd); hdc2 = CreateCompatibleDC(hdc); hbmp = ske_CreateDIB32(rc.right,rc.bottom); hbmpo = (HBITMAP)SelectObject(hdc2,hbmp); ske_BltBackImage(hwnd,hdc2,&rc); EventArea_DrawWorker(hwnd,hdc2); BitBlt(hdc,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top, hdc2,rc.left,rc.top,SRCCOPY); SelectObject(hdc2,hbmpo); DeleteObject(hbmp); DeleteDC(hdc2); SelectObject(hdc,GetStockObject(DEFAULT_GUI_FONT)); ReleaseDC(hwnd,hdc); ValidateRect(hwnd,NULL); } else { HDC hdc, hdc2; HBITMAP hbmp, hbmpo; RECT rc; PAINTSTRUCT ps; HBRUSH br = GetSysColorBrush(COLOR_3DFACE); GetClientRect(hwnd,&rc); hdc = BeginPaint(hwnd,&ps); hdc2 = CreateCompatibleDC(hdc); hbmp = ske_CreateDIB32(rc.right,rc.bottom); hbmpo = (HBITMAP)SelectObject(hdc2,hbmp); FillRect(hdc2,&ps.rcPaint,br); EventArea_DrawWorker(hwnd,hdc2); BitBlt(hdc,ps.rcPaint.left,ps.rcPaint.top,ps.rcPaint.right-ps.rcPaint.left,ps.rcPaint.bottom-ps.rcPaint.top, hdc2,ps.rcPaint.left,ps.rcPaint.top,SRCCOPY); SelectObject(hdc2,hbmpo); DeleteObject(hbmp); DeleteDC(hdc2); ps.fErase = FALSE; EndPaint(hwnd,&ps); } default: return DefWindowProc(hwnd, msg, wParam, lParam); } return TRUE; }