Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <d2d1.h>
- #include <dwmapi.h>
- LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- switch (uMsg)
- {
- case WM_DESTROY:
- {
- PostQuitMessage(0);
- return 0;
- }
- }
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
- }
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
- {
- WNDCLASSEX wndClass;
- ZeroMemory(&wndClass, sizeof(WNDCLASSEX));
- wndClass.cbSize = sizeof(WNDCLASSEX);
- wndClass.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(0, 0, 0));
- wndClass.hInstance = hInstance;
- wndClass.lpfnWndProc = WindowProc;
- wndClass.lpszClassName = "Overlay";
- wndClass.style = CS_HREDRAW | CS_VREDRAW;
- RegisterClassEx(&wndClass);
- RECT rc = {0, 0, 1440, 900};
- AdjustWindowRectEx(&rc, WS_OVERLAPPEDWINDOW, false, WS_EX_OVERLAPPEDWINDOW);
- HWND hWnd = CreateWindowEx(WS_EX_LAYERED, "Overlay", "OverlayWindow", WS_EX_TOPMOST | WS_POPUP,
- 0, 0, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, NULL);
- ID2D1Factory *factory = NULL;
- ID2D1HwndRenderTarget *renderTarget = NULL;
- ID2D1SolidColorBrush *brush = NULL;
- HRESULT hResult = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &factory);
- RECT rc2;
- GetClientRect(hWnd, &rc2);
- factory->CreateHwndRenderTarget(
- D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED)),
- D2D1::HwndRenderTargetProperties(hWnd, D2D1::SizeU(rc2.right, rc2.bottom), D2D1_PRESENT_OPTIONS_IMMEDIATELY),
- &renderTarget);
- renderTarget->CreateSolidColorBrush(D2D1::ColorF(0, 0, 0, 0), &brush);
- const MARGINS margin = {-1};
- SetLayeredWindowAttributes(hWnd, RGB(0, 0, 0), 255, ULW_COLORKEY | LWA_ALPHA);
- DwmExtendFrameIntoClientArea(hWnd, &margin);
- ShowWindow(hWnd, nShowCmd);
- MSG messages = {0};
- while (messages.message != WM_QUIT)
- {
- if (PeekMessage(&messages, NULL, 0, 0, PM_REMOVE))
- {
- TranslateMessage(&messages);
- DispatchMessage(&messages);
- }
- else
- {
- renderTarget->BeginDraw();
- renderTarget->Clear(D2D1::ColorF(0.0f, 0.0f, 0.0f, 0.0f));
- brush->SetColor(D2D1::ColorF(1.0f, 0.0f, 0.0f, 1.0f));
- renderTarget->DrawEllipse(D2D1::Ellipse(D2D1::Point2F(100, 100), 50, 50), brush, 3.0f);
- renderTarget->EndDraw();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement