TBitmap, custom dialog

How do you make a custom dialog?
I tried this but it doesn't work (There is no overloaded function of MessageDlg can be called with these arguments)

uses QDialogs
var myBmp: TBitmap;
  myBmp := TBitmap.Create;
  if (MessageDlg('Caption','Message',
                 mtCustom,mbOkCancel,0,mbNone,myBmp) <> mrOk) then
      // do stuffs

where do I do wrong?
when i change myBmp to nil, it works

Thank you
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

currently i do not have the syntax on hand,
but i guess instead of

myBmp -> myBmp.handle must set

meikl ;-)
It correctly works with nil because that is the default value for the function for the bitmap

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;

Bitmap is an image that appears on the face of the message dialog. If Bitmap is nil (Delphi) or NULL (C++), there is no image unless DlgType is mtConfirmation.
Pierre CorneliusCommented:
Your problem is probably that in your uses list you are using the Grpahics list instead of the QGraphics unit. i.e. the bitmap you are using is of type Graphics.TBitmap and not QGraphics.TBitmap as is required by the function.

Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Also I would change from using mtCustom dialog type to mtConfirmation as I noticed with a couple of my images it makes the background transparent
HardiAuthor Commented:
Thanks all

I just noticed that the values of button clicked (the result given a button is clicked) differs between Dialogs and QDialogs.
Using QDialogs makes all the other MessageDlg functions (that previously used Dialogs) misbehave.
PierreC may be right...

So... my question is still:
How do you make a custom dialog? (with custom image)
without messing up the existing MessageDlg functions (that use Dialogs)
Pierre CorneliusCommented:
You must specify which type of bitmap you are using. i.e. for the "dialogs.MessageDlg" use function use the "Graphics.TBitmap" type and for the "QDialogs.MessageDlg" function use "QGraphics.TBitmap"


  Bmp: Graphics.TBitmap;
  qBmp: QGraphics.TBitmap;
  bmp:= Graphics.TBitmap.Create;
  qbmp:= QGraphics.TBitmap.Create;

    if (Dialogs.MessageDlg('Caption','Message',
                 mtCustom,mbOkCancel,0,mbNone,Bmp) <> mrOk) then ;
    if (QDialogs.MessageDlg('Caption','Message',
                 mtCustom,mbOkCancel,0,mbNone,qBmp) <> mrOk) then ;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HardiAuthor Commented:
Thanks PierreC, i figured that earlier.
The problem is that Dialogs do not have that overloaded version of MessageDlg function (the one that can be called with TBitmap parameter)

It will give an error "Too many actual parameters" on:
    if (Dialogs.MessageDlg('Caption','Message',
                 mtCustom,mbOkCancel,0,mbNone,Bmp) <> mrOk) then ;

I am using Delphi 7. Does it work on yours?

I am trying not to use QDialogs, coz that means I have to change all the other MessageDlg functions to Dialogs.MessageDlg.

Have you ever made a custom dialog with your own image? If so just paste the code here. It's what I need :-)
Pierre CorneliusCommented:
I see. I didn't realise the bitmap functionality was specific to the QDialogs unit. I thought the Dialogs unit also had it.

Why not just create a new form, set it's Borderstyle to bsDialog, drop a TImage on it and the buttons you need and voila.
HardiAuthor Commented:
Yea I've been using it. Can even add a string grid and background pic :-D
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.