CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Delphi >  VCL组件开发及应用

FrameSniper(§绕瀑游龙§) 和Eastunfail(恶鱼杀手),请进,就刚才那打开子窗口的问题继续讨论。

楼主juwuyi(我有,我可以)2003-08-03 21:23:32 在 Delphi / VCL组件开发及应用 提问

我在main里打开FChild,然后关闭FChild。  
  然后再想打开FChild,结果就报错Abstract   Error  
  问题点数:100、回复次数:36Top

1 楼juwuyi(我有,我可以)回复于 2003-08-03 21:24:01 得分 0

我把Fchild定义在Public里。Top

2 楼juwuyi(我有,我可以)回复于 2003-08-03 21:28:23 得分 0

unit   MainMDIForm;  
   
  interface  
   
  uses  
      Windows,   Messages,   SysUtils,   Variants,   Classes,   Graphics,   Controls,   Forms,  
      Dialogs,   BaseForm,   ComCtrls,   ToolWin,   ExtCtrls,   ImgList,   Buttons,   Menus,   UserAddForm;  
   
  type  
      TFrmMain   =   class(TFrmBase)  
      private  
          {   Private   declarations   }  
      public  
          FChild:TFrm_UserAdd;  
      end;  
   
  procedure   TFrmMain.M_AddUserClick(Sender:   TObject);  
   
  begin  
      inherited;  
      //if   not   assigned(FChild)   then  
      if   not   assigned(FChild)   then  
          begin  
          FChild:=   TFrm_UserAdd.Create(Application);  
          FChild.Show   ;  
          end  
      else  
          FChild.BringToFront;     //把它Show在最前面  
      //Frm_UserAdd.Show;  
  end;  
  ==============  
  全部的代码就这样。  
  Top

3 楼FrameSniper(http://naoku.net/blogs/framesniper/)回复于 2003-08-03 21:36:53 得分 20

把FChild的定义放到单元接口部分的公共变量区........Top

4 楼Eastunfail(龍子龍孫) (Serpent's Embrace)回复于 2003-08-03 21:39:28 得分 30

例如添加一个新的Unit。  
  然后在interface和implementation之间写:  
   
  var    
      FChild:Tfrm_UserAdd;  
  要用这个FChild就uses这个Unit文件。  
   
   
   
  p.s.怎么在你的代码中没有看到implementation呢?Top

5 楼FrameSniper(http://naoku.net/blogs/framesniper/)回复于 2003-08-03 21:43:47 得分 0

他忘记写了呗!!!!!!!!!!!!!  
   
  ps是啥意思?Top

6 楼microjuz(天才弟弟……》说好了和xgto看流星雨)回复于 2003-08-03 21:54:18 得分 0

FS你不是号称e文很好吗。。keke  
  ps是补充的意思  
  中文里相当于:附注Top

7 楼microjuz(天才弟弟……》说好了和xgto看流星雨)回复于 2003-08-03 21:54:50 得分 0

杀都要高考了,还一天到晚的泡csdn啊Top

8 楼FrameSniper(http://naoku.net/blogs/framesniper/)回复于 2003-08-03 21:56:04 得分 0

呵呵,他准备补习了,HOHOHOHO~~~~~~~~~``Top

9 楼juwuyi(我有,我可以)回复于 2003-08-04 09:14:10 得分 0

--------------  
  例如添加一个新的Unit。  
  然后在interface和implementation之间写:  
   
  var    
      FChild:Tfrm_UserAdd;  
  要用这个FChild就uses这个Unit文件。  
  -------------------------------  
   
  to     Eastunfail(恶鱼杀手):  
  老大,这个更不行,也报错。  
  ErrorMessage:  
  Project   project1.exe   raised   exception   class   EAccessViolation   with   message   "Access  
  violation   at   address   004036D1   in   module   'project1.exe'.Read   of   address   A2cFc2D0".  
   
  要用这个FChild就uses这个Unit文件。  
  RS:老大,我肯定use了的啊,不然我第一次怎么可以打开呢?  
  我现在的问题就是说打开是没问题的,就是第一次打开后再关闭Fchild窗口,然后再想打开就报错。  
   
  p.s.怎么在你的代码中没有看到implementation呢?  
   
  r:这个我省略调了啊。  
   
  Top

10 楼juwuyi(我有,我可以)回复于 2003-08-04 09:27:12 得分 0

Delphi   Help   About   abstract.  
  ------------------------------------------  
   
  Sometimes   a   method   is   declared   as   abstract   in   a   Delphi   component.   In   the   component   library,   abstract   methods   usually   occur   in   classes   whose   names   begin   with   "custom,"   such   as   TCustomGrid.   Such   classes   are   themselves   abstract,   in   the   sense   that   they   are   intended   only   for   deriving   descendant   classes.  
   
  While   you   can   create   an   instance   object   of   a   class   that   contains   an   abstract   member,   it   is   not   recommended.   Calling   the   abstract   member   leads   to   an   EAbstractError   exception.    
   
  The   abstract   directive   is   used   to   indicate   parts   of   classes   that   should   be   surfaced   and   defined   in   descendant   components;   it   forces   component   writers   to   redeclare   the   abstract   member   in   descendant   classes   before   actual   instances   of   the   class   can   be   created.Top

11 楼juwuyi(我有,我可以)回复于 2003-08-04 09:29:50 得分 0

FrameSniper(§绕瀑游龙§)   和Eastunfail(恶鱼杀手),:  
   
  能不能说说你们是怎么处理子窗口打开的?Top

12 楼duxin(小伍)回复于 2003-08-04 09:31:29 得分 20

butfly   好久没见到你了    
   
   
   
  我来凑热闹:)Top

13 楼juwuyi(我有,我可以)回复于 2003-08-04 09:37:54 得分 0

to   duxin(小伍)    
   
  好像没你说的名啊?看错了吧?Top

14 楼duxin(小伍)回复于 2003-08-04 09:39:57 得分 0

:) 就是天才弟弟Top

15 楼juwuyi(我有,我可以)回复于 2003-08-04 09:55:39 得分 0

to:  
    duxin(小伍)    
   
  帮我解决这个问题啊,或者告诉我你是怎么处理的啦?  
   
  Top

16 楼duxin(小伍)回复于 2003-08-04 10:15:19 得分 0

你原先那个帖子是那个 我从头看看  
  现在不太了解你的意思Top

17 楼juwuyi(我有,我可以)回复于 2003-08-04 10:18:13 得分 0

to小伍  
  原贴,  
  http://expert.csdn.net/Expert/TopicView1.asp?id=2104428Top

18 楼juwuyi(我有,我可以)回复于 2003-08-04 10:23:33 得分 0

to   duxin(小伍)  
  原贴内容:  
  http://expert.csdn.net/Expert/TopicView1.asp?id=2104428Top

19 楼fengjn(颗粒)回复于 2003-08-04 10:47:18 得分 0

在mdi的子窗体的onclose   的   action:=   cafree;Top

20 楼juwuyi(我有,我可以)回复于 2003-08-04 10:52:12 得分 0

to:   fengjn(小枫)    
  那个有的,不然我怎么可以关闭窗口呢  
   
  还有没有其他的办法?Top

21 楼ihihonline(潇潇->戒烟)回复于 2003-08-04 10:59:48 得分 0

HMM~~  
  阿扑~~阿扑~~  
   
  ----------------------------------------------------------  
  等待,如沙漠行舟,痛苦万分  
  Top

22 楼fengjn(颗粒)回复于 2003-08-04 11:09:27 得分 30

function   TXXX.ActiveForm(FCaption:   string):   boolean;  
  var   i:   integer;  
  begin  
  result:=   false;  
  for   i:=   0   to   DMIChildCount   -   1   do    
      if   MDIChildren[i].caption:=   FCaption   then  
      begin  
          if   MDIChildren[i].WindowsState   =   wsMinimized   then  
                MDIChildren[i].WindowsState   :=   wsNormal;  
          MDIChildren[i].WindowsState.SetFocus;    
          result:=   true;  
      end;  
  end;  
   
   
  procedure   TFrmMain.M_AddUserClick(Sender:   TObject);  
  begin  
      inherited;{这个是什么,不知道要不要加}  
      //if   not   assigned(FChild)   then  
      if   not   activeForm('请输入窗体的标题')   then  
          begin  
              FChild:=   TFrm_UserAdd.Create(Application);  
              //FChild.Show   ;//MDI子窗体好象不需要调用show;  
          end;  
  end;  
   
  Top

23 楼ihihonline(潇潇->戒烟)回复于 2003-08-04 11:22:05 得分 0

unit   Unit1;  
   
  interface  
   
  uses  
      Windows,   Messages,   SysUtils,   Variants,   Classes,   Graphics,   Controls,   Forms,  
      Dialogs,   Menus,unit2;  
   
  type  
      TForm1   =   class(TForm)  
          MainMenu1:   TMainMenu;  
          ssss1:   TMenuItem;  
          procedure   ssss1Click(Sender:   TObject);  
      private  
          {   Private   declarations   }  
      public  
          {   Public   declarations   }  
          FChild:TForm2;  
      end;  
   
  var  
      Form1:   TForm1;  
   
  implementation  
   
  {$R   *.dfm}  
   
  procedure   TForm1.ssss1Click(Sender:   TObject);  
  begin  
      inherited;  
      if   application.FindComponent('Form2')   =   Nil   then  
          begin  
          FChild:=   Tform2.Create(Application);  
          FChild.Show   ;  
          end  
      else  
      begin  
          FChild.BringToFront;     //把它Show在最前面  
      end;  
  end;  
   
  ----------------------------------------------------------  
  等待,如沙漠行舟,痛苦万分  
  Top

24 楼duxin(小伍)回复于 2003-08-04 11:30:21 得分 0

你释放是怎么做的   
  if   not   assigned(FChild)   then  
   
  小小的application.FindComponent('Form2')   =   Nil    
   
  应该都没问题 好像问题不是出在  
  procedure   TFrmMain.M_AddUserClick(Sender:   TObject);  
   
  begin  
      inherited;  
      //if   not   assigned(FChild)   then  
      if   not   assigned(FChild)   then  
          begin  
          FChild:=   TFrm_UserAdd.Create(Application);  
          FChild.Show   ;  
          end  
      else  
          FChild.BringToFront;     //把它Show在最前面  
      //Frm_UserAdd.Show;  
  end;  
   
   
  感觉好像 在打开时这里已经有实例存在了Top

25 楼juwuyi(我有,我可以)回复于 2003-08-04 12:26:55 得分 0

to     ihihonline(小小)   :  
   
  if   application.FindComponent('Form2')   =   Nil   then  
   
  这样子可以啦,但是我不知道这样子能不能保证创建的窗体是否得到释放呢?  
  谢谢!,我暂时就用这个写好了。  
  ----------------  
  还有你能不能说说看,这样子  
  if   not   assigned(FChild)   then  
  出现错误的原因在哪里?  
  Top

26 楼juwuyi(我有,我可以)回复于 2003-08-04 12:28:51 得分 0

to   小伍:  
  释放:  
  在mdi的子窗体的onclose   的   action:=   cafree;  
  Top

27 楼duxin(小伍)回复于 2003-08-04 12:57:17 得分 0

if   not   assigned(FChild)   then  
  看这个类的实例是否建立  
  not   assigned(FChild)   没有建立窗体   为真     只要建了一个   或以上都为假  
   
   
  if   application.FindComponent('Form2')   =   Nil   then  
  判断   Form2是否建立     或者说某一窗体是否建立  
   
   
  Top

28 楼fengjn(颗粒)回复于 2003-08-04 12:59:05 得分 0

if   not   assigned(FChild)   then  
  当对象释放后,FChild变量仍然指向内存的一块固定的地址,所以,单纯的assigned是无法检测对象是否释放了的。Top

29 楼juwuyi(我有,我可以)回复于 2003-08-04 13:20:43 得分 0

to:duxin(小伍)    
  application.FindComponent('Form2')     =     Nil  
  判断     Form2是否建立         或者说某一窗体是否建立  
  -----------------------  
  按这样子说,是不是Fchild定义在过程里就可以了,没必要定义在public里了?  
  它是根据窗口名来判断的?  
   
  小伍,是不是可以这样子说?  
   
  ==================  
  to      
      if     not     assigned(FChild)     then      
  当对象释放后,FChild变量仍然指向内存的一块固定的地址,所以,单纯的assigned是无法检测对象是否释放了的。    
   
  ------------  
  那应该怎样子判断对象是否释放?Top

30 楼juwuyi(我有,我可以)回复于 2003-08-04 13:21:37 得分 0

to:duxin(小伍)    
  application.FindComponent('Form2')     =     Nil  
  判断     Form2是否建立         或者说某一窗体是否建立  
  -----------------------  
  按这样子说,是不是Fchild定义在过程里就可以了,没必要定义在public里了  
  它是根据窗口名来判断的  
   
  小伍,是不是可以这样子说?  
   
  ==================  
  to      
      if     not     assigned(FChild)     then      
  当对象释放后,FChild变量仍然指向内存的一块固定的地址,所以,单纯的assigned是无法检测对象是否释放了的。    
   
  ------------  
  那应该怎样子判断对象是否释放?Top

31 楼juwuyi(我有,我可以)回复于 2003-08-04 13:22:34 得分 0

 
  to     fengjn(小枫)  
      if     not     assigned(FChild)     then      
  当对象释放后,FChild变量仍然指向内存的一块固定的地址,所以,单纯的assigned是无法检测对象是否释放了的。    
   
  ------------  
  那应该怎样子判断对象是否释放?Top

32 楼fengjn(颗粒)回复于 2003-08-04 13:27:33 得分 0

if     assigned(FChild)     then      
      if   FChild   is   TForm2   then  
          begin  
              //没有试过  
          end;  
   
  如果仅仅是在mdi中使用  
  function   TXXX.ActiveForm(FCaption:   string):   boolean;  
  var   i:   integer;  
  begin  
  result:=   false;  
  for   i:=   0   to   DMIChildCount   -   1   do    
      if   MDIChildren[i].caption:=   FCaption   then  
      begin  
          if   MDIChildren[i].WindowsState   =   wsMinimized   then  
                MDIChildren[i].WindowsState   :=   wsNormal;  
          MDIChildren[i].WindowsState.SetFocus;    
          result:=   true;  
      end;  
  end;  
  很有通用性和代表性的。Top

33 楼bluenightsky()回复于 2003-08-04 13:36:16 得分 0

if     not     assigned(FChild)     then   是没有错误的  
  吧fchild声明在你的主窗口下面  
  var    
      TFrmMain:TFrmBase;  
      FChild:Tfrm_UserAdd;  
  Top

34 楼ihihonline(潇潇->戒烟)回复于 2003-08-04 16:58:45 得分 0

喂,我的就白写了?  
  晕死..........Top

35 楼FrameSniper(http://naoku.net/blogs/framesniper/)回复于 2003-08-04 23:45:05 得分 0

哈哈哈哈,小小,俺狙击手只能表示同情了,HOHOHOHO~~~~~~~~~~~~~~~`Top

36 楼ihihonline(潇潇->戒烟)回复于 2003-08-05 01:11:39 得分 0

juwuyi(深白色)   (   )   信誉:100     2003-8-4   13:21:37     得分:0    
     
     
       
  to:duxin(小伍)    
  application.FindComponent('Form2')     =     Nil  
  判断     Form2是否建立         或者说某一窗体是否建立  
  -----------------------  
  按这样子说,是不是Fchild定义在过程里就可以了,没必要定义在public里了  
  它是根据窗口名来判断的  
   
  小伍,是不是可以这样子说?  
   
  ==================  
  to      
      if     not     assigned(FChild)     then      
  当对象释放后,FChild变量仍然指向内存的一块固定的地址,所以,单纯的assigned是无法检测对象是否释放了的。    
   
  ------------  
  那应该怎样子判断对象是否释放?  
   
  ------------------------------------  
    搞错了没有?楼主?  
    if     not     assigned(FChild)     then     //FChild   你定义在Public里边,但是已经释放了,还这样做有什么意义?晕死......  
     
  Top

37 楼FrameSniper(http://naoku.net/blogs/framesniper/)回复于 2003-08-05 09:42:08 得分 0

哈哈,你这个道理小眼镜和俺早告诉了楼主了,HOHOHOHO~~~~~~~~~~~``Top

相关问题

  • .net是语言杀手吗?!!!(欢迎讨论)
  • 讨论讨论
  • 讨论~~~
  • 讨论
  • 讨论:
  • 讨论
  • 讨论!!!!!
  • 讨论,bcb & delphi?????-----(bcb讨论)
  • 讨论讨论外包?
  • 大家来讨论讨论

关键词

  • .net
  • 内存
  • 检测
  • fchild
  • 窗体
  • 释放
  • eastunfail
  • duxin
  • windowsstate
  • mdichildren

得分解答快速导航

  • 帖主:juwuyi
  • FrameSniper
  • Eastunfail
  • duxin
  • fengjn

相关链接

  • Delphi类图书
  • Delphi类源码下载
  • Delphi控件下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo