⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teform.pas

📁 Do your applications look a little boring? Would you like to get spectacular yet easy to use visual
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{
procedure TFormTransitions.ActivateHook(const Activate: Boolean);
begin
  if Activate
  then
  begin
    if(not Assigned(WindowProcBak)) then
    begin
      WasVisible := OwnerForm.Visible;
      WindowProcBak := OwnerForm.WindowProc;
      OwnerForm.WindowProc := NewWindowProc;
    end;

    if(Application.MainForm <> nil) and (OwnerForm.FormStyle = fsMdiChild) then
    begin
      MDIClientWndProcTransSubclass(Application.MainForm.ClientHandle);
      LockMDIClient :=
        Enabled and ((OwnerForm.WindowState = wsMaximized) or MaximizedChildren);
    end;

    if(OwnerForm.FormStyle = fsMDIForm)             and
       not(csDesigning in OwnerForm.ComponentState) and
      (OwnerForm.ClientHandle <> 0)                 then
      MDIClientWndProcBkgrndSubclass(OwnerForm.ClientHandle, BackgroundOptions);
  end
  else
  begin
    if Assigned(Owner) and Assigned(WindowProcBak) then
      OwnerForm.WindowProc := WindowProcBak;
    WindowProcBak := nil;

    if Assigned(Owner) and (OwnerForm.FormStyle = fsMdiChild) then
      LockMDIClient := False;
  end;
end;
}
function TFormTransitions.CanEnable: Boolean;
begin
  Result := (not(csDesigning in ComponentState)) and (OwnerForm.Parent = nil);
end;

procedure TFormTransitions.Loaded;
begin
  inherited Loaded;

  if OwnerForm.FormStyle = fsMDIForm then
    ActivateHookMDIClientBkgrnd(True, OwnerForm.ClientHandle);
    
  if Enabled and CanEnable
  then
  begin
    if OwnerForm.FormStyle = fsStayOnTop then
    begin
      OwnerForm.FormStyle := fsNormal;
      OwnerForm.FormStyle := fsStayOnTop;
    end;
  end
  else
  begin
    if(OwnerForm.FormStyle = fsMDIChild) and MDIClientLocked then
    begin
      UnlockWindow(Application.MainForm.ClientHandle, 0, True);
      MDIClientLocked := False;
    end;
  end;
end;

procedure TFormTransitions.Notification(AComponent: TComponent;
  Operation: TOperation);
begin
  inherited Notification(AComponent, Operation);
  if(Operation = opRemove)                 and
    (FShowTransition <> nil)               and
    (AComponent = FShowTransition)         then
  begin
    if(FShowTransition = OldTransition) and Assigned(NewTransition)
    then FShowTransition := NewTransition
    else FShowTransition := nil;
  end;
end;

procedure TFormTransitions.SetShowTransition(const Value: TTransitionEffect);
begin
  if Value <> FShowTransition then
  begin
    if DestroyTransitions                   and
      (not (csDesigning in ComponentState)) and
       Assigned(FShowTransition)            then
      FShowTransition.Free;

    FShowTransition := Value;

    if Assigned(FShowTransition) and
       Assigned(FShowTransition.TransitionList) then
      DestroyTransitions := False;
  end;
end;

function TFormTransitions.GetVersion: String;
begin
  Result := BilleniumEffectsVersion;
end;

procedure TFormTransitions.SetVersion(const Value: String);
begin
end;

procedure TFormTransitions.NewWindowProc(var Message: TMessage);
var
  TempTransition,
  IsVisible,
  SaveClientCoordinates,
  SaveNeverRendering: Boolean;
  SavePassSetting: TTEPassSettingType;
  Locked: Boolean;
  R: TRect;
  Rgn: HRGN;
  DC: HDC;
  PS: TPaintStruct;
