Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Popup Window Focus

Posted on 2004-05-01
1
Medium Priority
?
823 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 750 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

705 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