一个对话框函数中文化的问题,大家请进(50分)

M

mylem

Unregistered / Unconfirmed
GUEST, unregistred user!
在Delphi中的MessageDlg函数显示的按钮如mbOK等只能显示Yes这样的英文,我在开发一个中文
版的程序,希望把对话框中显示中文,如按钮上显示"确定"取消"等,用什么办法解决呢?
 
用api函数了
不然该messagedlg的代码,我改过
改完之和要把文件放到lib里面
 
用哪个API呢?是messagebox吗?它的功能好像没有messagedlg强大。改messagedlg的代码
怎么改,具体点。
 
application.messagebox()
 
把Borland/Delphi5/Source/Vcl下的Consts.pas文件用记事本打开,找到有关Messagedlg的部分
把有关的变量值改为中文即可,不过最好先备份Consts.pas文件。另外在编译程序时,要在
Project Options对话框中设置搜索路径为Borland/Delphi5/Source/Vcl.
 
procedure TForm1.Button2Click(Sender: TObject);
var
MsgDialog: TForm;
pt: TPoint;
btns: array[0..2] of TButton;
c: integer;
begin
MsgDialog := CreateMessageDialog('Hi', mtInformation, [mbYes,mbYesToAll, mbNo]);
c := MsgDialog.ControlCount;

btns[0] := TButton(MsgDialog.Controls[c-1]);
btns[1] := TButton(MsgDialog.Controls[c-2]);
btns[2] := TButton(MsgDialog.Controls[c-3]);

pt := Point(btns[0].Left,btns[0].Top);

btns[0].SetBounds(btns[1].Left, btns[1].Top, btns[0].Width,btns[0].Height);
btns[1].SetBounds(btns[2].Left, btns[2].Top, btns[1].Width,btns[1].Height);
btns[2].SetBounds(pt.X, pt.Y, btns[2].Width, btns[2].Height);
btns[0].Caption := '我是第一个';
btns[1].Caption := '我是第二个';
btns[2].Caption := '我是第三个';
MsgDialog.ShowModal;
end;
 
application.messagebox绝对不比messagedlg的功能弱,你试试就知道了
 
应该用Messagebox函数来完成,不知道你所说的功能差别在哪里。
 
这个函数功能较弱,大家看看
The MessageBox function creates, displays, and operates a message box. The message box contains an application-defined message and title, plus any combination of predefined icons and push buttons.

int MessageBox(

HWND hWnd, // handle of owner window
LPCTSTR lpText, // address of text in message box
LPCTSTR lpCaption, // address of title of message box
UINT uType // style of message box
);


Parameters

hWnd

Identifies the owner window of the message box to be created. If this parameter is NULL, the message box has no owner window.

lpText

Points to a null-terminated string containing the message to be displayed.

lpCaption

Points to a null-terminated string used for the dialog box title. If this parameter is NULL, the default title Error is used.

uType

Specifies a set of bit flags that determine the contents and behavior of the dialog box. This parameter can be a combination of flags from the following groups of flags.
Specify one of the following flags to indicate the buttons contained in the message box:
 
可以用钩子,将它们统一改成中文。
 
还有messgaebox函数不两个定义:Delphi默认为
function MessageBox(const Text, Caption: PChar
Flags: Longint = MB_OK): Integer;

但我需要用:
function MessageBox(const Text: WideString
const Caption: WideString = ''
Buttons:
TMessageButtons) = [smbOK]
Style: TMessageStyle = smsInformation
Default:
TMessageButton) = smbOK
Escape: TMessageButton) = smbCancel): TMessageButton


这两个调用方式均为application.messagebox(....);
怎么办?
 
windows.MessageBox
Application.Messagebox
 
MessageBox API,很好用的,我一直用它。不然用sgs125的方法
 
为什么下面这条语句报错呢?
if application.messagebox('您的确要删除吗?','XXX系统',[smbOK,smbcancel],
smswarning,smbok)=smbok then

错误:
[Error] MANAGER.PAS(186): Undeclared identifier: 'smbOK'
[Error] MANAGER.PAS(186): Incompatible types: 'Integer' and 'Set'
[Error] MANAGER.PAS(186): Too many actual parameters
我该怎么改呢?
 
if application.messagebox('您的确要删除吗?','XXX系统',MB_OKCANCEL+MB_ICONWARNING)
IDOK then
 
if application.messagebox('您的确要删除吗?','XXX系统',MB_OKCANCEL+MB_ICONWARNING)=IDOK then
 
[:D]MessageBox!!!
 
多人接受答案了。
 
顶部