L
likongxu
Unregistered / Unconfirmed
GUEST, unregistred user!
我做一个系统,有几个全局变量和一些通用的过程,(比如要经常建立特殊子
窗体的一个过程)我是否应该专门写一个"全局"变量单元来存放这些变量和过程阿?
我写了一个没有窗体的uGloabVar单元如下.里面现在只有一个过程,那为什么每次
我在别的单元里面use uGloabVar后,然后再调用openform这个过程的时候,
老是出错,而且错误还发生在uGloabVa这个单元,这个单元说明和定义好像没有错啊?
unit uGloabVar
interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ComCtrls, ToolWin
Var
procedure OpenForm(FormClass: TFormClass
var fm
AOwner:TComponent)
implementation
procedure OpenForm(FormClass: TFormClass
var fm
AOwner:TComponent)
var
i: integer
Child:TForm
begin
for i := 0 to Screen.FormCount -1 do
if Screen.Forms.ClassType=FormClass then
begin
Child:=Screen.Forms
if Child.WindowState=wsMinimized then
ShowWindow(Child.handle,SW_SHOWNORMAL)
else
ShowWindow(Child.handle,SW_SHOWNA)
if (not Child.Visible) then Child.Visible:=True
Child.BringToFront
Child.Setfocus
TForm(fm):=Child
exit
end
Child:=TForm(FormClass.NewInstance)
TForm(fm):=Child
Child.Create(AOwner)
end
end.
窗体的一个过程)我是否应该专门写一个"全局"变量单元来存放这些变量和过程阿?
我写了一个没有窗体的uGloabVar单元如下.里面现在只有一个过程,那为什么每次
我在别的单元里面use uGloabVar后,然后再调用openform这个过程的时候,
老是出错,而且错误还发生在uGloabVa这个单元,这个单元说明和定义好像没有错啊?
unit uGloabVar
interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ComCtrls, ToolWin
Var
procedure OpenForm(FormClass: TFormClass
var fm
AOwner:TComponent)
implementation
procedure OpenForm(FormClass: TFormClass
var fm
AOwner:TComponent)
var
i: integer
Child:TForm
begin
for i := 0 to Screen.FormCount -1 do
if Screen.Forms.ClassType=FormClass then
begin
Child:=Screen.Forms
if Child.WindowState=wsMinimized then
ShowWindow(Child.handle,SW_SHOWNORMAL)
else
ShowWindow(Child.handle,SW_SHOWNA)
if (not Child.Visible) then Child.Visible:=True
Child.BringToFront
Child.Setfocus
TForm(fm):=Child
exit
end
Child:=TForm(FormClass.NewInstance)
TForm(fm):=Child
Child.Create(AOwner)
end
end.