关于MessageDlg的问题!(20分)

  • 主题发起人 主题发起人 wing_sky
  • 开始时间 开始时间
W

wing_sky

Unregistered / Unconfirmed
GUEST, unregistred user!
我怎样能把MessageDlg里的标题改为中文的?<br>比如:我用 MessageDlg('是否保存?',mtinformation,[mbok],0);<br>就会出来一个消息框,而标题栏却是information,我能否把它改成中文的?
 
用Messagebox就行了.
 
用 MessageBox 吧<br>MessageBox(Handle,'是否保存?','提示',MB_ICONQUESTION+MB_YESNO);<br>详细说明看帮助<br>
 
你可以用 &nbsp; Application.MessageBox()<br>要不然,你得进行资源的汉化了...
 
用MessageBox只能应付消息之类的显示,但如果我用mtConfirmation这样需要有多项选择的<br>就不行了,能否就在MessageDlg的基础上汉化?
 
你可以修改consts.pas,它存放Dephi的一些常量<br>在consts.pas中查找以下内容: <br>"SMsgDlgWarning" <br>把 <br>SMsgDlgWarning = 'Warning'; <br>SMsgDlgError = 'Error'; <br>SMsgDlgInformation = 'Information'; <br>SMsgDlgConfirm = 'Confirm'; <br>SMsgDlgYes = '&amp;Yes'; <br>SMsgDlgNo = '&amp;No'; <br>SMsgDlgOK = 'OK'; <br>SMsgDlgCancel = 'Cancel'; <br>SMsgDlgHelp = '&amp;Help'; <br>SMsgDlgHelpNone = 'No help available'; <br>SMsgDlgHelpHelp = 'Help'; <br>SMsgDlgAbort = '&amp;Abort'; <br>SMsgDlgRetry = '&amp;Retry'; <br>SMsgDlgIgnore = '&amp;Ignore'; <br>SMsgDlgAll = '&amp;All'; <br>SMsgDlgNoToAll = 'N&amp;o to All'; <br>SMsgDlgYesToAll = 'Yes to &amp;All'; <br>改成 <br>SMsgDlgWarning = '警告'; <br>SMsgDlgError = '错误'; <br>SMsgDlgInformation = '提示'; <br>SMsgDlgConfirm = '确认'; <br>SMsgDlgYes = '是(&amp;Y)'; <br>SMsgDlgNo = '不(&amp;N)'; <br>SMsgDlgOK = '确定'; <br>SMsgDlgCancel = '取消'; <br>SMsgDlgHelp = '帮助(&amp;H)'; <br>SMsgDlgHelpNone = '没有该帮助信息'; <br>SMsgDlgHelpHelp = '帮助'; <br>SMsgDlgAbort = '放弃(&amp;A)'; <br>SMsgDlgRetry = '重试(&amp;R)'; <br>SMsgDlgIgnore = '忽略(&amp;I)'; <br>SMsgDlgAll = '全部(&amp;A)'; <br>SMsgDlgNoToAll = '全都不(&amp;O)'; <br>SMsgDlgYesToAll = '全都是(&amp;A)'; <br>然后重新编译Consts.pas,把Consts.duc 拷到delphi的lib子目录下,就完事了<br><br><br><br><br><br>  对广大的编程爱好者来说,最尴尬的事莫过于在执行自己编写的中文软件时却弹出一条英文的提示信息。本文介绍一种快速简便的方法,对Delphi中的系统提示信息进行汉化。<br>  在Delphi中,定义系统资源字符串常量的源文件(.pas)都放在了Delphi安装目录的/Source目录下,并按其类别分布在几个子目录中,而其编译后的单元文件(.dcu)则全部放在Delphi安装目录的/Lib目录中,系统编译链接应用程序时会自动从这些单元文件中找到所需的字符串常量将其替换。因此,我们只要将/Source目录下的源文件中的提示信息字符串汉化后,编译成单元文件,再将该单元文件拷贝到/Lib目录中,覆盖原先的单元文件就可以达到汉化的目的。我们需要汉化某条提示信息时,找到包含该提示信息的源文件,将该提示信息字符串汉化就可以了。<br>  首先,在Delphi中建立一个新的项目,该项目中会自动包含一个名为Unit1的窗体文件,将其从项目中移去。然后从菜单中选择Project→Options,在弹出的Project Options对话框中,选择Directories/Conditionals标签,其中的Unit output directory文本框可以指定项目编译后单元文件的存放路径,在这里填上/Lib目录的完整路径,在笔者的系统中该路径为C:/Program Files/Borland/Delphi5/lib。最后将该项目文件存盘,并取名为HanHua.dpr。至此,这个用于汉化的项目文件就建立起来了,那么,怎么利用这个项目文件开始工作呢?下面,我就用一个实例来说明其使用的方法。<br>  在用Delphi编制某应用软件时,软件编译后,在运行时出现提示信息“Delete record?”,其汉化的步骤如下:<br>  1.在Delphi中打开项目文件HanHua.dpr。<br>  2.选择菜单Search→Find in Files,在弹出的对话框中,在Text to find:文本框里输入要查找的文本,在这里我们输入“Delete record?”,然后在Where组件框里选中Search in directories,并在Search Directory Options中输入/Source目录的完整路径,在我的系统中该路径为C:/Program Files/Borland/Delphi5/Source,最后别忘了将Include subdirectories选中,单击“OK”按钮开始查找。<br>  3.在代码编辑器底部会新增一个窗口,显示出所有包含你所要查找的文本的文件,在这个例子中,只找到一个文件,显示“C:/Program Files/Borland/Delphi5/Source/Vcl/dbconsts.pas(100):SDeleteRecordQuestion='Delete record?';”,双击可以打开该文件,系统会自动将光标移到“Delete record?”前面,将其改为“删除记录?”。<br>  4.选择菜单Project→Add to Project,在弹出的对话框中,系统会自动将当前打开的文件(这里为consts.pas.db 和consts.pas)作为默认打开文件,可以直接单击“打开”按钮将其添加到项目中。<br>  5.编译项目HanHua.dpr。<br>  最后,我们只要把前面的应用软件重新编译一次,其提示信息“Delete record?”就变成了“删除记录?”。怎么样,用这种方法进行汉化是不是又快又准?不过,因为我们是直接在系统目录中对源文件进行修改,有两个方面还存在一点问题,其一,如果在修改过程中出现错误,就找不到可以参照的源文件了;其二,重装Delphi后,所有的汉化结果就全部没有了。所以我们还需要对上面的汉化过程作一点改进,其实,我们只要在上面第3步和第4步之间增加下面这个步骤就可以了:<br>  选择菜单File→Save As,在弹出的对话框中,将文件换名存盘到别的目录中。<br>  在增加上面这个步骤后,前面提到的两个问题都得到了解决:系统源文件没有被修改,修改后的文件都放在了我们自己的目录中;重装Delphi后,只要重新编译项目HanHua.dpr就可以将以前汉化过的系统提示信息重新汉化。<br>
 
