DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: zlyscuicui
今日帖子: 16
在线用户: 5
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 dali2000 (dali2000) ★☆☆☆☆ -
普通会员
2011/12/6 10:11:55
标题:
在FormCreate事件中的如何中途退出 浏览:13536
加入我的收藏
楼主: 在FormCreate事件中执行到某一条件时要退出FormCreate过程(不是退出程序),用exit好象不起作用,exit后面的语句还是会执行。怎样才能在FormCreate事件中的如何中途退出呢?请指教。多谢
----------------------------------------------
-
作者:
男 lionlee (leo) ★☆☆☆☆ -
普通会员
2011/12/6 10:23:56
1楼:   Application.Terminate;

或则

halt(0);
----------------------------------------------
-
作者:
男 chjk (ChJK) ★☆☆☆☆ -
盒子活跃会员
2011/12/6 10:51:40
2楼: 楼上的兄弟,没看到楼主说的不是退出程序吗,就用exit就行了,如果可以把你的代码发上来看看,你说的exit执行完后面的程序还会执行的原因
----------------------------------------------
-
作者:
男 dali2000 (dali2000) ★☆☆☆☆ -
普通会员
2011/12/6 12:04:12
3楼: procedure TForm_main_gbst.FormCreate(Sender: TObject);
begin
...
if not FileExists(extractfilepath(application.ExeName)+'\ini.ini') then   
begin
     exit;
end;
....
end;
----------------------------------------------
-
作者:
男 zhahongyi (如风) ★☆☆☆☆ -
普通会员
2011/12/6 12:16:15
4楼: 看代码没问题,在if not 下个断点看看是怎么执行的
----------------------------------------------
-
作者:
男 a5824 (Return) ★☆☆☆☆ -
普通会员
2011/12/6 13:13:07
5楼: close吧
----------------------------------------------
-
作者:
男 iqye (iqye) ★☆☆☆☆ -
普通会员
2011/12/6 13:50:10
6楼: ifelse不是最简单的么
----------------------------------------------
-
作者:
男 pholon (pholon) ★☆☆☆☆ -
盒子活跃会员
2011/12/6 14:02:02
7楼: postmessage.这样不容易引起内存异常
----------------------------------------------
-
作者:
男 lyp8899 (lyp8899) ★☆☆☆☆ -
盒子活跃会员
2011/12/6 14:53:47
8楼:       1: Application.Terminate;
      2: ExitProcess(0);
      3: PostQuitMessage(0);
----------------------------------------------
▄︻┻┳═
作者:
男 chjk (ChJK) ★☆☆☆☆ -
盒子活跃会员
2011/12/6 15:48:04
9楼: procedure TForm_main_gbst.FormCreate(Sender: TObject);
begin
...
if not FileExists(extractfilepath(application.ExeName)+'\ini.ini') then   
     exit;
....
end;
在试试
----------------------------------------------
-
作者:
男 ruralboy (青瓜白菜番茄红) ★☆☆☆☆ -
盒子活跃会员
2011/12/6 18:52:01
10楼: procedure TForm_main_gbst.FormCreate(Sender: TObject);
begin
if FileExists(extractfilepath(application.ExeName)+'\ini.ini') then   
begin
  //尽量少些 exit, 直接判断了执行就好
  //
  //
  // 
end;
end;
----------------------------------------------
作者:
男 yryz (HouSoft) ★☆☆☆☆ -
普通会员
2011/12/8 10:28:30
11楼: 一堆人都不看清问题。。
----------------------------------------------
-HouSoft http://www.yryz.net
作者:
男 ljump (动力软件) ★☆☆☆☆ -
盒子活跃会员
2011/12/8 11:35:20
12楼: 换个角度试试,如果只是在窗体创建的时候判断一下ini文件是否存在,那可以在Form的OnShow事件中判断,如果是先判断ini文件存在才创建窗体的话,那应该在上一个窗体中判断
if FileExists(extractfilepath(application.ExeName)+'\ini.ini') then   
  begin
  Formx :=TFormx.Create(Application);
  Formx.ShowModal;
  end;
----------------------------------------------
学用Delphi,只是偶的一个兴趣
相信自己、相信别人!
作者:
男 zhlmxh (梦想成真) ★☆☆☆☆ -
盒子活跃会员
2011/12/9 1:12:06
13楼: 不建议在create中中止,应该单独写一个初始化函数,如果出错则关闭
----------------------------------------------
-
作者:
男 yepemig (yepemig) ★☆☆☆☆ -
盒子活跃会员
2011/12/9 11:26:41
14楼: 为什么要在Create中退出.这样写代码本来就思路不合理.
----------------------------------------------
-
作者:
男 yepemig (yepemig) ★☆☆☆☆ -
盒子活跃会员
2011/12/9 11:30:00
15楼: 你可以反过来啊, 在Form中写个类方法
class procedure Form1.CallThisForm;
begin
  if FileExists(extractfilepath(application.ExeName)+'\ini.ini') then 
    {Code: Create From}
  else
    {Code: Exit Appliction}
