Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- switch (msg)
- {
- case WM_PAINT:
- {
- HPEN framePen = ::CreatePen(PS_SOLID, 5, RGB(255, 0, 0));
- RECT rect = {};
- PAINTSTRUCT ps;
- ::GetClientRect(hwnd, &rect);
- HDC hdc = ::BeginPaint(hwnd, &ps);
- ::SelectObject(hdc, framePen);
- ::Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
- ::EndPaint(hwnd, &ps);
- }
- case WM_CLOSE:
- DestroyWindow(hwnd);
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- default:
- return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- return 0;
- }
- int main()
- {
- HWND handle = FindWindow(L"ConsoleWindowClass", L"C:\WINDOWS\system32\cmd.exe");
- SetForegroundWindow(handle);
- RECT rect = {};
- ::GetWindowRect(handle, &rect);
- WNDCLASSEX wx = {};
- wx.cbSize = sizeof(WNDCLASSEX);
- wx.lpfnWndProc = WndProc;
- wx.lpszClassName = L"TestBorderWindow";
- wx.hCursor = ::LoadCursor(NULL, IDC_ARROW);
- wx.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
- ::RegisterClassEx(&wx);
- HWND hWnd = CreateWindowEx(WS_EX_LAYERED,
- L"TestBorderWindow",
- L"Demo",
- WS_POPUP,
- rect.left, rect.top,
- rect.right - rect.left, rect.bottom - rect.top,
- NULL,
- NULL,
- (HINSTANCE)GetModuleHandle(NULL),
- NULL);
- ::GetWindowRect(handle, &rect);
- SetLayeredWindowAttributes(hWnd, RGB(0, 0, 0), 255, LWA_ALPHA);
- ::SetWindowPos(handle, hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
- SWP_SHOWWINDOW);
- }
Add Comment
Please, Sign In to add comment