问题
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
回答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).
来源:https://stackoverflow.com/questions/5660468/delphi-tcolordialog-opens-behind-a-stayontop-form