From e038b5d9216c6710c2a7f81840d76f8130cd73b8 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Mon, 15 Jul 2019 08:41:24 -0500 Subject: [PATCH] Horrifyingly try Gdi Plus as a solution, that is _wrong_ though --- .../WindowsTerminal/NonClientIslandWindow.cpp | 86 ++++++++++++++----- .../WindowsTerminal/WindowsTerminal.vcxproj | 6 +- 2 files changed, 68 insertions(+), 24 deletions(-) diff --git a/src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp b/src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp index da12a6c192e..e885386a843 100644 --- a/src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp +++ b/src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp @@ -6,6 +6,19 @@ #include "pch.h" #include "NonClientIslandWindow.h" +// using namespace std; +// #include + +#ifndef max +#define max(a, b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +#define min(a, b) (((a) < (b)) ? (a) : (b)) +#endif +#include +#undef max +#undef min + extern "C" IMAGE_DOS_HEADER __ImageBase; using namespace winrt::Windows::UI; @@ -24,14 +37,20 @@ constexpr int RECT_HEIGHT(const RECT* const pRect) return pRect->bottom - pRect->top; } +Gdiplus::GdiplusStartupInput gdiplusStartupInput; +ULONG_PTR gdiplusToken; + NonClientIslandWindow::NonClientIslandWindow() noexcept : IslandWindow{}, _isMaximized{ false } { + // Initialize GDI+. + Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); } NonClientIslandWindow::~NonClientIslandWindow() { + Gdiplus::GdiplusShutdown(gdiplusToken); } // Method Description: @@ -536,34 +555,59 @@ RECT NonClientIslandWindow::GetMaxWindowRectInPixels(const RECT* const prcSugges const auto color = RGB(backgroundColor.R, backgroundColor.G, backgroundColor.B); _backgroundBrush = wil::unique_hbrush(CreateSolidBrush(color)); + const auto debugColor0 = RGB(255, 0, 255); + const auto debugBrush0 = wil::unique_hbrush(CreateSolidBrush(debugColor0)); + const auto debugColor1 = RGB(0, 255, 255); + const auto debugBrush1 = wil::unique_hbrush(CreateSolidBrush(debugColor1)); + const auto debugColor2 = RGB(255, 255, 0); + const auto debugBrush2 = wil::unique_hbrush(CreateSolidBrush(debugColor2)); + const auto debugColor3 = RGB(1, 1, 1); + const auto debugBrush3 = wil::unique_hbrush(CreateSolidBrush(debugColor3)); + const auto debugColor4 = RGB(255, 0, 0); + const auto debugBrush4 = wil::unique_hbrush(CreateSolidBrush(debugColor4)); + RECT windowRect = {}; ::GetWindowRect(_window.get(), &windowRect); const auto cx = windowRect.right - windowRect.left; const auto cy = windowRect.bottom - windowRect.top; - // Fill in the _entire_ titlebar area. - RECT dragBarRect = {}; - dragBarRect.left = xPos; - dragBarRect.right = xPos + cx; - dragBarRect.top = yPos; - dragBarRect.bottom = yPos + cy; - ::FillRect(hdc.get(), &dragBarRect, _backgroundBrush.get()); - - // Draw the top window border - RECT clientRect = { 0, 0, cx, yPos }; - ::FillRect(hdc.get(), &clientRect, _backgroundBrush.get()); - - // Draw the left window border - clientRect = { 0, 0, xPos, cy }; - ::FillRect(hdc.get(), &clientRect, _backgroundBrush.get()); + Gdiplus::Graphics graphics(hdc.get()); + Gdiplus::Color bgColor{ 255, 255, 0, 0 }; + Gdiplus::SolidBrush solidBrush(bgColor); + + // const RECT wholeWindowRelativeToWindow = { 0, 0, cx, cy }; + // ::FillRect(hdc.get(), &wholeWindowRelativeToWindow, debugBrush3.get()); + auto result = graphics.FillRectangle(&solidBrush, 0, 0, cx, cy); + // auto result = graphics.FillRectangle(&solidBrush, 200, 200, 200, 200); + result; + + // // Fill in the _entire_ titlebar area. + RECT dragBarRect = GetDragAreaRect(); + // dragBarRect.left = xPos; + // dragBarRect.right = xPos + cx; + // dragBarRect.top = yPos; + // dragBarRect.bottom = yPos + cy; + // ::FillRect(hdc.get(), &dragBarRect, _backgroundBrush.get()); + ::FillRect(hdc.get(), &dragBarRect, debugBrush1.get()); + + // // Draw the top window border + // RECT clientRect = { 0, 0, cx, yPos }; + // ::FillRect(hdc.get(), &clientRect, _backgroundBrush.get()); + + // // Draw the left window border + // clientRect = { 0, 0, xPos, cy }; + // ::FillRect(hdc.get(), &clientRect, _backgroundBrush.get()); // Draw the bottom window border - clientRect = { 0, cy - yPos, cx, cy }; - ::FillRect(hdc.get(), &clientRect, _backgroundBrush.get()); - - // Draw the right window border - clientRect = { cx - xPos, 0, cx, cy }; - ::FillRect(hdc.get(), &clientRect, _backgroundBrush.get()); + // clientRect = { 0, cy - yPos, cx, cy }; + // ::FillRect(hdc.get(), &clientRect, _backgroundBrush.get()); + // ::FillRect(hdc.get(), &clientRect, debugBrush2.get()); + // ::FillRect(hdc.get(), &clientRect, debugBrush3.get()); + // ::FillRect(hdc.get(), &clientRect, debugBrush4.get()); + + // // Draw the right window border + // clientRect = { cx - xPos, 0, cx, cy }; + // ::FillRect(hdc.get(), &clientRect, _backgroundBrush.get()); } return 0; diff --git a/src/cascadia/WindowsTerminal/WindowsTerminal.vcxproj b/src/cascadia/WindowsTerminal/WindowsTerminal.vcxproj index 05b96db3e14..d50102e92eb 100644 --- a/src/cascadia/WindowsTerminal/WindowsTerminal.vcxproj +++ b/src/cascadia/WindowsTerminal/WindowsTerminal.vcxproj @@ -36,7 +36,7 @@ "$(OpenConsoleDir)src\cascadia\TerminalCore\lib\Generated Files";%(AdditionalIncludeDirectories); - gdi32.lib;dwmapi.lib;Shcore.lib;%(AdditionalDependencies) + gdi32.lib;gdiplus.lib;dwmapi.lib;Shcore.lib;%(AdditionalDependencies) @@ -126,12 +126,12 @@ true - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - +