procedure msg(text:string;caption:string=application.title;icon:integer=mb_iconinformation); begin MessageBox(application.handle,text,title,mb_ok+icon); end;
function msgdlg(msg:string;buttons:integer=-2;micon:integer=-4;defaultbutton:integer=-1;tit:string='#0';dlgtype:integer=0):integer; begin if buttons=-1 then buttons:=mb_ok; if buttons=-2 then buttons:=mb_yesno; if buttons=-3 then buttons:=mb_yesnocancel;if micon=-1 then micon:=MB_ICONWARNING; if micon=-2 then micon:=MB_ICONERROR; if micon=-3 then micon:=MB_ICONINFORMATION; if micon=-4 then micon:=MB_ICONQUESTION;if tit='#0' then tit:=application.Title;if defaultbutton=-1 then defaultbutton:=MB_DEFBUTTON1; if defaultbutton=-2 then defaultbutton:=MB_DEFBUTTON2; if defaultbutton=-3 then defaultbutton:=MB_DEFBUTTON3; if defaultbutton=-4 then defaultbutton:=MB_DEFBUTTON4;result:=messagebox(application.Handle,pchar(msg),pchar(tit),buttons+micon+defaultbutton+dlgtype); end; //////////////////////
Project\Add to project\选择\Borland\Delphi5\Source\Vcl\consts.pas
按F9键运行
找\Borland\Delphi5\Source\Vcl\consts.dcu文件
拷贝到\Borland\Delphi5\lib目录下即可。
会生成一个.DCU文件,不是.duc
覆盖原来的,(在Lib目录下)
很多人都喜欢用MessageDlg来显示信息,于是就对其英文显示的按钮大改特改。我不明白为什么不用Application.Message,它可是会随着Windows的版本自动改变语言的呀!!!而且使用和MessageDlg一样简单,根本就不需要修改什么!
这样api编译起来也小。
自己写msg函数加上默认参数有多长?
你不识字还不识数吗??
begin
MessageBox(application.handle,text,title,mb_ok+icon);
end;
begin
if buttons=-1 then buttons:=mb_ok;
if buttons=-2 then buttons:=mb_yesno;
if buttons=-3 then buttons:=mb_yesnocancel;if micon=-1 then micon:=MB_ICONWARNING;
if micon=-2 then micon:=MB_ICONERROR;
if micon=-3 then micon:=MB_ICONINFORMATION;
if micon=-4 then micon:=MB_ICONQUESTION;if tit='#0' then tit:=application.Title;if defaultbutton=-1 then defaultbutton:=MB_DEFBUTTON1;
if defaultbutton=-2 then defaultbutton:=MB_DEFBUTTON2;
if defaultbutton=-3 then defaultbutton:=MB_DEFBUTTON3;
if defaultbutton=-4 then defaultbutton:=MB_DEFBUTTON4;result:=messagebox(application.Handle,pchar(msg),pchar(tit),buttons+micon+defaultbutton+dlgtype);
end;
//////////////////////