lcl: add new form style fsIgnoreMouseEvents. use it instead of windows-specific WM_NCHITTEST=HTTRANSPARENT.

git-svn-id: trunk@52377 -
This commit is contained in:
ondrej 2016-05-23 21:47:00 +00:00
parent 2e5f56f9de
commit a7f5af9c78
6 changed files with 18 additions and 15 deletions

View File

@ -176,7 +176,7 @@ type
TCaption = TTranslateString;
TCursor = -32768..32767;
TFormStyle = (fsNormal, fsMDIChild, fsMDIForm, fsStayOnTop, fsSplash, fsSystemStayOnTop);
TFormStyle = (fsNormal, fsMDIChild, fsMDIForm, fsStayOnTop, fsSplash, fsSystemStayOnTop, fsIgnoreMouseEvents);
TFormBorderStyle = (bsNone, bsSingle, bsSizeable, bsDialog, bsToolWindow,
bsSizeToolWin);
TBorderStyle = bsNone..bsSingle;
@ -2972,7 +2972,7 @@ begin
if Frm=nil then
Exit;
if Frm.Perform(WM_NCHITTEST, 0, 0) <> HTTRANSPARENT then
if Frm.FormStyle <> fsIgnoreMouseEvents then
Exit;
Handle := 0;
@ -2985,7 +2985,7 @@ begin
NewFrm := Screen.CustomFormsZOrdered[I];
if (NewFrm<>Frm)
and PtInRect(NewFrm.BoundsRect, MousePos)
and (NewFrm.Perform(WM_NCHITTEST, 0, 0) <> HTTRANSPARENT)
and (NewFrm.FormStyle <> fsIgnoreMouseEvents)
then
Break;

View File

@ -508,6 +508,7 @@ type
procedure CMActivate(var Message: TLMessage); message CM_ACTIVATE;
procedure CMDeactivate(var Message: TLMessage); message CM_DEACTIVATE;
procedure CMShowingChanged(var Message: TLMessage); message CM_SHOWINGCHANGED;
procedure WMNCHitTest(var Message: TLMessage); message LM_NCHITTEST;
protected
FActionLists: TList; // keep this TList for Delphi compatibility
FFormBorderStyle: TFormBorderStyle;
@ -858,7 +859,6 @@ type
procedure SetHintRectAdjust(AValue: TRect);
protected
class procedure WSRegisterClass; override;
procedure WMNCHitTest(var Message: TLMessage); message LM_NCHITTEST;
procedure ActivateSub;
procedure DoShowWindow; override;
procedure UpdateRegion;

View File

@ -2201,7 +2201,7 @@ begin
if (FMainForm = nil)
and (FCreatingForm=AForm)
and (not (AppDestroying in FFlags))
and not (AForm.FormStyle in [fsMDIChild, fsSplash])
and not (AForm.FormStyle in [fsMDIChild, fsSplash, fsIgnoreMouseEvents])
then
FMainForm := AForm;
end;

View File

@ -728,6 +728,14 @@ begin
Application.QueueAsyncCall(@Moved, 0)
end;
procedure TCustomForm.WMNCHitTest(var Message: TLMessage);
begin
if FormStyle=fsIgnoreMouseEvents then
Message.Result := HTTRANSPARENT
else
inherited;
end;
procedure TCustomForm.Moved(Data: PtrInt);
begin
if WindowState = wsNormal then
@ -1949,10 +1957,10 @@ Begin
FFormStyle := Value;
Include(FFormState, fsFormStyleChanged);
if FFormStyle = fsSplash then
if FFormStyle in [fsSplash, fsIgnoreMouseEvents] then
BorderStyle := bsNone
else
if OldFormStyle = fsSplash then
if OldFormStyle in [fsSplash, fsIgnoreMouseEvents] then
BorderStyle := bsSizeable;
if HandleAllocated then
TWSCustomFormClass(WidgetSetClass).SetFormStyle(Self, Value, OldFormStyle);

View File

@ -30,7 +30,7 @@ begin
Canvas.Font := Screen.HintFont;
Canvas.Brush.Style := bsClear;
FAlignment := taLeftJustify;
BorderStyle := bsNone;
FormStyle := fsIgnoreMouseEvents;
Caption := '';
with GetControlClassDefaultSize do
SetInitialBounds(0, 0, CX, CY);
@ -69,11 +69,6 @@ begin
RegisterHintWindow;
end;
procedure THintWindow.WMNCHitTest(var Message: TLMessage);
begin
Message.Result := HTTRANSPARENT;
end;
procedure THintWindow.DoShowWindow;
begin
if (ActiveControl = nil) and (not (csDesigning in ComponentState)) and (Parent=nil) then

View File

@ -222,7 +222,7 @@ begin
win.setLevel(HintWindowLevel);
TCocoaPanel(win).callback := TLCLWindowCallback.Create(win, AWinControl);
win.setDelegate(win);
if AWinControl.Perform(WM_NCHITTEST, 0, 0)=HTTRANSPARENT then
if Form.FormStyle=fsIgnoreMouseEvents then
win.setIgnoresMouseEvents(True)
else
win.setAcceptsMouseMovedEvents(True);
@ -480,7 +480,7 @@ var
win.setTitle(ns);
ns.release;
win.setAcceptsMouseMovedEvents(True);
if AWinControl.Perform(WM_NCHITTEST, 0, 0)=HTTRANSPARENT then
if Form.FormStyle=fsIgnoreMouseEvents then
win.setIgnoresMouseEvents(True);
cnt.callback := TCocoaWindow(win).callback;