@@ -154,15 +154,12 @@ int createSomeWindows(const HWND& consoleHwnd)
154
154
return 0 ;
155
155
}
156
156
157
- // This wmain exists for help in writing scratch programs while debugging.
158
- int __cdecl wmain (int /* argc*/ , WCHAR* /* argv[]*/ )
157
+ int doDefaultOutput ()
159
158
{
160
159
const auto pid{ GetCurrentProcessId () };
161
160
const auto consoleWindow{ GetConsoleWindow () };
162
- // createSomeWindows(consoleWindow);
163
161
164
162
wprintf (fmt::format (L" pid: {}\n " , pid).c_str ());
165
-
166
163
wprintf (fmt::format (L" consoleWindow: {0:#010x}\n " , reinterpret_cast <unsigned long long >(consoleWindow)).c_str ());
167
164
168
165
const auto mainHwnd{ find_main_window (pid) };
@@ -181,3 +178,39 @@ int __cdecl wmain(int /*argc*/, WCHAR* /*argv[]*/)
181
178
182
179
return 0 ;
183
180
}
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