您的位置:程序门 -> delphi -> vcl组件开发及应用



急急急


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


急急急
发表于:2007-07-19 16:00:35 楼主
我现在做了一个项目,我的.dpr文件第一个是主窗体,第二个才是登陆窗体,但我想登陆成功之后再显示

主窗体?

我的主窗体代码如下:
unit   frmmain;

interface

uses
    windows,   messages,   sysutils,   variants,   classes,   graphics,   controls,   forms,
    dialogs,   menus,   buttons,   toolwin,   comctrls;

type
    tbm_office   =   class(tform)
        mainmenu1:   tmainmenu;
        n1:   tmenuitem;
        n2:   tmenuitem;
        bgtxl:   tmenuitem;
        wjpl:   tmenuitem;
        yzqh:   tmenuitem;
        yylzh:   tmenuitem;
        sfz:   tmenuitem;
        zygl:   tmenuitem;
        n4:   tmenuitem;
        exit:   tmenuitem;
        n6:   tmenuitem;
        help:   tmenuitem;
        jsq:   tmenuitem;
        kdjl:   tmenuitem;
        sl:   tmenuitem;
        statusbar1:   tstatusbar;
        toolbar1:   ttoolbar;
        zyglspeed:   tspeedbutton;
        tslbutton2:   tspeedbutton;
        exitbutton3:   tspeedbutton;
        procedure   formactivate(sender:   tobject);
    private
        {   private   declarations   }
    public
        {   public   declarations   }
    end;

var
    bm_office:   tbm_office;

implementation

uses   login,   bm_hintu;

{$r   *.dfm}

procedure   tbm_office.formactivate(sender:   tobject);
begin
    if   not   loginEXECute(tfrmlogin)   then   application.terminate;
    end;
end.


登陆窗体如下:
unit   login;

interface

uses
    windows,   messages,   sysutils,   variants,   classes,   graphics,   controls,   forms,
    dialogs,   stdctrls,   buttons,   jpeg,   extctrls;

type
    tfrmlogin   =   class(tform)
        login_panel:   tpanel;
        panel2:   tpanel;
        label1:   tlabel;
        image1:   timage;
        btnok:   tspeedbutton;
        btnexit:   tspeedbutton;
        edtusername:   tedit;
        edtpsw:   tedit;
        label2:   tlabel;
        label3:   tlabel;
        procedure   btnokclick(sender:   tobject);
        procedure   edtusernamekeydown(sender:   tobject;   var   key:   word;
            shift:   tshiftstate);
        procedure   edtpswkeydown(sender:   tobject;   var   key:   word;
            shift:   tshiftstate);
        procedure   btnexitclick(sender:   tobject);
    private
        {   private   declarations   }
    public
        {   public   declarations   }
    end;

var
    frmlogin:   tfrmlogin;
    logined:   boolean   =   false;
    //打开登陆窗口,并判断是否登陆成功
    function   loginEXECute(aformclass:tformclass):boolean;
implementation

uses   dm,   frmmain;

{$r   *.dfm}

{   tfrmlogin   }

function   loginEXECute(aformclass:   tformclass):   boolean;
begin
    with   aformclass.create(application)   do
        begin
            logined   :=false;
            try
                showmodal;
            finally
                free;
            end;
            result   :=   logined;
        end;
end;


procedure   tfrmlogin.btnokclick(sender:   tobject);
var
    vlogined:variant;
    sql2:string;
begin
    with   frmdm.purview   do
    begin
        close;
        sql.clear;
        sql2:= 'select   p.*,d.d_code   from   purview   p,dept   d   where   p.u_name= ' ' '
                    +edtusername.text+ ' ' ' '+ 'and   p.u_psw= ' ' '
                    +edtpsw.text+ ' ' ' '+ 'and   p.u_dept=d.d_code ';
        sql.add(sql2);
        open;
        if   recordcount> 0   then   vlogined   :=   true
        else   vlogined:=   false;
        //密码不正确
        if   vlogined=false   then
            begin
                application.messagebox( '用户名或密码不正确,请重新输入 ', '提示信

息 ',mb_iconinformation);//mb_defbutton1
                exit;
            end
        else
            begin
                bm_office.statusbar1.panels[0].text   := '系统提示: ';
                bm_office.statusbar1.panels[1].text   := '民航学院: '+
                frmdm.purview.fields[0].asstring+ '操作员 ';
                bm_office.statusbar1.panels[2].text   := '登陆时间: '+
                formatdatetime( 'yyyy "年 "   mm "月 "   dd "日 "   tt ',now);
            end;
                logined   :=true;
                close;
    end;
end;

end.
怎样才能实现?
发表于:2007-07-19 16:05:581楼 得分:0
在工程文件中写....
  //           ahandle       :=       findwindow(nil, 'formm ');
    application.initialize;
    application.title   :=   'sdd ';
    application.createform(tfrmlogin,   frmlogin);
    //application.showmainform:=false;
    application.run;
设置主窗体
发表于:2007-07-19 16:23:252楼 得分:0
我的工程文件如下:
program   bmglxt;

uses
    forms,
    frmmain   in   'frmmain.pas '   {bm_office},
    dm   in   'dm.pas '   {frmdm:   tdatamodule},
    login   in   'login.pas '   {frmlogin},
    test   in   'test.pas '   {form1},
    bm_hintu   in   'bm_hintu.pas '   {bm_hintf};

{$r   *.res}
to   brightyang(其实我是一个程序员)
我看不明白你的;
我的工程文件如下:
begin
    application.initialize;
    application.createform(tfrmdm,   frmdm);
    application.createform(tbm_office,   bm_office);
    //application.createform(tfrmlogin,   frmlogin);
    //application.createform(tform1,   form1);
    //application.createform(tbm_hintf,   bm_hintf);
    application.run;
end.
发表于:2007-07-19 16:36:363楼 得分:0
把工程文件改成这样
begin
    application.initialize;
    application.createform(tfrmdm,   frmdm);
    application.createform(tbm_office,   bm_office);
    //application.createform(tfrmlogin,   frmlogin);
    //application.createform(tform1,   form1);
    //application.createform(tbm_hintf,   bm_hintf);
    if   not   loginEXECute   then   //   如果没有成功登录,就退出
        exit;
    application.run;
end.
发表于:2007-07-19 17:50:524楼 得分:0
谢谢logne帮我解决了问题!


快速检索

最新资讯
热门点击