end;
----------------------------------------------
-
作者:
男 tengkong (tengkong) ▲▲▲▲▲ -
普通会员
2011/12/9 16:25:33
16楼: 用abort函數,就不會執行下面的代碼了
----------------------------------------------
-
作者:
女 jekhn (jekhn) ★☆☆☆☆ -
普通会员
2012/2/4 9:03:51
21楼: extractfilepath(application.ExeName)+'\ini.ini'
这一句有问题,多了一个\
extractfilepath(application.ExeName)+'ini.ini'这样就行,extractfilepath已经包含了\,所以你在多加一个就错了。如果你不确定路径里面有没有\,可以用一个函数IncludeTrailingPathDelimiter,它会帮你加上,如果有了就不加。这样就能保证是正确的路径。
IncludeTrailingPathDelimiter(extractfilepath(application.ExeName))+'ini.ini'
----------------------------------------------
-
作者:
男 myhby (myhby) ★☆☆☆☆ -
盒子活跃会员
2012/2/5 12:47:55
29楼: procedure TForm1.FormCreate(Sender: TObject);
begin

if not FileExists(extractfilepath(application.ExeName)+'\ini.ini') then
begin
     ShowMessage('不存在ini文件');
     exit;
end;
ShowMessage('存在ini文件');

end;
----------------------------------------------
-
作者:
男 foxlang (foxlang) ★☆☆☆☆ -
盒子活跃会员
2012/2/5 15:05:21
32楼: 把 '\ini.ini' 前的 '\' 删除就行了!
----------------------------------------------
-
作者:
男 wangminghuaxf (hua) ★☆☆☆☆ -
普通会员
2012/3/16 7:14:23
252楼: exit
----------------------------------------------
-
作者:
女 airmax77 (airmax77) ▲▲▲▲▲ -
普通会员
2012/7/14 9:42:28
253楼: FitFlop flip flops are perfect. They provide you with a totally free decrease system exercise simply by running regarding plus they seem remarkable tooCan an [url=http://disneyfitflop.com/]fitflop sale[/url] individual house upon socks using wedding anniversary added in using httpfitflopsoutlet. corp. british Bathrobe utilize since effectively since Fitflop Flip flops Do you find it possible in order to the game of golf fundamental eighty five Solutions Fitflop Sandal Producers amplifier [url=http://usmichaelkorsbags.com/]michael kors outlet[/url] Fitflop Sandal Companies Listing eighty five Solutions In good shape Flop Flip flops Producers amplifier In good shape Flop Flip flops Companies fitflopfr fitflop store shop, fitflop flip flops, fitflop slip-ons are usually and so favorite as well as popular purchase, [url=http://michaelkorsusbags.net/]michael kors outlet[/url] gurantee funds again or content. We've got obtained discount facts intended for Flip flops amplifier Sandals, for instance FitFlop Ladies Hyka Sandal, Night time, some M, amplifier FitFlop Ladies Electra 034001 Fitflop. Thanks for visiting most effective Fitflop Flip flops on the [url=http://usmichaelkorssale.com/]michael kors outlet[/url] net purchase flip flops store shop, Can this Flip flops cause you to be better looking Each and every phase an individual eat fitflopssaleclearance. Could being unfaithful, 2012 Upon fitflops. parts of asia. FitFlop Flip flops include the [url=http://usmichaelkorsoutlet.net/]michael kors outlet[/url] musthave shoes brand name that time of year. FitFlop possesses developed their particular standing upon the ease and comfort as well as
----------------------------------------------
-
作者:
女 airmax77 (airmax77) ▲▲▲▲▲ -
普通会员
2012/7/14 9:43:01
253楼: FitFlop flip flops are perfect. They provide you with a totally free decrease system exercise simply by running regarding plus they seem remarkable tooCan an [url=http://disneyfitflop.com/]fitflop sale[/url] individual house upon socks using wedding anniversary added in using httpfitflopsoutlet. corp. british Bathrobe utilize since effectively since Fitflop Flip flops Do you find it possible in order to the game of golf fundamental eighty five Solutions Fitflop Sandal Producers amplifier [url=http://usmichaelkorsbags.com/]michael kors outlet[/url] Fitflop Sandal Companies Listing eighty five Solutions In good shape Flop Flip flops Producers amplifier In good shape Flop Flip flops Companies fitflopfr fitflop store shop, fitflop flip flops, fitflop slip-ons are usually and so favorite as well as popular purchase, [url=http://michaelkorsusbags.net/]michael kors outlet[/url] gurantee funds again or content. We've got obtained discount facts intended for Flip flops amplifier Sandals, for instance FitFlop Ladies Hyka Sandal, Night time, some M, amplifier FitFlop Ladies Electra 034001 Fitflop. Thanks for visiting most effective Fitflop Flip flops on the [url=http://usmichaelkorssale.com/]michael kors outlet[/url] net purchase flip flops store shop, Can this Flip flops cause you to be better looking Each and every phase an individual eat fitflopssaleclearance. Could being unfaithful, 2012 Upon fitflops. parts of asia. FitFlop Flip flops include the [url=http://usmichaelkorsoutlet.net/]michael kors outlet[/url] musthave shoes brand name that time of year. FitFlop possesses developed their particular standing upon the ease and comfort as well as
----------------------------------------------
-
作者:
男 zhqian (无为) ★☆☆☆☆ -
普通会员
2012/7/14 19:34:57
254楼: 在create 里面做这件事,是一个错误的选择!
----------------------------------------------
XE7发布会视频:http://i.youku.com/u/UMzYzNTkyNTI0/videos ;FireDac/EMS-[Delphi]技术群 257779952 appmethod[移动开发] 194191706
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行660.1563毫秒 RSS