Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to change the default button in a MessageDlg Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
30-Aug-02
Category
Dialogs
Language
Delphi 2.x
Views
94
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How to change the default button in a MessageDlg

Answer:
1   
2   function DefMessageDlg(const aCaption: string; const Msg: string; DlgType: 
3   TMsgDlgType;
4     Buttons: TMsgDlgButtons; DefButton: Integer; HelpCtx: Longint): Integer;
5   var
6     i: Integer;
7     btn: TButton;
8   begin
9     with CreateMessageDialog(Msg, DlgType, Buttons) do
10    try
11      Caption := aCaption;
12      HelpContext := HelpCtx;
13      for i := 0 to ComponentCount - 1 do
14      begin
15        if Components[i] is TButton then
16        begin
17          btn := TButton(Components[i]);
18          btn.default := btn.ModalResult = DefButton;
19          if btn.default then
20            ActiveControl := Btn;
21        end;
22      end;
23      Result := ShowModal;
24    finally
25      Free;
26    end;
27  end;
28  
29  procedure TForm1.Button2Click(Sender: TObject);
30  begin
31    if DefMessageDlg('Please confirm', 'Do you want to format your harddisk now?', 
32  mtConfirmation, mbYesNoCancel, mrno, 0) = mrYes then
33      ShowMessage('Formatting disk...');
34  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC