There is a function to draw shadow,but each shadow takes 2ms to draw,if I create 10 shadow it takes nearly 20ms to draw and make the UI lag.
CreateShadowBox(hWnd, hdc, rc.left + 20, gTopSize, 100,100,Box1, RGB(60,60,60), RGB(10,10,10));
CreateShadowBox(hWnd, hdc, rc.left + 330, gTopSize, 100,100, Box2, RGB(60,60,60), RGB(10,10,10));
Because the amount of code is too large, I only show the structure:
typedef void (DRAWPANEL)(HWND, HDC);
void CreateBoxShadow(HWND h,HDC hdc,int x, int y, int sizex, int sizey, DRAWPANEL Drawing,COLORREF bcl, COLORREF cl)
The calculation delay can be understood as sleep(2);
What I have tried:
I try to use multithreading to do the calculation at the same time,but I don't know how to achieve it.
DWORD WINAPI VUIShadowBoxThread(LPVOID pf)
{
PanelHandleFun* p = (PanelHandleFun*)pf;
CreateBoxShadow(p->h, p->hdc, p->x, p->y, p->cx, p->cy, p->exDraw, p->c1, p->c2);
return 0;
}
void CreateBoxShadow_T(HWND h, HDC hdc, int x, int y, int sizex, int sizey, DRAWPANEL Drawing, COLORREF bcl, COLORREF cl)
{
PanelHandleFun p;
p.h = h;
p.hdc = hdc;
p.exDraw = Drawing;
p.x = x;
p.y = y;
p.cx = sizex;
p.cy = sizey;
p.c1 = bcl;
p.c2 = cl;
HANDLE thread = CreateThread(NULL, NULL, VUIShadowBoxThread, &p, 0, 0);
if (thread)
{
WaitForSingleObject(thread, INFINITE);
CloseHandle(thread);
}
}
Does anyone have an idea?Thank you!