Sometimes you want to hide a dialog box as soon as it is started. There are many methods to achieve this, but the effects are not ideal. You can always see the trace of a pop-up dialog box. Is there a way to completely hide it? The answer is yes. Here is a simple implementation method.
The modifystyleex function is used to modify the extended properties of the window. The prototype of this function is:
Bool modifystyleex (
DWORD dwremove, // The attribute to be removed
DWORD dwadd, // attributes to be added
Uint nflags = 0
);
Add the code to the oninitdialog function in the dialog box:
Modifystyleex (ws_ex_appwindow, ws_ex_toolwindow );
The ws_ex_appwindow attribute is used to force a top-level window to appear on the taskbar when it is visible. Remove it.
The ws_ex_toolwindow attribute is used to create a window like a floating toolbar. The window does not appear on the taskbar and does not appear when you press/"Alt + TAB. Add it.
Add the code to the default handler defwindowproc in the dialog box:
If (Message = wm_ncpaint)
{
Showwindow (sw_hide );
Return 0;
}
The wm_ncpaint message is sent to the window when the window frame must be drawn.
Just add a few lines of simple code to make the window disappear after it is started. Of course, you must add the system tray icon for the program, or you will not be able to control the window.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service