日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

Delphi Inputbox,InputQuery用法

發(fā)布時(shí)間:2023/12/13 综合教程 30 生活家
生活随笔 收集整理的這篇文章主要介紹了 Delphi Inputbox,InputQuery用法 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Delphi :InputQuery,InputBox用法及區(qū)別

function InputQuery(const ACaption, APrompt: string; var Value: string): Boolean;
InputQuery返回值為是否點(diǎn)了OK 輸入的字符串放在了變量Value中

function InputBox(const ACaption, APrompt, ADefault: string): string;
inputBox返回值是字符串,也就是輸入的字符串

procedure TForm1.Button1Click(Sender: TObject);
var
s:string;
begin
//點(diǎn)擊了OK按鈕后,則
if InputQuery('標(biāo)題','提示字符',s) then
begin
if s<>'' then //如果輸入不為空則
showmessage(s);
end;

end;

procedure TForm1.Button2Click(Sender: TObject);
var
s:string;
begin
s:=InputBox('標(biāo)題','提示字符',s);
if s<>'' then
showmessage(s);
end;

Delphi通過自定義消息自定義Inputbox,使其支持掩碼并修改按鈕的caption

首先自定義一個(gè)消息ID

const
InputBoxMessage = WM_USER + 200;

接著聲明并實(shí)現(xiàn)該消息的處理過程

procedure InputBoxSetPasswordChar(var Msg: TMessage); message InputBoxMessage;//聲明

procedure Tfrm.InputBoxSetPasswordChar(var Msg: TMessage);//實(shí)現(xiàn)
var
hInputForm, hEdit, hButton: HWND;
begin
hInputForm := Screen.Forms[0].Handle;
if (hInputForm <> 0) then
begin
hEdit := FindWindowEx(hInputForm, 0, 'TEdit', nil);
SendMessage(hEdit, EM_SETPASSWORDCHAR, Ord('*'), 0);
// Change button text:
hButton := FindWindowEx(hInputForm, 0, 'TButton', 'Cancel');
SendMessage(hButton, WM_SETTEXT,0, Integer(PChar('取消')));
hButton := FindWindowEx(hInputForm, 0, 'TButton', 'OK');
SendMessage(hButton, WM_SETTEXT,0, Integer(PChar('確定')));
end;
end;

使用自定義后的InputBox

PostMessage(Handle, InputBoxMessage, 0, 0);
InputBox('請?jiān)O(shè)置解鎖密碼','請?jiān)O(shè)置解鎖密碼(不能為空):','');

總結(jié)

以上是生活随笔為你收集整理的Delphi Inputbox,InputQuery用法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。