When window A is show, I want to show another none-modal popup window B, but:
As you can see, the window B that I want is something like a more usable popup window like a popup menu (which is less a obstacle than a general none-modal window when you want it to get away by clicking on any other part of the parent window).
Am I clear on my question? Thank you.
The easiest solution I had found for "1" is to send a WM_NCACTIVATE to the calling form as soon as the popup-form gets activated (in a WM_ACTIVATE handler), so that the calling form would draw its caption with the active colors. You'll have to have a reference for the calling form in the popup-form to achieve this.
For "2", you can release the popup form in the same WM_ACTIVATE handler, this won't eat the clicks that goes to the calling form.
So sth. like this should go to the popup-form;
type
TForm2 = class(TForm)
[..]
private
FOwner: TForm;
procedure WmActivate(var Msg: TWMActivate); message WM_ACTIVATE;
public
constructor Create(AOwner: TComponent); override;
[...]
constructor TForm2.Create(AOwner: TComponent);
begin
if not (AOwner is TForm) then
raise Exception.Create('Owner should be TForm');
FOwner := TForm(AOwner);
inherited;
end;
procedure TForm2.WmActivate(var Msg: TWMActivate);
begin
SendMessage(FOwner.Handle, WM_NCACTIVATE, Ord(Msg.Active <> WA_INACTIVE), 0);
inherited;
if Msg.Active = WA_INACTIVE then
Release;
end;
and supply the calling form as the owner of the popup-form;
procedure TForm1.Button1Click(Sender: TObject);
var
PopForm: TForm2;
begin
PopForm := TForm2.Create(Self);
[..]
In order to prevent a window from getting focus, you must either specify the WS_EX_NOACTIVATE
extended window style (Windows 2000 and up) or handle WM_MOUSEACTIVATE
and return MA_NOACTIVATE
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With