static LRESULT WINAPI UIWndProcBase(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_PAINT)
{
PAINTSTRUCT ps;
BeginPaint(hWnd, &ps);
//OnPaint(ps.hdc);
EndPaint(hWnd, &ps);
}
else if (msg == WM_DESTROY)
{
PostQuitMessage(0);
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
void UIRun()
{
WNDCLASSEX wc = {sizeof(wc)};
wc.hInstance = GetModuleHandle(0);
wc.lpszClassName = _T("uiclassname");
wc.lpfnWndProc = &UIWndProcBase;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
RegisterClassEx(&wc);
wstring ws = L"aaabbcd";
HWND hParent = CreateWindowExW(WS_EX_TRANSPARENT, _T("EDIT"), _T(""), WS_POPUP, 0, 0, 100, 100, 0, NULL, wc.hInstance, NULL);
HWND m_hWnd = CreateWindowEx(0, wc.lpszClassName, ws.c_str(), WS_POPUP, 0, 0, 100, 100,
hParent, NULL, wc.hInstance, NULL);
SetWindowLong(m_hWnd, GWL_EXSTYLE, WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_TOPMOST);
SetLayeredWindowAttributes(m_hWnd, RGB(0,0,0), 120, LWA_ALPHA);
SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_SHOWWINDOW);
MSG msg;
while (GetMessage(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
int main()
{
UIRun();
return 0;
} |