Solved

How to get the icon on the messagebox?

Posted on 2009-07-15
8
225 Views
Last Modified: 2012-05-07
Dear Experts,

I have put a picture of a messagebox of another application as attach.
I want to make the same messagbox for my application.
I got everything the same (see the procedure in the code-section) except for the icon.

How could I do that?

Greetings, Peter Kiers
procedure TForm1.DeleteButtonClick(Sender: TObject); var

   node : TTreeNode;

   mess, str : string;

   key_stat : integer;

begin

    Node := Treeview1.Selected;

    if Assigned(Node) then

       begin

       str := Node.Text;

       mess := 'Are you sure that you want to delete the';

       Case Node.ImageIndex of

         15 : mess := mess + ' folder ' + '"' + str + '"?' +#13+

                     'All folders, subfolders, items and subitems will be permanently' +#13+ 'deleted.' +#13;

         17 : mess := mess + ' item ' + '"' + str + '"?' + #13;

       end;

       with Application do

         begin

         NormalizeTopMosts;

         key_stat := MessageBox(pchar(mess), 'Confirm Deletion', MB_YESNO);

         RestoreTopMosts;

       end;

       if key_stat = 7 then  Exit;

       TreeView1.Items.Delete(Treeview1.Selected);

       end

    else ShowMessage('Select a folder in the treeview first.'); 

end;

Open in new window

0
Comment
Question by:peterkiers
  • 5
  • 3
8 Comments
 
LVL 1

Author Comment

by:peterkiers
ID: 24866691
forgot the picture.
Example1.bmp
0
 
LVL 6

Expert Comment

by:FactorB
ID: 24867081
Use Message Dialog instead

MessageDlg('Confirm Deletion', mtInformation, mbYesNo, 0)

Regards,
B.
0
 
LVL 6

Accepted Solution

by:
FactorB earned 500 total points
ID: 24867152
No, better use MessageBox API function and change it this way,

key_stat := MessageBox(0, PChar(mess), PChar('Confirm Deletion'), MB_YESNO + MB_ICONINFORMATION);

Regards,
B.
0
 
LVL 1

Author Comment

by:peterkiers
ID: 24867160
I guess i have to change:
key_stat := MessageBox(pchar(mess), 'Confirm Deletion', MB_YESNO);

into:

key_stat := MessageDlg <====could you help me with the rest?

Greetings, Peter Kiers

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:peterkiers
ID: 24867189
I get error message:

Incompatible types: integer and PAnsiChar

PK.
0
 
LVL 1

Author Comment

by:peterkiers
ID: 24867228
I have made this, is this good programming because it sure works.

key_stat := MessageBox(pchar(mess), 'Confirm Deletion', MB_YESNO + MB_ICONIFORMATION);

Peter
0
 
LVL 1

Author Comment

by:peterkiers
ID: 24867250
FactorB: 500 points comming your way...

Greetings
Peter Kiers
0
 
LVL 6

Expert Comment

by:FactorB
ID: 24867263
yes it is works for me too, later you can use

key_stat := MessageBox(0, PChar(mess), PChar('Confirm Deletion'), MB_YESNO + MB_ICONINFORMATION);

if key_stat=7 then Exit; {7=NO}
if key_stat=6 then TreeView1.Items.Delete(Treeview1.Selected); {6=YES}

Thanks, hope it helped,
B.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now