DELPHI 如何设置主窗口
发布网友
发布时间:2023-07-17 07:35
我来回答
共5个回答
热心网友
时间:2023-07-21 03:45
form2做为登录窗口是不需要设置为主窗体的,如果设置为主窗体,登录完成以后把主窗体form2 释放后进程也就跟着释放了,这样你就实现不了你登录的效果!方法很多,给你举个例子:
打开你的工程文件(*.dpr,或project ->view source),把Application.CreateForm(TForm2,Form2)改为
Form2:= TForm2.Create(Application);并把这一句放到Application.CreateForm(TForm1,Form1)前面,如:
begin
application.initliaze;
Form2:= TForm2.Create(Application);
if not (Form2.ShowModal = mrOK) then
begin
Form2.Free;
Exit;
end;
Form2.free;
Application.CreateForm(TForm1,Form1);
Application.Run;
end;
Application.CreateForm()创建的第一个窗体就是主窗体,你要改的话就把你想要的放在前面就行了
热心网友
时间:2023-07-21 03:45
将formstyle设为fsmidform.子设成fsmidchild.
API:
The SetParent function changes the parent window of the specified child window. HWND SetParent(
HWND hWndChild, // handle to window whose parent is changing
HWND hWndNewParent // handle to new parent window
);
VCL:
Sets the parent of the control.
procere SetParent(AParent: TWinControl); virtual;
Description
SetParent is the protected implementation of the Parent property. Override SetParent to execute additional code when the value of the Parent property changes.
The AParent parameter specifies the new parent of the control.
If the control already has a parent, SetParent removes the control from that parent's list of controls by calling the parent's RemoveControl method. If AParent is not nil, SetParent calls its InsertControl method to add the control to its list of controls.
The TControl destructor calls SetParent(nil)to remove the control from its parent's control list before destroying the component.
热心网友
时间:2023-07-21 03:46
在project->options->forms选项卡里的main form选from2然后ok确定就可以了
热心网友
时间:2023-07-21 03:46
同意ayi033的方式,其实登陆窗口不用作为主窗体使用,可以参见Splash的实现方式去做
热心网友
时间:2023-07-21 03:47
在project->options->forms选项卡里把Form2调整到Form1上面