这样行不行,变态做法,因为你要点cancel的话,鼠标就要放到按钮上 if length(trim(passwordedit.text))<6 and 鼠标当前位置不在button的区域里面 then begin MessageDlg('Password length must greate 6l!',mtInformation,[mbOk],0); passwordedit.SetFocus; end
在程序中,对edit进行onexit判断,如: if ActiveControl<>"cancel按钮的名字" then exit //注意输入时不要引号哦 if length(trim(passwordedit.text))<6 then begin MessageDlg('Password length must greate 6l!',mtInformation,[mbOk],0); passwordedit.SetFocus; end
哦,错了, 应该为if ActiveControl="cancel按钮的名字" then exit;
你可以加一个变量password if password then begin if length(trim(passwordedit.text))<6 then begin MessageDlg('Password length must greate 6l!',mtInformation,[mbOk],0); passwordedit.SetFocus; password:=false; end end; 然后在passwordedit的onkeypress事件中把password:=true;
TO: CoolSlob(夕阳无限好,只是今黄昏----西下夕阳): if ActiveControl<>"cancel按钮的名字" then exit //注意输入时不要引号哦 其中<>要改为= 谢谢了
从用户使用角度,也许并不喜欢频繁的弹出对话框,放到最后统一的处理也许更好。
if length(trim(passwordedit.text))<6 and 鼠标当前位置不在button的区域里面 then
begin
MessageDlg('Password length must greate 6l!',mtInformation,[mbOk],0);
passwordedit.SetFocus;
end
if ActiveControl<>"cancel按钮的名字" then exit //注意输入时不要引号哦
if length(trim(passwordedit.text))<6 then
begin
MessageDlg('Password length must greate 6l!',mtInformation,[mbOk],0);
passwordedit.SetFocus;
end
应该为if ActiveControl="cancel按钮的名字" then exit;
if password then
begin
if length(trim(passwordedit.text))<6 then
begin
MessageDlg('Password length must greate 6l!',mtInformation,[mbOk],0);
passwordedit.SetFocus;
password:=false;
end
end;
然后在passwordedit的onkeypress事件中把password:=true;
if ActiveControl<>"cancel按钮的名字" then exit //注意输入时不要引号哦
其中<>要改为=
谢谢了