Board index » delphi » ShowWindow won't display form's controls

ShowWindow won't display form's controls

Hi all,

When I use ShowWindow to display a form, the form appears
but the controls on the form are not visible.

My main goal is to have a form popup when the user presses
the spacebar on another form, and then to have the popup
form close when the spacebar is released.

I had to use ShowWindow to display the form so that I
could use the SW_SHOWNOACTIVATE flag to prevent the popup
window from stealing the focus from the main window and
preventing the spacebar from executing the OnKeyUp event.

Everything works fine; the form opens and closes as
expected with the spacebar keypress, but for some reason,
when the form displays, none of the controls on it are
visible (and they all definitely have their VISIBLE
property set to TRUE).

Here's the code I'm using to display the form:

        frmQuickView := TfrmQuickView.Create(Application);
        ShowWindow(frmQuickView.Handle, SW_SHOWNOACTIVATE);

Obviously I'm creating the form at run-time, and not having
Delphi Auto-Create the form. But I even tried it with Delphi
doing the Auto-Create, and only executing the above
ShowWindow function, and that still had the same effect.

Any ideas? Using D5 Enterprise.

 - Dave

 

Re:ShowWindow won't display form's controls


Quote
David M. Fornalsky wrote:

> Hi all,

[snip]

Quote
> Everything works fine; the form opens and closes as
> expected with the spacebar keypress, but for some reason,
> when the form displays, none of the controls on it are
> visible (and they all definitely have their VISIBLE
> property set to TRUE).

I could think about 3 reasons:
1. Try to use frmQuickView.Show / Hide or Visible instead of ShowWindow
2. Try a Application.ProcessMessages after ShowWindow
3. (if this doesn't help) Can you give us some code about how you detect
pressing and releasing the space bar? Maybe there is another trap.

-Michael

Re:ShowWindow won't display form's controls


FWIW, I found a solution. Setting the Visible property
causes the controls to display, but does not rob the
main form of focus:

    frmQuickView := TfrmQuickView.Create(Application);
    ShowWindow(frmQuickView.Handle, SW_SHOWNOACTIVATE);
    frmQuickView.Visible := True;

 - Dave

Other Threads