begin
  case Message.Msg of
    CM_SHOWINGCHANGED:
    begin
      if not WasVisible then
        BackgroundOptions.Control := OwnerForm;

      if Enabled                   and
         CanEnable                 and
        (not NestedFormTransition) and
        (not WasVisible)           and
        (not TETransitionPrepared) and
        (((ShowTransition =  nil)  and FlickerFreeTransition.FlickerFreeWhenDisabled) or
          (ShowTransition <> nil)  and ShowTransition.AllowTransition)
      then
      begin
        if(OwnerForm.FormStyle = fsMDIChild) and MDIClientLocked
        then
        begin
          Rgn := 0;
          if GetMaximizedMDIChild(OwnerForm) then
          begin
            SetWindowLong(Application.MainForm.ClientHandle, GWL_EXSTYLE,
              GetWindowLong(Application.MainForm.ClientHandle,
                GWL_EXSTYLE) and not WS_EX_CLIENTEDGE);
            SetWindowPos(Application.MainForm.ClientHandle, 0, 0, 0, 0, 0,
              SWP_FRAMECHANGED or SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE or SWP_NOZORDER);
          end;
        end
        else Rgn := LockWindow(OwnerForm.Handle,
                               OwnerForm.WindowState <> wsMaximized);
        Locked := True;
        try
          with OwnerForm do
          begin
            {$ifndef D3C3}
            if(FormStyle = fsStayOnTop) and
              (((HorzScrollBar.Visible and (HorzScrollBar.Style = ssRegular)) and
                not(VertScrollBar.Visible and (VertScrollBar.Style <> ssRegular)))  or
               ((VertScrollBar.Visible and (VertScrollBar.Style = ssRegular)) and
                not(HorzScrollBar.Visible and (HorzScrollBar.Style <> ssRegular)))) then
              UninitializeFlatSB(Handle);
            {$endif D3C3}
          end;

          if OwnerForm.FormStyle = fsMDIForm then
            NestedFormTransition := True;
          try
            TETransitionPrepared := True;
            try
              WindowProcBak(Message);
            finally
              TETransitionPrepared := False;
            end;
          finally
            if OwnerForm.FormStyle = fsMDIForm then
              NestedFormTransition := False;
          end;

          IsVisible := OwnerForm.Visible;
          if Enabled and (WasVisible <> IsVisible) then
          begin
            if(not WasVisible) and IsVisible then
            begin
              if ShowTransition = nil
              then
              begin
                ShowTransition := TFlickerFreeTransition.Create(nil);
                ShowTransition.FlickerFreeWhenDisabled :=
                  FlickerFreeTransition.FlickerFreeWhenDisabled;
                TempTransition := True;
              end
              else TempTransition := False;
              try
                SaveClientCoordinates := ShowTransition.ClientCoordinates;
                SavePassSetting       := ShowTransition.PassSetting;
                SaveNeverRendering    := ShowTransition.NeverRendering;

                ShowTransition.PassSetting := teOnePass;

                if(OwnerForm.FormStyle = fsMDIChild) and MaximizedChildren
                then
                begin
                  GetClientRect(Application.MainForm.ClientHandle, R);
                  ShowTransition.ClientCoordinates := True;
                end
                else
                begin
                  ShowTransition.ClientCoordinates := False;
                  R:=OwnerForm.BoundsRect; //V34
