3
votes

I'm using Delphi 4. I have a main form with a button that dynamically creates a new form. I'd like the new form to be visible, but to show up BEHIND the main form.

I've tried calling SendToBack() immediately after FormCreate(). But that makes the window flicker quickly before it's actually sent to back.

I've tried making the form invisible, then SendToBack(), then Visible := true. But the new form is still at the front.

It looks like SendToBack() only works with visible forms? How can I cause the form to be shown behind the main form?

2

2 Answers

1
votes

This worked for me:

SetWindowPos(newform.Handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_SHOWWINDOW
  or SWP_NOMOVE or SWP_NOOWNERZORDER or SWP_NOSIZE or SWP_NOACTIVATE);

newform.Visible := true;

Thanks for help!

0
votes

make the second window (e.g. form2) invisible, then call:

showWindow(form2.handle,SW_SHOWNOACTIVATE);

-don