Skip to content

Context Menus are sometimes not shown in High-DPI applications #2097

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Oct 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,7 @@ private void CreateWindow(bool asyncCall)
// cascading failure.
if (PopupInitialPlacementHelper.IsPerMonitorDpiScalingActive)
{
DestroyWindow();
DestroyWindowImpl();
_positionInfo = null;
makeNewWindow = true;
}
Expand Down Expand Up @@ -1601,18 +1601,40 @@ private void BuildWindow(Visual targetVisual)
_secHelper.BuildWindow(origin.x, origin.y, targetVisual, IsTransparent, PopupFilterMessage, OnWindowResize, OnDpiChanged);
}

private void DestroyWindow()
/// <summary>
/// Destroys the underlying window (HWND) if it is alive
/// </summary>
/// <returns>true if the window was destroyed, otherwise false</returns>
private bool DestroyWindowImpl()
{
if (_secHelper.IsWindowAlive())
{
_secHelper.DestroyWindow(PopupFilterMessage, OnWindowResize, OnDpiChanged);
ReleasePopupCapture();
return true;
}

// Raise closed event after popup has actually closed
OnClosed(EventArgs.Empty);
return false;
}

// When closing, clear the placement target registration
UpdatePlacementTargetRegistration(PlacementTarget, null);
/// <summary>
/// Destroys the window, and does additional book-keeping
/// like releasing the capture, raising Closed event, and
/// clearing placement-target registration
/// </summary>
private void DestroyWindow()
{
if (_secHelper.IsWindowAlive())
{
if (DestroyWindowImpl())
{
ReleasePopupCapture();

// Raise closed event after popup has actually closed
OnClosed(EventArgs.Empty);

// When closing, clear the placement target registration
UpdatePlacementTargetRegistration(PlacementTarget, null);
}
}
}

Expand Down