MCPcopy Create free account
hub / github.com/TranslucentTB/TranslucentTB / SetRegion

Method SetRegion

TranslucentTB/uwp/xamldragregion.cpp:80–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80void XamlDragRegion::SetRegion(int width, int height, wf::Rect buttonsRegion)
81{
82 if (buttonsRegion != m_ButtonsRegion)
83 {
84 if (buttonsRegion == wf::Rect { 0, 0, 0, 0 })
85 {
86 if (!SetWindowRgn(m_WindowHandle, nullptr, false)) [[unlikely]]
87 {
88 MessagePrint(spdlog::level::warn, L"Failed to clear window region");
89 return;
90 }
91 }
92 else
93 {
94 wil::unique_hrgn windowRgn(CreateRectRgn(0, 0, width, height));
95 if (!windowRgn) [[unlikely]]
96 {
97 MessagePrint(spdlog::level::warn, L"Failed to create window region");
98 return;
99 }
100
101 wil::unique_hrgn buttonsRgn(CreateRectRgn(
102 static_cast<int>(buttonsRegion.X),
103 static_cast<int>(buttonsRegion.Y),
104 static_cast<int>(buttonsRegion.X + buttonsRegion.Width),
105 static_cast<int>(buttonsRegion.Y + buttonsRegion.Height)
106 ));
107 if (!buttonsRgn) [[unlikely]]
108 {
109 MessagePrint(spdlog::level::warn, L"Failed to create buttons region");
110 return;
111 }
112
113 CombineRgn(windowRgn.get(), windowRgn.get(), buttonsRgn.get(), RGN_DIFF);
114
115 if (SetWindowRgn(m_WindowHandle, windowRgn.get(), false))
116 {
117 windowRgn.release(); // the system owns the region now
118 }
119 else
120 {
121 MessagePrint(spdlog::level::warn, L"Failed to set window region");
122 return;
123 }
124 }
125
126 m_ButtonsRegion = buttonsRegion;
127 }
128}
129
130XamlDragRegion::XamlDragRegion(WindowClass &classRef, Window parent) :
131 MessageWindow(classRef, { }, WS_CHILD, WS_EX_LAYERED | WS_EX_NOREDIRECTIONBITMAP, parent)

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected