Compare commits

...

1 commit

3 changed files with 69 additions and 0 deletions

View file

@ -289,12 +289,25 @@ void IslandWindow::Initialize()
{
_source = DesktopWindowXamlSource{};
auto originalWndProc{ GetWindowLongPtr(_window.get(), GWLP_WNDPROC) };
originalWndProc;
auto interop = _source.as<IDesktopWindowXamlSourceNative>();
winrt::check_hresult(interop->AttachToWindow(_window.get()));
// stash the child interop handle so we can resize it when the main hwnd is resized
interop->get_WindowHandle(&_interopWindowHandle);
auto islandWndProc{ GetWindowLongPtr(_window.get(), GWLP_WNDPROC) };
islandWndProc;
if (islandWndProc == originalWndProc)
{
auto a = 0;
a++;
a;
}
_rootGrid = winrt::Windows::UI::Xaml::Controls::Grid();
_source.Content(_rootGrid);

View file

@ -211,6 +211,25 @@ void NonClientIslandWindow::Initialize()
// then make sure to update it's visual state to reflect if we're in the
// maximized state on launch.
_titlebar.Loaded([this](auto&&, auto&&) { _OnMaximizeChange(); });
_originalWndProc = GetWindowLongPtr(_window.get(), GWLP_WNDPROC);
// auto newProc = [originalProc](HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam) -> LRESULT {
// switch (wm)
// {
// case WM_NCHITTEST:
// {
// int a = 0;
// a++;
// a;
// break;
// }
// }
// return reinterpret_cast<WNDPROC>(originalProc)(hwnd, wm, wParam, lParam);
// };
// SetWindowLongPtr(_window.get(), GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(&newProc));
SetWindowLongPtr(_window.get(), GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(&NonClientIslandWindow::_StaticOverrideWndProc));
}
// Method Description:
@ -948,3 +967,36 @@ void NonClientIslandWindow::_OpenSystemMenu(const int cursorX, const int cursorY
PostMessage(_window.get(), WM_SYSCOMMAND, ret, 0);
}
}
[[nodiscard]] LRESULT __stdcall NonClientIslandWindow::_StaticOverrideWndProc(HWND const window,
UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept
{
WINRT_ASSERT(window);
if (auto nonClientIslandWindow{ reinterpret_cast<NonClientIslandWindow*>(GetWindowLongPtr(window, GWLP_USERDATA)) })
{
return nonClientIslandWindow->_OverrideMessageHandler(message, wparam, lparam);
}
return DefWindowProc(window, message, wparam, lparam);
}
LRESULT NonClientIslandWindow::_OverrideMessageHandler(UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept
{
switch (message)
{
case WM_NCHITTEST:
{
int a = 0;
a++;
a;
break;
}
}
return reinterpret_cast<WNDPROC>(_originalWndProc)(_window.get(), message, wparam, lparam);
}

View file

@ -65,6 +65,10 @@ private:
[[nodiscard]] static LRESULT __stdcall _StaticInputSinkWndProc(HWND const window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept;
[[nodiscard]] LRESULT _InputSinkMessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept;
LONG_PTR _originalWndProc{ 0 };
[[nodiscard]] static LRESULT __stdcall _StaticOverrideWndProc(HWND const window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept;
[[nodiscard]] LRESULT _OverrideMessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept;
void _ResizeDragBarWindow() noexcept;
int _GetResizeHandleHeight() const noexcept;