How do I set my MainForm to be hidden when my program starts?

南楼画角 提交于 2019-12-23 08:28:08

问题


I am using the Borland c++ builder. I have an application where I want the main form to be hidden until a button is pressed on a different form. i have set the Visible value on the mainform to false, but it still shows up when i run the program. anyone know what to do?


回答1:


Have a look at the TApplication ShowMainForm property.

Here is an example based on the instructions in online help.

  1. Set the main form Visible property to false.

  2. On the menu select Project -> View Source to display the main project file.

  3. Add the following code after the call to Application->CreateForm and before the call to Application->Run.

    Application->ShowMainForm = false;

You should end up with something like this.

try
{
  Application->Initialize();
  Application->MainFormOnTaskBar = true;
  Application->CreateForm(__classid(TMainForm), &MainForm);
  // extra code to hide main form
  Application->ShowMainForm = false;
  Application->Run();
}



回答2:


There is a demo that comes with C++Builder that does this It can be found in demos\cpp\apps\twoforms

"First" is the form with the button that shows "Second"

The button's OnClick event handler creates the new form with new, then calls ShowModal() You can use just Show() if it isn't meant to be a modal form.



来源:https://stackoverflow.com/questions/3452089/how-do-i-set-my-mainform-to-be-hidden-when-my-program-starts

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!