怎样自动进入另一个窗体?

janlon 2004-05-07 11:42:58
在初始化一个窗体的时候,如果符合条件一则进入窗体A,否则进入窗体B,这种应该怎样实现?
...全文
25 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
janlon 2004-05-08
  • 打赏
  • 举报
回复
我的意思是在窗体初始化的时候如何进行判断?
laihongbo524 2004-05-08
  • 打赏
  • 举报
回复
if xxx then //你的条件
form1.show else form2.show;
cghdenglu 2004-05-08
  • 打赏
  • 举报
回复
xue xi?
楚人无衣 2004-05-08
  • 打赏
  • 举报
回复
var
frmFlash: TfrmFlash;
begin
Application.Initialize;
frmFlash := TfrmFlash.Create(application);
frmFlash.Show;
frmFlash.Update;
if frmFlash.ShowModal <> mrOk then {满足条件,运行a窗体}
Application.CreateForm(Tfrma, frma);
else {不满足条件,运行b窗体}
Application.CreateForm(Tfrmb, frmb);
frmFlash.Hide;
frmFlash.Free;
Application.Run;
end.
janlon 2004-05-08
  • 打赏
  • 举报
回复
weizi2000(秋风啊):

我用了你的方法,好像不行!运行后,出现一个最小化的窗口,其他什么也没有看到,还有就是计算机变得奇慢无比!

我是希望先检测互联网是否连通,如果连通,并且用户名与密码正确,则进入正常使用界面,如果网络没有连通,则进入拨号的界面!请帮我看一下错在什么地方!谢谢

以下是源码:

unit Unit_login;

interface

uses
Windows, Messages, winInet,SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls;

type
Tfrm_login = class(TForm)
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

type
TNature = (Micro,Macro);
TMethod = Record
Name: string[20];
Condition: string[40];
Nature: string[60];
Result: string[60];
end;
type MethodFileType = file of TMethod;
var
frm_login: Tfrm_login;
MyRec:TMethod;
RecFile:MethodFileType;
implementation

uses unit_first, Unit_myfirst, unit_main;

{$R *.dfm}
//函数开始
function InternetConnected: Boolean;

const

// local system uses a modem to connect to the Internet.

INTERNET_CONNECTION_MODEM = 1;

// local system uses a local area network to connect to the Internet.

INTERNET_CONNECTION_LAN = 2;

// local system uses a proxy server to connect to the Internet.

INTERNET_CONNECTION_PROXY = 4;

// local system's modem is busy with a non-Internet connection.

INTERNET_CONNECTION_MODEM_BUSY = 8;

var

dwConnectionTypes : DWORD;

begin

dwConnectionTypes := INTERNET_CONNECTION_MODEM+ INTERNET_CONNECTION_LAN+ INTERNET_CONNECTION_PROXY;

Result := InternetGetConnectedState(@dwConnectionTypes, 0);

end;
//函数结束
procedure Tfrm_login.FormShow(Sender: TObject);
var
name,pwd:string;
flag:boolean;
begin
AssignFile( RecFile, 'MYREC.FIL' ) ;
Reset( RecFile ) ;
read( RecFile, MyRec) ;
CloseFile( RecFile ) ;
name :=MyRec.Name;
pwd :=MyRec.Condition;
flag:=false;
if (name='123') and (pwd='123') then
flag:=true
else
flag:=false;
//
Application.Initialize;
frm_login := Tfrm_login.Create(application);
frm_login.Show;
frm_login.Update;
if InternetConnected and flag then {满足条件,运行a窗体}
Application.CreateForm(Tfrm_main, frm_main)
else {不满足条件,运行b窗体}
Application.CreateForm(Tfrm_myfirst, frm_myfirst);
frm_login.Hide;
frm_login.Free;
Application.Run;
//
end;
end.
Heyongfeng 2004-05-08
  • 打赏
  • 举报
回复
你必须在工程文件中把A和B的窗体初始化放在另一个窗体C的前面,然后才能在C的create事件里根据条件显示你要的窗口
qingenerp 2004-05-08
  • 打赏
  • 举报
回复
form.create里判断
if xxx then //你的条件
form1.show else form2.show;
tresss 2004-05-08
  • 打赏
  • 举报
回复
那就在form.create里判断就好啊!
你不是这个意思?

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