DELPHI 如何设置主窗口 30
delphi编译的时候默认是运行from1的,但我把from2设为登陆窗口,要先运行,应该在哪设置,可以使程序一运行先运行from2而不是from1....
delphi 编译的时候默认是运行from1的,但我把from2设为登陆窗口,要先运行,应该在哪设置,可以使程序一运行先运行from2而不是from1.
展开
展开全部
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()创建的第一个窗体就是主窗体,你要改的话就把你想要的放在前面就行了
打开你的工程文件(*.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()创建的第一个窗体就是主窗体,你要改的话就把你想要的放在前面就行了
展开全部
将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.
procedure 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.
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.
procedure 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.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在project->options->forms选项卡里的main form选from2然后ok确定就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
同意ayi033的方式,其实登陆窗口不用作为主窗体使用,可以参见Splash的实现方式去做
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在project->options->forms选项卡里把Form2调整到Form1上面
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询