Skip to content

Commit 23b6fee

Browse files
committed
this was a test that Evan wanted me to try. seemed to work okay, but it's not validated with WAM
1 parent e46e9a3 commit 23b6fee

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

src/interactivity/base/InteractivityFactory.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ using namespace Microsoft::Console::Interactivity;
354354
pseudoClass.lpfnWndProc = DefWindowProc;
355355
RegisterClass(&pseudoClass);
356356

357-
const auto windowStyle = (owner == HWND_DESKTOP) ? WS_OVERLAPPEDWINDOW : WS_CHILD;
357+
// const auto windowStyle = (owner == HWND_DESKTOP) ? WS_OVERLAPPEDWINDOW : WS_CHILD;
358+
const auto windowStyle = WS_OVERLAPPEDWINDOW;
358359

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

379-
const auto awareness{ GetThreadDpiAwarenessContext() };
380-
awareness;
381-
SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
380+
// const auto awareness{ GetThreadDpiAwarenessContext() };
381+
// awareness;
382+
// SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
382383

383384
break;
384385
}

src/tools/scratch/main.cpp

+37-4
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,12 @@ int createSomeWindows(const HWND& consoleHwnd)
154154
return 0;
155155
}
156156

157-
// This wmain exists for help in writing scratch programs while debugging.
158-
int __cdecl wmain(int /*argc*/, WCHAR* /*argv[]*/)
157+
int doDefaultOutput()
159158
{
160159
const auto pid{ GetCurrentProcessId() };
161160
const auto consoleWindow{ GetConsoleWindow() };
162-
// createSomeWindows(consoleWindow);
163161

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

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

182179
return 0;
183180
}
181+
182+
// This wmain exists for help in writing scratch programs while debugging.
183+
int __cdecl wmain(int argc, WCHAR* argv[])
184+
{
185+
doDefaultOutput();
186+
187+
const auto consoleWindow{ GetConsoleWindow() };
188+
189+
if (argc <= 1)
190+
{
191+
return 0;
192+
}
193+
194+
HWND target = consoleWindow;
195+
std::wstring arg{ argv[1] };
196+
if (arg == L"--parent" && argc > 2)
197+
{
198+
target = GetAncestor(consoleWindow, GA_ROOT);
199+
arg = argv[2];
200+
}
201+
202+
if (arg == L"messagebox")
203+
{
204+
MessageBoxW(target, L"foo", L"bar", MB_OK);
205+
}
206+
else if (arg == L"windows")
207+
{
208+
createSomeWindows(target);
209+
}
210+
else if (arg == L"hide")
211+
{
212+
ShowWindow(target, SW_HIDE);
213+
}
214+
215+
return 0;
216+
}

0 commit comments

Comments
 (0)