Solved

How to get the icon on the messagebox?

Posted on 2009-07-15
8
224 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

747 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

13 Experts available now in Live!

Get 1:1 Help Now