Solved

Popup Window Focus

Posted on 2004-05-01
1
803 Views
Last Modified: 2010-04-04
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.
0
Comment
Question by:JQL
1 Comment
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 250 total points
ID: 10967276

   in the constructor you send The form handle.

  constructor TPopupMenu.Create (...your params here...; FormHandle : THandle);
  begin
     ......
  end;

  in the constructor you set FormStyle := FormStyle + [fsStayOnTop];

  procedure TPopupMenu.ShowPopup(....your params here...);
  begin
    Show;
    .....
    // activate the form using it's handle
    SendMessage(FormHandle, WM_ACTIVATE, 0, 0);
  end;
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now