怎么会不行,看过帮助后再说吧<br><br>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. <br><br>int MessageBox(<br><br>&nbsp; &nbsp; HWND hWnd, // handle of owner window<br>&nbsp; &nbsp; LPCTSTR lpText, // address of text in message box<br>&nbsp; &nbsp; LPCTSTR lpCaption, // address of title of message box &nbsp;<br>&nbsp; &nbsp; UINT uType // style of message box<br>&nbsp; &nbsp;); <br>&nbsp;<br><br>Parameters<br><br>hWnd<br><br>Identifies the owner window of the message box to be created. If this parameter is NULL, the message box has no owner window. <br><br>lpText<br><br>Points to a null-terminated string containing the message to be displayed. <br><br>lpCaption<br><br>Points to a null-terminated string used for the dialog box title. If this parameter is NULL, the default title Error is used. <br><br>uType<br><br>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. <br>Specify one of the following flags to indicate the buttons contained in the message box:<br><br>Flag Meaning<br>MB_ABORTRETRYIGNORE The message box contains three push buttons: Abort, Retry, and Ignore.<br>MB_OK The message box contains one push button: OK. This is the default.<br>MB_OKCANCEL The message box contains two push buttons: OK and Cancel.<br>MB_RETRYCANCEL The message box contains two push buttons: Retry and Cancel.<br>MB_YESNO The message box contains two push buttons: Yes and No.<br>MB_YESNOCANCEL The message box contains three push buttons: Yes, No, and Cancel.<br>&nbsp;<br><br>Specify one of the following flags to display an icon in the message box:<br><br>Flag Meaning<br>MB_ICONEXCLAMATION, <br>MB_ICONWARNING<br> An exclamation-point icon appears in the message box.<br>MB_ICONINFORMATION, MB_ICONASTERISK<br> An icon consisting of a lowercase letter i in a circle appears in the message box.<br>MB_ICONQUESTION A question-mark icon appears in the message box.<br>MB_ICONSTOP, <br>MB_ICONERROR, <br>MB_ICONHAND<br> A stop-sign icon appears in the message box.<br>&nbsp;<br><br>Specify one of the following flags to indicate the default button:<br><br>Flag Meaning<br>MB_DEFBUTTON1 The first button is the default button. MB_DEFBUTTON1 is the default unless MB_DEFBUTTON2, MB_DEFBUTTON3, or MB_DEFBUTTON4 is specified.<br>MB_DEFBUTTON2 The second button is the default button.<br>MB_DEFBUTTON3 The third button is the default button.<br>MB_DEFBUTTON4 The fourth button is the default button.<br>&nbsp;<br><br>Specify one of the following flags to indicate the modality of the dialog box:<br><br>Flag Meaning<br>MB_APPLMODAL The user must respond to the message box before continuing work in the window identified by the hWnd parameter. However, the user can move to the windows of other applications and work in those windows. Depending on the hierarchy of windows in the application, the user may be able to move to other windows within the application. All child windows of the parent of the message box are automatically disabled, but popup windows are not.MB_APPLMODAL is the default if neither MB_SYSTEMMODAL nor MB_TASKMODAL is specified.<br>MB_SYSTEMMODAL Same as MB_APPLMODAL except that the message box has the WS_EX_TOPMOST style. Use system-modal message boxes to notify the user of serious, potentially damaging errors that require immediate attention (for example, running out of memory). This flag has no effect on the user's ability to interact with windows other than those associated with hWnd.<br>MB_TASKMODAL Same as MB_APPLMODAL except that all the top-level windows belonging to the current task are disabled if the hWnd parameter is NULL. Use this flag when the calling application or library does not have a window handle available but still needs to prevent input to other windows in the current application without suspending other applications.
 
to htw<br>&nbsp;谢谢!你的帮助正是我所需要的!<br>to pihome<br>&nbsp; 不好意思,我也看了帮助,确实可以,但我不知道怎么取它按了哪一个按钮?MessageDle里面<br>怎么取我就知道,可在MessageBox里我该怎么获得它按了哪个键呢?<br><br>如MessageDlg里的:if MessageDlg('是否保存',mtConfirmation,[mbYes,mbNo],0)=mrYes then<br><br>分我就先给了,也希望pihome能帮我解答上面的问题!谢谢!分少了点!呵呵!<br>
 
比如说 MB_OKCANCEL<br>if MessageBox(...)=(ID_OK,IDOK,mrOK中的作一个,都是一样的值) then<br>&nbsp; DoSomething;<br><br>Windows.pas声明如下:<br>&nbsp; { Dialog Box Command IDs }<br>&nbsp; {$EXTERNALSYM IDOK}<br>&nbsp; IDOK = 1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ID_OK = IDOK;<br>&nbsp; {$EXTERNALSYM IDCANCEL}<br>&nbsp; IDCANCEL = 2; &nbsp; &nbsp; &nbsp;ID_CANCEL = IDCANCEL;<br>&nbsp; {$EXTERNALSYM IDABORT}<br>&nbsp; IDABORT = 3; &nbsp; &nbsp; &nbsp; ID_ABORT = IDABORT;<br>&nbsp; {$EXTERNALSYM IDRETRY}<br>&nbsp; IDRETRY = 4; &nbsp; &nbsp; &nbsp; ID_RETRY = IDRETRY;<br>&nbsp; {$EXTERNALSYM IDIGNORE}<br>&nbsp; IDIGNORE = 5; &nbsp; &nbsp; &nbsp;ID_IGNORE = IDIGNORE;<br>&nbsp; {$EXTERNALSYM IDYES}<br>&nbsp; IDYES = 6; &nbsp; &nbsp; &nbsp; &nbsp; ID_YES = IDYES;<br>&nbsp; {$EXTERNALSYM IDNO}<br>&nbsp; IDNO = 7; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ID_NO = IDNO;<br>&nbsp; {$EXTERNALSYM IDCLOSE}<br>&nbsp; IDCLOSE = 8; &nbsp; &nbsp; &nbsp; ID_CLOSE = IDCLOSE;<br>&nbsp; {$EXTERNALSYM IDHELP}<br>&nbsp; IDHELP = 9; &nbsp; &nbsp; &nbsp; &nbsp;ID_HELP = IDHELP;<br>&nbsp; {$EXTERNALSYM IDTRYAGAIN}<br>&nbsp; IDTRYAGAIN = 10;<br>&nbsp; {$EXTERNALSYM IDCONTINUE}<br>&nbsp; IDCONTINUE = 11;<br>
 
后退
顶部