I want to run the app in silent mode by passing in a parameter, otherwise I will show the window.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
Well, for one you could just decide not to create a window at all if this parameter is passed in, otherwise you can try calling ShowWindow, with the handle to your window and with the
SW_HIDE
parameter, and see if that does what you need.Another way of hiding the window and never having it show up, but still create it, is to chose to never call
ShowWindow
withSW_HIDE
on it, and create it withCreateWindow
/CreateWindowEx
, and not set theWS_VISIBLE
flag in thedwStyle
parameter.ShowWindow(... SW_HIDE ...)
doesn't work?The best practice here is to not create the window in the first place. Nothing forces you to actually create a window in InitInstance. Though if you're working with MFC it's likely a lot of your application/domain/business logic is sitting there, tightly coupled to those MFC message handlers and so forth. In which case the window will need to exist.
I think a better solution will be not creating the window if not needed. Take a look at the main function and you will see the code that creates the window. Call it only if you want to launch the window.
create the window, omit the WS_VISIBLE flag and don't call ShowWindow.
or
When you call showWindow(), add SW_HIDE parameter.
If you have an MFC
CWnd
based display thenCWnd::ShowWindow(SW_HIDE);
If you are using just win32 then
ShowWindow(hWnd, SW_HIDE);
Other things people do depending on your goals