//                  R := Rect(0, 0, OwnerForm.Width, OwnerForm.Height);
//                  if OwnerForm.WindowState = wsMaximized then
//                    InflateRect(R, OwnerForm.Left, OwnerForm.Top)
                end;

                try
                  ShowTransition.NeverRendering := True;

                  ShowTransition.Prepare(OwnerForm, R);

                  if(OwnerForm.FormStyle = fsMDIChild) and MDIClientLocked
                  then
                  begin
                    UnlockWindow(Application.MainForm.ClientHandle, 0, True);
                    MDIClientLocked := False;
                  end
                  else Rgn := UnlockWindow(OwnerForm.Handle, Rgn,
                                OwnerForm.FormStyle = fsMDIChild);
                  Locked := False;

                  if(Rgn <> 0) and (not MDIClientLocked) then
                  begin
                    ShowTransition.ClipRgn := Rgn;
                    Rgn := 0;
                  end;

                  if ShowTransition.Prepared then
                    ShowTransition.Execute;
                finally
                  ShowTransition.ClientCoordinates := SaveClientCoordinates;
                  ShowTransition.PassSetting       := SavePassSetting;
                  ShowTransition.NeverRendering    := SaveNeverRendering;
                end;
              finally
                ShowTransition.UnPrepare;
                if TempTransition then
                  ShowTransition := nil;
              end;
            end;
          end;
        finally
          if Locked then
          begin
            if(OwnerForm.FormStyle = fsMDIChild) and MDIClientLocked
            then
            begin
              UnlockWindow(Application.MainForm.ClientHandle, 0, True);
              MDIClientLocked := False;
            end
            else UnlockWindow(OwnerForm.Handle, Rgn, False);
          end;
        end;
      end
      else WindowProcBak(Message);
      WasVisible := OwnerForm.Visible;
    end;

    CM_PARENTFONTCHANGED:
    begin
      WindowProcBak(Message);
      BackgroundOptions.Control := OwnerForm;
    end;

    CM_TEGETBKGNDOPTIONS:
      Message.Result := Longint(BackgroundOptions);

    WM_ERASEBKGND:
    begin
      if MDIClientLocked then
      begin
        Message.Result := 1;
        exit;
      end;
      if(OwnerForm.FormStyle <> fsMDIForm) and BackgroundOptions.IsActive
      then
      begin
        {$ifdef D7UP}
        if BEParentBackgroundPainted(OwnerForm.Handle) then
          BackgroundOptions.DrawBackGround(TWmEraseBkgnd(Message).DC,
            Rect(0, 0, 0, 0));
        {$endif D7UP}
        Message.Result := 1;
      end
      else WindowProcBak(Message);
    end;

    WM_PAINT:
    begin
      if(OwnerForm.FormStyle <> fsMDIForm) and BackgroundOptions.IsActive
      then
      begin
        DC := TWMPaint(Message).DC;
        if DC = 0
        then
        begin
          DC := BeginPaint((Owner as TWinControl).Handle, PS);
          try
            if IsRectEmpty(PS.rcPaint) then
              PS.rcPaint := (Owner as TWinControl).ClientRect;

            BackgroundOptions.DrawBackGround(DC, PS.rcPaint);
            if not(csDesigning in OwnerForm.ComponentState) then
              OwnerForm.Paint;
            TFCWinControl(Owner).PaintControls(DC, nil);
          finally
            if TWMPaint(Message).DC = 0 then
              EndPaint((Owner as TWinControl).Handle, PS);
          end;
        end
        else
        begin
          Rgn := CreateRectRgn(0, 0, 0, 0);
          GetClipRgn(DC, Rgn);
          GetRgnBox(Rgn, R);
          DeleteObject(Rgn);
          DPToLP(DC, R, 2);

          BackgroundOptions.DrawBackGround(DC, R);
          if not(csDesigning in OwnerForm.ComponentState) then
            OwnerForm.Paint;
          TFCWinControl(Owner).PaintControls(DC, nil);
        end;
      end
      else WindowProcBak(Message);
    end;

    WM_MOVE:
    begin
      WindowProcBak(Message);
      if(not(csDestroying in ComponentState)) and
        BackgroundOptions.IsActive            and
        (BackgroundOptions.ParentPicture      or
         BackgroundOptions.ParentBkgrndForm   or
         not BackgroundOptions.Opaque) then
        BackgroundOptions.ControlChanged(Self);
    end;

    WM_SIZE,
    WM_VSCROLL,
    WM_HSCROLL:
    begin
      WindowProcBak(Message);
      if(not(csDestroying in ComponentState)) and
        BackgroundOptions.IsActive then
        BackgroundOptions.ControlChanged(Self);
    end;

    else WindowProcBak(Message);
  end;
end;

function TFormTransitions.GetPalette: HPALETTE;
begin
  Result := BackgroundOptions.GetPalette;
end;

procedure TFormTransitions.SetBackgroundOptions(
  Value: TFCBackgroundOptions);
begin
  BackgroundOptions.Assign(Value);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -