Guest User

Untitled

a guest
Oct 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  2. {
  3. switch (msg)
  4. {
  5. case WM_PAINT:
  6. {
  7. HPEN framePen = ::CreatePen(PS_SOLID, 5, RGB(255, 0, 0));
  8. RECT rect = {};
  9. PAINTSTRUCT ps;
  10. ::GetClientRect(hwnd, &rect);
  11. HDC hdc = ::BeginPaint(hwnd, &ps);
  12. ::SelectObject(hdc, framePen);
  13. ::Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
  14. ::EndPaint(hwnd, &ps);
  15. }
  16. case WM_CLOSE:
  17. DestroyWindow(hwnd);
  18. break;
  19. case WM_DESTROY:
  20. PostQuitMessage(0);
  21. break;
  22. default:
  23. return DefWindowProc(hwnd, msg, wParam, lParam);
  24. }
  25. return 0;
  26. }
  27.  
  28. int main()
  29. {
  30. HWND handle = FindWindow(L"ConsoleWindowClass", L"C:\WINDOWS\system32\cmd.exe");
  31.  
  32. SetForegroundWindow(handle);
  33.  
  34. RECT rect = {};
  35. ::GetWindowRect(handle, &rect);
  36.  
  37. WNDCLASSEX wx = {};
  38. wx.cbSize = sizeof(WNDCLASSEX);
  39. wx.lpfnWndProc = WndProc;
  40. wx.lpszClassName = L"TestBorderWindow";
  41. wx.hCursor = ::LoadCursor(NULL, IDC_ARROW);
  42. wx.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
  43.  
  44. ::RegisterClassEx(&wx);
  45.  
  46. HWND hWnd = CreateWindowEx(WS_EX_LAYERED,
  47. L"TestBorderWindow",
  48. L"Demo",
  49. WS_POPUP,
  50. rect.left, rect.top,
  51. rect.right - rect.left, rect.bottom - rect.top,
  52. NULL,
  53. NULL,
  54. (HINSTANCE)GetModuleHandle(NULL),
  55. NULL);
  56. ::GetWindowRect(handle, &rect);
  57. SetLayeredWindowAttributes(hWnd, RGB(0, 0, 0), 255, LWA_ALPHA);
  58. ::SetWindowPos(handle, hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
  59. SWP_SHOWWINDOW);
  60. }
Add Comment
Please, Sign In to add comment