Avatar billede blomme Nybegynder
28. september 2001 - 13:39 Der er 4 kommentarer og
1 løsning

Messagedlg() syntax

Hej,

Da jeg sidder med min kode, men uden en version af Delphi til at hjælpe mig, mangler jeg syntaxen til messagedlg funktionen samt en minimal fortegnelse på hvad knapperne hedder. Jeg forsøger mig her -

if messagedlg(\'Vil du videre ?\', mtconfirmation, [mbyes, mbno],0) = mryes then showmessage(\'Du er videre\');

På forhånd, tak !
Avatar billede blomme Nybegynder
28. september 2001 - 13:40 #1
Det skal lige siges, at det jeg søger efter er ovenstående kode, compilet osv., dvs. fejlfri. Koden skal bare være uden fejl, da det ikke er mig, der skal compile den... :-)
Avatar billede morten_s Nybegynder
28. september 2001 - 13:41 #2
Fra hjælpe filen:

Displays a message dialog box in the center of the screen.

Unit

QDialogs

Category

dialog and message routines

function MessageDlg(const Msg: WideString; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons
; HelpCtx: Longint; DefaultBtn: TMsgDlgBtn = mbNone; Bitmap: TBitmap = nil): Integer; overload;
function MessageDlg(const Caption: WideString; const Msg: WideString; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint; DefaultBtn: TMsgDlgBtn = mbNone; Bitmap: TBitmap = nil): Integer; overload;

function MessageDlg(const Caption: WideString; const Msg: WideString; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint; X, Y: Integer; DefaultBtn: TMsgDlgBtn = mbNone; Bitmap: TBitmap = nil): Integer; overload;

function MessageDlg(const Caption: WideString; const Msg: WideString; DlgType: TMsgDlgType; Button1, Button2, Button3: TMsgDlgBtn; HelpCtx: Longint; X, Y: Integer; DefaultBtn: TMsgDlgBtn = mbNone; Bitmap: TBitmap = nil): Integer; overload;

Description

Call MessageDlg to bring up a message box and obtain the user\'s response.

Caption specifies the caption for the message box when DlgType is mtCustom. If this parameter is not used (the first syntax), the caption for custom message boxes is the title of the application.

Msg is the content of the message that appears.

DlgType indicates the purpose of the dialog.

Buttons indicates what buttons should appear in the message box. Note that if you want to use a three button message box, you can use the last syntax instead, and control the order in which the buttons appear.

Button1, Button2, and Button3 indicate what types of buttons to use for a three button message box. The resulting buttons appear in order.

HelpCtx specifies the context ID for the help topic that should appear when the user clicks the help button or presses F1 while the dialog is displayed.

X and Y specify the screen coordinates where the dialog should appear. A value of –1 means that the message box can appear anywhere in the specified dimension.

DefaultBtn specifies which button from among those specified by Buttons (or Button1, Button2, and Button3) is the default button for the dialog. If DefaultBtn is mbNone, there is no default button.

Bitmap is an image that appears on the face of the message dialog. If Bitmap is nil, there is no image unless DlgType is mtConfirmation.

MessageDlg returns the value of the button the user selected. The following table lists the TMsgDlgBtn values for each type of button that can appear in the message box, and the corresponding value that is returned if the user selects that button:

TMsgDlgBtn Value    Corresponding return value

mbOk    mrOk
mbCancel    mrCancel
mbYes    mrYes
mbNo    mrNo
mbAbort    mrAbort
mbRetry    mrRetry
mbIgnore    mrIgnore
Avatar billede morten_s Nybegynder
28. september 2001 - 13:42 #3
Eller endnu bedre fra VCL hjælpe filen

Displays a message dialog box in the center of the screen.

Unit

Dialogs

Category

dialog and message routines

function MessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint): Word;

Description

Call MessageDlg to bring up a message box and obtain the user\'s response.

Msg is the content of the message that appears.

DlgType indicates the purpose of the dialog.

Buttons indicates what buttons should appear in the message box.

HelpCtx specifies the context ID for the help topic that should appear when the user clicks the help button or presses F1 while the dialog is displayed.

MessageDlg returns the value of the button the user selected. The following table lists the TMsgDlgBtn values for each type of button that can appear in the message box, and the corresponding value that is returned if the user selects that button:

TMsgDlgBtn Value    Corresponding return value

mbOK    mrOk
mbCancel    mrCancel
mbYes    mrYes
mbNo    mrNo
mbAbort    mrAbort
mbRetry    mrRetry
mbIgnore    mrIgnore
mbAll    mrAll
mbNoToAll    mrNoToAll
mbYesToAll    mrYesToAll

Note:    If the user types Ctrl+C in the message box, the text of the message is copied to the clipboard.
Avatar billede morten_s Nybegynder
28. september 2001 - 13:44 #4
Er det dette diu søger ?

if MessageDlg(\'Vil du videre ?, mtConfirmation, [mbYes, mbNo], 0) = mrYes then
ShowMessage(\'Nu er du videre\');
Avatar billede morten_s Nybegynder
28. september 2001 - 13:45 #5
Eller et eksempel fra hjælpe filen

procedure TForm1.Button1Click(Sender: TObject);

begin
  if MessageDlg(\'Welcome to my Object Pascal application.  Exit now?\',
    mtConfirmation, [mbYes, mbNo], 0) = mrYes then
  begin
    MessageDlg(\'Exiting the Object Pascal application.\', mtInformation,
      [mbOk], 0);
    Close;
  end;

end;
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester