Link to home
Start Free TrialLog in
Avatar of Peter Kiers
Peter KiersFlag for Netherlands

asked on

How to get the icon on the messagebox?

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

Avatar of Peter Kiers
Peter Kiers
Flag of Netherlands image

ASKER

forgot the picture.
Example1.bmp
Avatar of FactorB
FactorB

Use Message Dialog instead

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

Regards,
B.
ASKER CERTIFIED SOLUTION
Avatar of FactorB
FactorB

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

I get error message:

Incompatible types: integer and PAnsiChar

PK.
I have made this, is this good programming because it sure works.

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

Peter
FactorB: 500 points comming your way...

Greetings
Peter Kiers
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.