从可用表单列表中选择MainForm [英] Choose MainForm from a list of available forms
问题描述
是否可以在连接到数据库之后从可用表单列表中选择一个表单(作为主窗体)?我有一个具有3'可用'形式的数据模块。当前没有主版本.Datamodule是首先创建的。现在,我想根据用户登录的数据库选择窗体,并使其成为主窗体。这可以做到吗?
Is it possible to choose a form (as a mainform) from a list of "available" forms after connecting to the database ? I have a datamodule with 3 'available' forms.No mainform for the time being.Datamodule is created first. Now, I would like to select the form depending on the database the user logs in to, and make it the mainform. Can this be done and how ?
推荐答案
主窗体被视为通过调用 Application.CreateForm
。所以将选择逻辑添加到.dpr文件代码中,然后调用 Application.CreateForm
来创建用户选择的任何形式。
The main form is deemed to be the first form created by a call to Application.CreateForm
. So add your selection logic to the .dpr file code, and then call Application.CreateForm
to create whichever form the user selects.
// .dpr code
begin
Application.Initialize;
CreateMainForm;
Application.Run;
end.
这里,$ code> CreateMainForm 由您和实现用户表单选择。可能会这样:
Here, CreateMainForm
is provided by you and implements the user form selection. It might go like this:
procedure CreateMainForm;
var
Form: TForm;
FormClass: TFormClass;
begin
FormClass := ChooseMainFormClass;
Application.CreateForm(FormClass, Form);
end;
再次, ChooseMainFormClass
由您提供。
这篇关于从可用表单列表中选择MainForm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!