?
Solved

TPanel as WS_POPUP

Posted on 1997-06-27
4
Medium Priority
?
1,302 Views
Last Modified: 2012-05-05
I have developed a messaging component derived from a TPanel. The Owner
and Parent at Create time is Applciation.MainForm. To pop it up anywhere
on the screen I overwrite the CreateParams method:

inherited CreateParams( Params);
Params.Style := ( Params.Style or WS_POPUP ) and ( not WS_CHILD );

This way I can pop up the window anywhere on the screen and the focus
does not switch from the current active form to the derived TPanel. Just
before display I set the Parent of my TPanel derivative to
Screen.ActiveForm... that way, when it is dismissed the focus remains on
the most recently active form. Just before destruction the Parent is set
back to Application.MainForm, otherwise exceptions come up.

Everything is great as long as the MainForm does not have a sizeable
border. If it does, although the TPanel derivative pops up in the
correct spot, the MainForm automatically creates slide bars to the right
and bottom. It seems that Delphi *thinks* the component is actually
located far to the lower right. This was confirmed when I compiled it as
a component and dropped it on the form. The six little black resizing
spots showed up in one spot, but the actual image showed up in another
spot in the upper left!

If I show and hide the TPanel using the API call ShowWindow, everything
is ok in the sense that the window shows up in the corect spot with no
auto slide bars being created. (Of course all the Delphi components on
my TPanel derviative fail to appear - they never get a paint notice.)
The curious behavior I cannot overcome starts somewhere in the call to
make the TPanel derviative Visible = true.

I have changed the ControlState to remove csAlignmentRequested, (or
whatever that set value is called) adn it did not help matters.
0
Comment
Question by:iced
[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
  • 4
4 Comments
 
LVL 3

Accepted Solution

by:
mirek071497 earned 400 total points
ID: 1337910
Changing Parent in runtime is a very bad idea.
Try this....

 TPopupPanel = class(TPanel)
  private
    SubParams : boolean;
  public
    procedure   CreateParams(var Params: TCreateParams); override;
    constructor Create(AOwner: TComponent); override;
  end;

implementation

procedure TPopupPanel.CreateParams( var Params: TCreateParams );
begin
  inherited CreateParams( Params );
  if SubParams then
    Params.Style := (Params.Style or WS_POPUP ) and (not WS_CHILD);
end;

constructor TPopupPanel.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  SubParams := not (csDesigning in ComponentState );
end;

0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1337911
is anybody there
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1337912
Hi ..

This really resolve you'r problem. Try!
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1337913
holiday,holiday but now is 18 sept !
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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

752 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