Mark Williams 14 Posted June 20, 2020 (edited) Within a Delphi document management application I use COM to open MS word documents. Hyperlinks can be added to the Word document which are references to image files maintained by the Delphi application. When the user clicks on a hyperlink in Word a message is returned to the Delphi app which in turn responds by opening a form which displays the required image. Whilst I want the image form to be top of the z-rder and activated I would like to keep the Word window just below it in the z-order ie above any other open windows in the Delphi application including the main form. First I tried: ImgForm := TFrmImage.Create(Nil); ImgForm.ParentWindow := Wordwnd; ImgForm.Show; SetWindowPos(WordWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE OR SWP_NOACTIVATE); SetWindowPos(ImgForm.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE OR SWP_NOACTIVATE); This didn't work. The application main form appeared on top of the Word window. I then tried creating the image form without activating it: ImgForm := TFrmImage.Create(Nil); ImgForm.visible := false; ImgForm.ParentWindow := Wordwnd; SetWindowPos(WordWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE OR SWP_NOACTIVATE); SetWindowPos(ImgForm.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE OR SWP_NOACTIVATE); Same result!. I am using a Delphi Add-In within Word to provide additional ribbon functions etc. Somewhat tongue in cheek I tried a different approach. When the user clicks on a hyperlink the Add-In creates a new form "HostForm" and then sends a request through to the Delphi app to open ImgForm. The Delphi App does the following: ImgForm := TImgForm.Create(Nil); ImgForm.Visible := false; ImgForm.borderStyle := bsNone; ImgForm.ParentWindow := Wnd; //ie the handle of HostForm ImgForm.Align := alClient; ImgForm.Visible := true; Much to my amazement it worked. ImgForm was embedded in HostForm. HostForm was top of the Zorder with the word window below it and the Delphi app below the word window. The only thing that didn't work was the alignment. A couple of questions: Is it possible simply to align ImgForm to HostForm or will I need to deal with it in HostForm's resize event? I have noticed that if I close the Delphi app ImgForm is also closed ie it just disappears from HostForm and if I close HostForm, ImgForm remains in existence albeit it cannot be seen. These effects are I suppose to be expected and should be easily handled. But am I missing more potentially significant problems that will be more difficult or even impossible to handle? Edited June 20, 2020 by Mark Williams Missing line from code Share this post Link to post