到底用什么来showmessage? showmessage就不用说了,功能太差messagebox不能显示位图messagedlg又不好改变标题我既要自定标题,又要显示位图(就是惊叹号、问号之类的),应该怎么写?另外,怎么把按钮上的yes,no改成中文的是、否 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Application.MessageBox('显示图标','提示',MB_OK+MB_ICONWARNING); MB_OK+MB_ICONINFORMATION:提示信息图标MB_ICONWARNING:警告图标还有几个,想不起来了 这不一样吗?还不是调用API MessageBox,用Application.Hanlde作为句柄!方法只有三类:1.直接调用API2.使用VCL中封装的窗体3.自定义窗体前两种不能满足你要求时只能用第三种! 怎么会一样那,我们要多利用delphi提供的功能,这样可以提高开发效率 你可以用messagedlg来显示中文,前天我刚试过的。如果你想改一改的话可以这样做。在delphi中的消息框都是在一个叫consts.pas单元里面定义的。首先新建一个项目,新建一个单元。然后打开上面的consts.pas在c:\borland\delphi7\source\vcl\consts.pas找出如下几个定义的。 SMsgDlgWarning = 'Warning'; SMsgDlgError = 'Error'; SMsgDlgInformation = 'Information'; SMsgDlgConfirm = 'Confirm'; SMsgDlgYes = '&Yes'; SMsgDlgNo = '&No'; SMsgDlgOK = 'OK'; SMsgDlgCancel = 'Cancel'; SMsgDlgHelp = '&Help'; SMsgDlgHelpNone = 'No help available'; SMsgDlgHelpHelp = 'Help'; SMsgDlgAbort = '&Abort'; SMsgDlgRetry = '&Retry'; SMsgDlgIgnore = '&Ignore'; SMsgDlgAll = '&All'; SMsgDlgNoToAll = 'N&o to All'; SMsgDlgYesToAll = 'Yes to &All';然后改成 SMsgDlgWarning = '警告';之后的都一样改成你喜欢的文字就行了只要你喜欢的。如:SMsgDlgYes = '&中‘; SMsgDlgNo = '&不中';呵呵你自己决定吧。改完之后,你要把这个单元的内容全部考到你刚才新建的那个单元里,并且命名为consts.pas然后关掉这个单元。并且编译刚才那个已经考好的单元,记住一定是单元名为consts呀。这时在你保存的那个目录下有一个consts.dcu.你把这个文件考到lib目录下替换掉就可以了。然后你在使用messagedlg时还用英文的提示,但是程序显示的就是你刚才自己改的文字。爽吧!试一试吧。 直接用MessageBox开发效率就低了?MessageBox(Application.Handle,'显示图标','提示',MB_OK+MB_ICONWARNING);感觉不出来!:(Application.MessageBox('显示图标','提示',MB_OK+MB_ICONWARNING);好像也没多多少!而且用当前窗体的句柄也可以!MessageBox(Form.Handle,'显示图标','提示',MB_OK+MB_ICONWARNING);如果不想用模式化窗体,还就只能MessageBox(0,'显示图标','提示',MB_OK+MB_ICONWARNING); to ehom(?!) :你自己看不出来哪个更简单一点吗 MessageBox(Handle,'显示图标','提示',MB_OK+MB_ICONWARNING);Application.MessageBox('显示图标','提示',MB_OK+MB_ICONWARNING);比什么,代码长度?我的更短!而且用Application.MessageBox还不能产生非模式窗体!这样的比较有意义吗?本来就一样,想怎么用就怎么用,和开发效率没关系! 呵呵~~~我可不是什么高手!不争啦,不过错误还是要纠正,使用Application.MessageBox还是要调用API MessageBoxfunction TApplication.MessageBox(const Text, Caption: PChar; Flags: Longint): Integer;var ActiveWindow: HWnd; WindowList: Pointer; MBMonitor, AppMonitor: HMonitor; MonInfo: TMonitorInfo; Rect: TRect; FocusState: TFocusState;begin ActiveWindow := GetActiveWindow; MBMonitor := MonitorFromWindow(ActiveWindow, MONITOR_DEFAULTTONEAREST); AppMonitor := MonitorFromWindow(Handle, MONITOR_DEFAULTTONEAREST); if MBMonitor <> AppMonitor then begin MonInfo.cbSize := Sizeof(TMonitorInfo); GetMonitorInfo(MBMonitor, @MonInfo); GetWindowRect(Handle, Rect); SetWindowPos(Handle, 0, MonInfo.rcMonitor.Left + ((MonInfo.rcMonitor.Right - MonInfo.rcMonitor.Left) div 2), MonInfo.rcMonitor.Top + ((MonInfo.rcMonitor.Bottom - MonInfo.rcMonitor.Top) div 2), 0, 0, SWP_NOACTIVATE or SWP_NOREDRAW or SWP_NOSIZE or SWP_NOZORDER); end; WindowList := DisableTaskWindows(0); FocusState := SaveFocusState; if UseRightToLeftReading then Flags := Flags or MB_RTLREADING; try Result := Windows.MessageBox(Handle, Text, Caption, Flags);//这里 finally if MBMonitor <> AppMonitor then SetWindowPos(Handle, 0, Rect.Left + ((Rect.Right - Rect.Left) div 2), Rect.Top + ((Rect.Bottom - Rect.Top) div 2), 0, 0, SWP_NOACTIVATE or SWP_NOREDRAW or SWP_NOSIZE or SWP_NOZORDER); EnableTaskWindows(WindowList); SetActiveWindow(ActiveWindow); RestoreFocusState(FocusState); end;end;看到了Result := Windows.MessageBox(Handle, Text, Caption, Flags);吗?再加上其它API的调用,设置类代码,比直接使用API的时间执行"长"多了!当然这点时间完全可以忽略不计! 另外,怎么把按钮上的yes,no改成中文的是、否MessageboxEx函数的最后一个参数是Language,查查帮助就知道了。 求高手C转delphi 在线等 现在delphi2006中用fastreport的都在用什么版本的?有个免费下载链接就更好了,谢谢先!~ 求intraweb8.0.22 for delphi7的序列号 请问如何让用户选择一个目录 用一条sql语句怎样才能找出不重复记录的所有数据? 字体的问题,急,急! 35岁后程序员该怎么养活自己? format()的用法 各位帮手,如果实现类似windows任务栏的自动隐藏功能. 为什么在DLL中用IS判断从EXE主程序中传进来的对象类型失败了? 如何动态定义这样类型的长度? 请教:在使用Treeview时,已知某一节点,如何知道它的父节点是那一个!!!
MB_ICONWARNING:警告图标
还有几个,想不起来了
2.使用VCL中封装的窗体
3.自定义窗体前两种不能满足你要求时只能用第三种!
SMsgDlgWarning = 'Warning';
SMsgDlgError = 'Error';
SMsgDlgInformation = 'Information';
SMsgDlgConfirm = 'Confirm';
SMsgDlgYes = '&Yes';
SMsgDlgNo = '&No';
SMsgDlgOK = 'OK';
SMsgDlgCancel = 'Cancel';
SMsgDlgHelp = '&Help';
SMsgDlgHelpNone = 'No help available';
SMsgDlgHelpHelp = 'Help';
SMsgDlgAbort = '&Abort';
SMsgDlgRetry = '&Retry';
SMsgDlgIgnore = '&Ignore';
SMsgDlgAll = '&All';
SMsgDlgNoToAll = 'N&o to All';
SMsgDlgYesToAll = 'Yes to &All';
然后改成 SMsgDlgWarning = '警告';之后的都一样改成你喜欢的文字就行了只要你喜欢的。如:SMsgDlgYes = '&中‘;
SMsgDlgNo = '&不中';呵呵你自己决定吧。
改完之后,你要把这个单元的内容全部考到你刚才新建的那个单元里,并且命名为consts.pas
然后关掉这个单元。并且编译刚才那个已经考好的单元,记住一定是单元名为consts呀。这时在你保存的那个目录下有一个consts.dcu.你把这个文件考到lib目录下替换掉就可以了。然后你在使用messagedlg时还用英文的提示,但是程序显示的就是你刚才自己改的文字。
爽吧!试一试吧。
MessageBox(Form.Handle,'显示图标','提示',MB_OK+MB_ICONWARNING);如果不想用模式化窗体,还就只能
MessageBox(0,'显示图标','提示',MB_OK+MB_ICONWARNING);
var
ActiveWindow: HWnd;
WindowList: Pointer;
MBMonitor, AppMonitor: HMonitor;
MonInfo: TMonitorInfo;
Rect: TRect;
FocusState: TFocusState;
begin
ActiveWindow := GetActiveWindow;
MBMonitor := MonitorFromWindow(ActiveWindow, MONITOR_DEFAULTTONEAREST);
AppMonitor := MonitorFromWindow(Handle, MONITOR_DEFAULTTONEAREST);
if MBMonitor <> AppMonitor then
begin
MonInfo.cbSize := Sizeof(TMonitorInfo);
GetMonitorInfo(MBMonitor, @MonInfo);
GetWindowRect(Handle, Rect);
SetWindowPos(Handle, 0,
MonInfo.rcMonitor.Left + ((MonInfo.rcMonitor.Right - MonInfo.rcMonitor.Left) div 2),
MonInfo.rcMonitor.Top + ((MonInfo.rcMonitor.Bottom - MonInfo.rcMonitor.Top) div 2),
0, 0, SWP_NOACTIVATE or SWP_NOREDRAW or SWP_NOSIZE or SWP_NOZORDER);
end;
WindowList := DisableTaskWindows(0);
FocusState := SaveFocusState;
if UseRightToLeftReading then Flags := Flags or MB_RTLREADING;
try
Result := Windows.MessageBox(Handle, Text, Caption, Flags);//这里
finally
if MBMonitor <> AppMonitor then
SetWindowPos(Handle, 0,
Rect.Left + ((Rect.Right - Rect.Left) div 2),
Rect.Top + ((Rect.Bottom - Rect.Top) div 2),
0, 0, SWP_NOACTIVATE or SWP_NOREDRAW or SWP_NOSIZE or SWP_NOZORDER);
EnableTaskWindows(WindowList);
SetActiveWindow(ActiveWindow);
RestoreFocusState(FocusState);
end;
end;看到了Result := Windows.MessageBox(Handle, Text, Caption, Flags);吗?再加上其它API的调用,设置类代码,比直接使用API的时间执行"长"多了!当然这点时间完全可以忽略不计!