各位帮帮我!关于InputBox!

yundou 2002-06-13 09:09:38
我使用了一个InputBox来输入一个加入到INI文件中的字串,但是如果你点击Cancel也能加入到INI文件中,我是想让使用者点击OK按钮后才写入INI文件,怎么办?
...全文
50 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
THE_ROCK 2002-07-07
  • 打赏
  • 举报
回复
我有一个控件包你满意!联系rock4342@163.com我发给你!
一点点凋落 2002-06-14
  • 打赏
  • 举报
回复
假如输入了几个字母再Cancel有判断吗?
还是根据你要得到的字符串做一些限制吧。
netlib 2002-06-13
  • 打赏
  • 举报
回复
你用的是d5还是d6,
我在d6下刚调试,可以的呀,没有问题。

如果d5不行的话,这样吧,你把最后一个参数设为' '
一个空格,如果用户按cancel,会反回这个空格
你在判断它是不是空格就行了。
chenjbjbjb 2002-06-13
  • 打赏
  • 举报
回复
to netlib(河外孤星)
mabey he must be uses default value
hammer_shi 2002-06-13
  • 打赏
  • 举报
回复
好像实现楼主的功能不了。
inputbox是一个调试函数,在帮助中也就:
function InputBox(const ACaption, APrompt, ADefault: string): string;
begin
Result := ADefault;
InputQuery(ACaption, APrompt, Result);
end;
根本没有判断返回的是yes还是no!
要不你自己做个dialog模块!









/*************************************/
/*1、MY TOOL:*************************/
/*2、Delphi,Oracle,Sybase,C++/C*******/
/*3、PROJECT:*************************/
/*3、Boss*****************************/
/*4、为了五星的目标希望你早点结贴*****/
/*************************************/
taidy 2002-06-13
  • 打赏
  • 举报
回复
procedure TForm1.Button1Click(Sender: TObject);
var T:TINIfile;
begin
T.Create('c:\test.ini');
if InputBox('Input Box', 'Prompt', '1') <>'1' then
T.WriteString('Section','Key','string maybe get from inputbox');
end;
chenjbjbjb 2002-06-13
  • 打赏
  • 举报
回复
Use the InputBox function when there is a default value that should be used when the user chooses the Cancel button (or presses Esc) to exit the dialog. If the application needs to know whether the user chooses OK or Cancel, use the InputQuery function instead.
-----
delphi的文档说你这种情况用InputQuery。

netlib 2002-06-13
  • 打赏
  • 举报
回复
var
InputString: string;
begin
InputString:= InputBox('Input Box', 'Prompt', '');
if inputstring <> '' then
begin
//do your things
end;
end;
THE_ROCK 2002-06-13
  • 打赏
  • 举报
回复
强烈关注!
knock 2002-06-13
  • 打赏
  • 举报
回复
var s: String;
if InputQuery('Caption','ss',S) then
begin
//............................
end;
这样就可以了啊
kuangning 2002-06-13
  • 打赏
  • 举报
回复
用Inputbox不好
因为界面很普通,按钮上还是英文的。不爽
不如自己做一个
Billy_Chen28 2002-06-13
  • 打赏
  • 举报
回复
inputadd:=Inputbox('增加字典对话框', '请输入字典名:','' );
if inputadd<>'' then
begin
票票飞扬 2002-06-13
  • 打赏
  • 举报
回复
var str: String;

if InputQuery('Caption','ss',Str) then
begin
............................
end;
surfguy 2002-06-13
  • 打赏
  • 举报
回复
我的D6调试了一下也可以

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