Link to home
Start Free TrialLog in
Avatar of JQL
JQL

asked on

Popup Window Focus

I need to create a small Popup window which will contain a number of controls (not necessarily controls with handles). The Popup Window must be able to overlap the Parent Form border, in a similar manner to a Combobox's drop down portion.

(Note the Popup Window is NOT a ListBox, though, in principle, it could contain a ListBox as one of it's controls).

Now, the part I'm having difficulty with: When you click on a control in the Popup window the Parent Form **must** retain focus. The Popup Window must stay open and on top of the Parent Window until manually closed.

At present I'm using the following code in the CreateParams:

procedure TPopupWindow.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.Style := Params.Style or ES_MULTILINE or WS_POPUP;
end;

And this to return Focus to the main form when a control is pressed:

procedure TPopupWindow.ControlPressed(Sender: TObject);
begin
  FMainForm.SetFocus;

 // ... More code to handle the mouse click or keyboard input ...

end;

When you click on a control in the Popup Window the Parent Form looses focus which causes a "flashing effect" of the Parent Form's border when I programmatically return focus to it.

Other info:

The Popup Window does *not* have a Caption. Does *not* have BorderIcons or in fact a Border. The Popup Window's background must be opaque when both inside and outside the Parent Forms boundaries.
ASKER CERTIFIED SOLUTION
Avatar of Ivanov_G
Ivanov_G
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial