Search code examples
delphidelphi-5

windows OpenDialog open at background of other forms of application in Delphi, How to bring it at front?


I am using OpenDialog in Delphi 5. My problem is it opens at the back of My Application forms. I set My application form at the TOP using following code

if UpperCase(SmSession.ApplicationName) = 'MYAPP' then
begin
  Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST;
  exit;
end

, so the windows dialog box might be at the back. How can I take it to front without changing my application forms code ?

This is my code to openDialog:

EditParent.OpenDlg.InitialDir := EditParent.FDefaultDir;
EditParent.OpenDlg.FileName := EditParent.FFileName;

if EditParent.OpenDlg.Execute then
Begin
  SplitFileDir(EditParent.OpenDlg.FileName, TmpDir, TmpFile);
  if EditParent.ShowOnlyFileName then
    EditParent.FileName := TmpFile
  else
    EditParent.FileName := EditParent.OpenDlg.FileName;
  EditParent.Directory := TmpDir;
  EditParent.SetPeerDirectoryBrowser;
End;
EditParent.OpenDlg.Free;
inherited Click;

end;


Solution

  • This Property I was using for keep my application window on top always. Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST;

    now i commented this line and use another following property Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
    Params.WndParent := GetDesktopWindow;
    it works.