Skip to content

Commit

Permalink
this was a test that Evan wanted me to try. seemed to work okay, but …
Browse files Browse the repository at this point in the history
…it's not validated with WAM
  • Loading branch information
zadjii-msft committed Feb 25, 2022
1 parent e46e9a3 commit 23b6fee
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/interactivity/base/InteractivityFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ using namespace Microsoft::Console::Interactivity;
pseudoClass.lpfnWndProc = DefWindowProc;
RegisterClass(&pseudoClass);

const auto windowStyle = (owner == HWND_DESKTOP) ? WS_OVERLAPPEDWINDOW : WS_CHILD;
// const auto windowStyle = (owner == HWND_DESKTOP) ? WS_OVERLAPPEDWINDOW : WS_CHILD;
const auto windowStyle = WS_OVERLAPPEDWINDOW;

// Attempt to create window
hwnd = CreateWindowExW(
Expand All @@ -376,9 +377,9 @@ using namespace Microsoft::Console::Interactivity;
status = NTSTATUS_FROM_WIN32(gle);
}

const auto awareness{ GetThreadDpiAwarenessContext() };
awareness;
SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
// const auto awareness{ GetThreadDpiAwarenessContext() };
// awareness;
// SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);

break;
}
Expand Down
41 changes: 37 additions & 4 deletions src/tools/scratch/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,12 @@ int createSomeWindows(const HWND& consoleHwnd)
return 0;
}

// This wmain exists for help in writing scratch programs while debugging.
int __cdecl wmain(int /*argc*/, WCHAR* /*argv[]*/)
int doDefaultOutput()
{
const auto pid{ GetCurrentProcessId() };
const auto consoleWindow{ GetConsoleWindow() };
// createSomeWindows(consoleWindow);

wprintf(fmt::format(L"pid: {}\n", pid).c_str());

wprintf(fmt::format(L"consoleWindow: {0:#010x}\n", reinterpret_cast<unsigned long long>(consoleWindow)).c_str());

const auto mainHwnd{ find_main_window(pid) };
Expand All @@ -181,3 +178,39 @@ int __cdecl wmain(int /*argc*/, WCHAR* /*argv[]*/)

return 0;
}

// This wmain exists for help in writing scratch programs while debugging.
int __cdecl wmain(int argc, WCHAR* argv[])
{
doDefaultOutput();

const auto consoleWindow{ GetConsoleWindow() };

if (argc <= 1)
{
return 0;
}

HWND target = consoleWindow;
std::wstring arg{ argv[1] };
if (arg == L"--parent" && argc > 2)
{
target = GetAncestor(consoleWindow, GA_ROOT);
arg = argv[2];
}

if (arg == L"messagebox")
{
MessageBoxW(target, L"foo", L"bar", MB_OK);
}
else if (arg == L"windows")
{
createSomeWindows(target);
}
else if (arg == L"hide")
{
ShowWindow(target, SW_HIDE);
}

return 0;
}

1 comment on commit 23b6fee

@github-actions

This comment was marked as outdated.

Please sign in to comment.