1

I have a main form (form1) that calls form2 which is a stayontop form. form2 calls a modal form (form3) which is also a stayontop form. when form3 modal form calls the colordialog, the color dialog opens behind form3.

What to set to open color dialog in front of form3?

I'm using D2009

thanks

Sertac Akyuz
  • 54,131
  • 4
  • 102
  • 169
user474079
  • 65
  • 2
  • 6
  • Have you installed Update 3 for Delphi 2009? If yes and still no go, then set `Application.ModalPopupMode` to `pmAuto` or `pmExplicit`. – Sertac Akyuz Apr 14 '11 at 17:41

1 Answers1

1

Delphi (around D2007) introduced an overloaded Execute methods for all of the standard dialogs that accept a parent window handle as a parameter. Change your call to display the dialog:

if ColorDialog1.Execute(Handle) then
begin
  // Do whatever
end;

Handle in this case would be the window handle of the stay on top form that's displaying the TColorDialog. If you're executing the dialog from another window, you'll need to pass the stay on top form's handle instead.

The documentation is here (XE version, but it still applies to D2009).

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • 1
    The ParentWnd parameter is *ignored* if the Application's `ModalPopupMode` is `pmNone`. And even when it is not 'pmNone', setting it really makes sense if you are passing something other than the active form's handle to it, IOW if you're putting the dialog in front of a form other than the active form. Because, as the link you refer indicates, if no ParentWnd is supplied it is already the active form's handle that is used. As such, this will not help the OP's problem. – Sertac Akyuz Apr 15 '11 at 06:39