我做了一个登录子窗口login_form和主窗口main_form,login_form.formstyle设置为fsStayOnTop,我的目的是要程序运行时,login_form处于main_form上层(已实现),并且login_form处于激活状态,设置login_form为SetFocus,但无法实现。请问该如何设置?
解决方案 »
- 请教一个关于ReportMachine打印图片的动态大小问题
- delphi里开发COM时一些数据类型
- 读取dbf列名
- 请问一下不同的对象在一个里面怎么定义一个过程或函数?
- ★★为什么按钮在windows xp下没有xp效果?救命!!!
- dephi中如何创建一个不继承form的自定义类,还有,如何使用之?
- 报表问题。实现把数据逐行累计放于后面一个字段。怎么实现。懂的朋友快来啊!!
- 难题!十个GroupBox,如何让上面的控件(Edit,Memo各10个)内容分别为"aaa","bbb"
- 打开工程文件时出错(Error Reading Form)
- 非常奇怪的现象。。。
- delphi 怎么判断字符串里有几个英文单词?
- ID3DXSprite 贴图的疑惑 求大大指点迷津
这样主窗口就不能操作,必须关掉登陆窗口才能继续操作,即if login_form.showmodal=mrCancel then //验证不通过
application.Terminate;//退出程序
Forms,
Windows,
typinfo,
SysUtils,
MainForm in 'Pas\MainForm.pas' {frmMain},
test in 'Pas\test.pas' {FrmEdits},
Common in 'Pas\Common.pas',
test2 in 'Pas\test2.pas' {FrmTab},
GetCPUSerialNO in 'Pas\GetCPUSerialNo.pas',
RegInfo in 'Pas\RegInfo.pas' {frmRegInfo},
UserSeting in 'Pas\UserSeting.pas' {frmUserSeting},
PrdtInfo in 'Pas\PrdtInfo.pas' {frmPrdtInfo},
DM in 'Pas\DM.pas' {frmDM: TDataModule},
Login in 'Pas\Login.pas' {frmLogin},
Logo in 'Pas\Logo.pas' {frmLogo},
CompanyInfo in 'Pas\CompanyInfo.pas' {frmCompanyInfo},
CustInfo in 'Pas\CustInfo.pas' {frmCustInfo},
About in 'Pas\About.pas' {frmAbout},
CustOrder in 'Pas\CustOrder.pas' {frmCustOrder};{$R *.res}type TDesignUser=(LJJ);var
hMutex:HWND;
Ret:Integer;
hWinHwd:HWND;
UserName:array[0..20] of char;
fLength:dword;begin
Application.Initialize;
Application.Title:='沃丰纸业信息管理系统';
hWinHwd:=FindWindow(nil,Pchar('WooFong'));
SetForeGroundWindow(hWinHwd);
ShowWindow(hWinHwd,SW_SHOW);
hMutex:=CREATEMUTEX( nil,TRUE, Pchar('WooFong'));
Ret:=GetLastError();
if Ret<>ERROR_ALREADY_EXISTS then
Begin
frmLogo:=TfrmLogo.Create(Application);
frmLogo.Show;
frmLogo.Update;
Application.CreateForm(TfrmDM, frmDM);
Application.CreateForm(TfrmMain, frmMain);
fLength:=20;
GetUserName(UserName,fLength);
if GetEnumValue(TypeInfo(TDesignUser),UpperCase(UserName))<>-1 then
begin
frmMain.PUserNo :='001';
frmMain.PUserName:='Admin';
frmMain.PIsAdmin:=True;
end
else
Application.CreateForm(TfrmLogin, frmLogin);
frmLogo.Hide;
frmLogo.Close;
Application.Run;
End;
ReleaseMutex(hMutex);
end.下面是登录窗口的按钮事件procedure TfrmLogin.btnLoginClick(Sender: TObject);
var
cBaseRight,
cRight,
cUserPass,
cUserId,
cUserName:String; iMenuItemCnt:Integer;
begin
cUserName:=Trim(cobUserName.Text);
if cUserName='' then
begin
ShowMessage('用户名不能为空!');
cobUserName.SetFocus;
Abort;
end; with frmDM.tbUser do
begin
if not Locate('UserName',cUserName,[]) then
begin
ShowMessage('该用户不存在!');
cobUserName.SetFocus;
Abort;
end
else
begin
cUserId :=FieldbyName('UserID').AsString;
cUserName :=FieldbyName('UserName').AsString;
cUserPass :=FieldbyName('Password').AsString; if FieldbyName('IsAdmin').AsInteger=1 then
frmMain.IsAdmin:=True
else
frmMain.IsAdmin:=False;
end; if Trim(edtPassword.text)<>cUserPass then begin
ShowMessage('密码不正确!');
edtPassword.Clear;
edtPassword.SetFocus;
Exit;
end;
end; frmMain.PUserNo :=cUserId;
frmMain.PUserName:=cUserName; frmMain.Visible:=True;
Application.ShowMainForm:=True;
frmLogin.Hide;
//FreeAndNil(frmLogin);
end;
procedure Tmain_form.FormShow(Sender: TObject);
begin
main_form.Enabled:=false;
login_form.ShowModal;
end;报读取内存出错
首先这是逻辑问题。即先后逻辑问题。如果这个没搞好,很容易出问题的。比如Alt+F4
窗口都没有create,如何调用呢?
加了create
报错“cannot create a visible window modal”
报错“cannot create a visible window modal”