How to start a program without showing it

zhaozj2021-02-17  48

In order to start the program without displaying it, you must edit the Winmain function to the main window and program of the program.

Step 1: Select View | Project Source from the C Builder menu and start editing the Winmain function. Call the showWindow function, pass Application-> Handle, hide the program's task bar icon. Setting ShowMainForm to make the main window not displayed on the screen.

WinApi Winmain (Hinstance, Hinstance, LPSTR, INT)

{

Try

{

Application-> Initialize ();

Application-> CREATEFORM (__ classid (tform1), & form1);

Application-> ShowMainform = False;

ShowWindow (Application-> Handle, SW_HIDE);

Application-> Run ();

}

Catch (Exception & Exception)

{

Application-> Showexception (& Exception);

}

Return 0;

}

Step 2: Perform the following two lines of code when you want to display the program. Remember, if the code is positioned in a method of the main window class, Application-> Mainform-> Visible = true can be replaced with Visible = true.

ShowWindow (Application-> Handle, SW_SHOW);

Application-> mainform-> visible = true;

转载请注明原文地址:https://www.9cbs.com/read-28735.html

New Post(0)