I tried to develop my program in windowless framework,I want to change the UI(more clearly,just like switch to the next page) when clicked a button(button is a click area),all the control based on hdc,so it is not available to switch the page like window.
Let me introduce my code.
typedef void (DRAWPANEL)(HWND, HDC);
typedef int RUNFUN;
void CreatePanel(HWND h, HDC hdc, DRAWPANEL DrawFun)
{
HDC hMemDC;
HBITMAP hBmpMem;
HBITMAP hPreBmp;
RECT rc;
GetClientRect(h, &rc);
hMemDC = CreateCompatibleDC(hdc);
hBmpMem = CreateCompatibleBitmap(hdc, rc.right - rc.left, rc.bottom - rc.top);
hPreBmp = (HBITMAP)SelectObject(hMemDC, hBmpMem);
DrawFun(h, hMemDC);
BitBlt(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
SelectObject(hMemDC, hPreBmp);
DeleteObject(hBmpMem);
DeleteDC(hMemDC);
}
int ClickArea(HWND hWnd, int x, int y, int sizex, int sizey, LPARAM lParam, RUNFUN function())
{
POINT pt;
wchar_t txt[80];
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
wsprintf(txt, L"x=%d;y=%d\n", LOWORD(lParam), HIWORD(lParam));
OutputDebugString(txt);
RECT rect;
GetClientRect(hWnd, &rect);
RECT rc = { x,y,x + sizex,y + sizey };
if (PtInRect(&rc, pt))
{
function();
return -1;
}
return -1;
}
void Panel1(HWND hWnd,HDC hdc)
{
}
void Panel2(HWND hWnd, HDC hdc)
{
}
RUNFUN test()
{
return 0;
}
Finally,Draw it.
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
CreatePanel(hWnd, hdc, Panel1);
EndPaint(hWnd, &ps);
break;
}
case WM_LBUTTONUP:
{
ClickArea(hWnd, 20, 20, 100, 40,lParam,test);
break;
}
you can see "Panel2" in my code.
I just wanted to change the UI from Panel1 to Panel2 when click the button.
Images of two panels:
https://db.vertexstudio.xyz/lnk/PanelPic/1.png
https://db.vertexstudio.xyz/lnk/PanelPic/2.png
What I have tried:
I created a new function:
void SwitchPanel(DRAWPANEL p)
{
}
I wanted to switch the panel by this.
Any idea?
Thank you for helping!