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

📄 acsbutils.pas

📁 Alpha Controls 5.40,delphi上的alpha开发源码控件包。没有密码。5.40版的最新版。
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    w := Min(w, SkinData.FCacheBmp.Width - R1.Left);
    w := Min(w, Bmp.Width - R2.Left) - 1; 
    if w < 0 then Exit;
    if R1.Left < R2.Left then begin
      if (R1.Left < 0) then begin
        inc(R2.Left, - R1.Left);
        dec(h, - R1.Left);
        R1.Left := 0;
      end;
    end
    else begin
      if (R2.Left < 0) then begin
        inc(R1.Left, - R2.Left);
        dec(h, - R2.Left);
        R2.Left := 0;
      end;
    end;
    if R1.Top < R2.Top then begin
      if (R1.Top < 0) then begin
        inc(R2.Top, - R1.Top);
        dec(h, - R1.Top);
        R1.Top := 0;
      end;
    end
    else begin
      if (R2.Top < 0) then begin
        inc(R1.Top, - R2.Top);
        dec(h, - R2.Top);
        R2.Top := 0;
      end;
    end;
    c.R := 255; c.G := 0; c.B := 255; // clFuchsia
    col.C := ParentCenterColor;
    if not CI.Ready then begin
      if ParentCenterColor <> clFuchsia then for Y := 0 to h do begin
        S1 := SkinData.FCacheBmp.ScanLine[R1.Top + Y];
        S2 := Bmp.ScanLine[R2.Top + Y];
        for X := 0 to w do begin
          if (S2[R2.Left + X].R = c.R) and (S2[R2.Left + X].G = c.G) and (S2[R2.Left + X].B = c.B) then begin
            S1[R1.Left + X].R := col.R;
            S1[R1.Left + X].G := col.G;
            S1[R1.Left + X].B := col.B;
          end;
        end;
      end;
    end
    else begin
      if Fast24Src.Attach(ci.Bmp) then for Y := 0 to h do begin
        S1 := SkinData.FCacheBmp.ScanLine[R1.Top + Y];
        S2 := Bmp.ScanLine[R2.Top + Y];
        for X := 0 to w do begin
          if (S2[R2.Left + X].R = c.R) and (S2[R2.Left + X].G = c.G) and (S2[R2.Left + X].B = c.B) then begin
            if ParentCenterColor <> clFuchsia then begin
              S1[R1.Left + X].R := col.R;
              S1[R1.Left + X].G := col.G;
              S1[R1.Left + X].B := col.B;
            end
            else begin
              if (CI.Bmp.Height <= R1.Top + ci.Y + Y) then Continue;
              if (CI.Bmp.Width <= R1.Left + ci.X + X) then Break;
              if R1.Top + ci.Y + Y < 0 then Break;
              if R1.Left + ci.X + X < 0 then Continue;
              col := Fast24Src.Pixels[R1.Left + ci.X + X, R1.Top + ci.Y + Y];
              // GetPixel(ci.Bmp.Canvas.Handle, R1.Left + ci.X + X, R1.Top + ci.Y + Y);
              S1[R1.Left + X].R := col.R;
              S1[R1.Left + X].G := col.G;
              S1[R1.Left + X].B := col.B;
            end;
          end
        end;
      end;
    end;
  end;
begin
  if not Assigned(Skindata.SkinManager) then Exit;
  if (SkinData.BorderIndex < 0) or not Skindata.SkinManager.IsValidImgIndex(SkinData.BorderIndex) or not Assigned(SkinData.FCacheBmp) or
        (Wnd.WndSize.cx < 2) or (Wnd.WndSize.cy < 2) then Exit;

  CI := GetParentCacheHwnd(Wnd.CtrlHandle);
  if not GetBoolMsg(Wnd.ParentWnd, AC_CHILDCHANGED) and (ParentCenterColor = clFuchsia) then begin
    ParentCenterColor := clFuchsia;
    SendMessage(Wnd.ParentWnd, SM_ALPHACMD, MakeWParam(0, AC_GETCONTROLCOLOR), 0);
    ParentCenterColor := ColorToRGB(ParentCenterColor)
  end
  else ParentCenterColor := clFuchsia;

  MaskData := SkinData.SkinManager.ma[SkinData.BorderIndex];
  Width := Wnd.WndSize.cx;
  Height := Wnd.WndSize.cy;
  wl := MaskData.WL; wt := MaskData.WT; wr := MaskData.WR; wb := MaskData.WB;

  if (MaskData.ImageCount = 0) and (MaskData.Bmp <> nil) then begin // if external
    MaskData.MaskType := 1;
    MaskData.ImageCount := 3;
    MaskData.R := Rect(0, 0, MaskData.Bmp.Width, MaskData.Bmp.Height);
  end;

//  GetWindowRect(Wnd.ParentWnd, parRect);
  if ParentCenterColor <> clFuchsia then begin
    ParentColor.C := ColorToRGB(ParentCenterColor);
    ParentRGB.R := ParentColor.R;
    ParentRGB.G := ParentColor.G;
    ParentRGB.B := ParentColor.B;
  end
  else begin
    inc(CI.X, Wnd.WndPos.x);
    inc(CI.Y, Wnd.WndPos.y);
  end;

  if State >= MaskData.ImageCount then State := MaskData.ImageCount - 1;
  dw := State * WidthOf(MaskData.R) div (MaskData.ImageCount);        // Width of mask
  dh := HeightOf(MaskData.R) div (1 + MaskData.MaskType);             // Height of mask

  w := WidthOf(MaskData.R) div MaskData.ImageCount - wl - wr;         // Width of piece of mask

  if MaskData.Bmp <> nil then SrcBmp := MaskData.Bmp else SrcBmp := SkinData.SkinManager.MasterBitmap;
  if MaskData.MaskType = 0 then begin // Copy without mask
    CopyTransCorner(SrcBmp, 0, 0, Rect(MaskData.R.Left + dw, MaskData.R.Top, MaskData.R.Left + dw + wl - 1, MaskData.R.Top + wt - 1));
    CopyTransCorner(SrcBmp, 0, Height - wb, Rect(MaskData.R.Left, MaskData.R.Bottom - wb, MaskData.R.Left + wl - 1, MaskData.R.Bottom - 1));
    CopyTransCorner(SrcBmp, Width - wr, Height - wb, Rect(MaskData.R.Left + dw + wl + w, MaskData.R.Bottom - wb, MaskData.R.Left + dw + wl + w + wr - 1, MaskData.R.Bottom - 1));
    CopyTransCorner(SrcBmp, Width - wr, 0, Rect(MaskData.R.Left + dw + wl + w, MaskData.R.Top, MaskData.R.Left + dw + wl + w + wr - 1, MaskData.R.Top + wb - 1));
  end
  else begin
    CopyMasterCorner(Rect(0, 0, wl + 1, wt + 1), Rect(MaskData.R.Left + dw, MaskData.R.Top, MaskData.R.Left + dw + wl, MaskData.R.Top + wt), SrcBmp);
    CopyMasterCorner(Rect(0, Height - wb, wl, Height), Rect(MaskData.R.Left + dw, MaskData.R.Top + dh - wb, MaskData.R.Left + dw + wl, MaskData.R.Top + dh), SrcBmp);
    CopyMasterCorner(Rect(Width - wr, Height - wb, Width, Height), Rect(MaskData.R.Left + dw + wl + w, MaskData.R.Top + dh - wb, MaskData.R.Left + dw + wl + w + wr, MaskData.R.Top + dh), SrcBmp);
    CopyMasterCorner(Rect(Width - wr, 0, Width, wt), Rect(MaskData.R.Left + dw + wl + w, MaskData.R.Top, MaskData.R.Left + dw + wl + w + wr, MaskData.R.Top + wt), SrcBmp);
  end;
  ParentCenterColor := clFuchsia;
end;

procedure RefreshScrolls(SkinData : TsCommonData; var ListSW : TacScrollWnd);
begin
  if not (csLoading in SkinData.FOwnerControl.ComponentState)
     and not (csDestroying in SkinData.FOwnerControl.ComponentState)
     and not (csDesigning in SkinData.FOwnerControl.ComponentState){
     and TWinControl(SkinData.FOwnerControl).HandleAllocated} then begin
    if SkinData.Skinned then begin
      UninitializeFlatSB(TWinControl(SkinData.FOwnerControl).Handle);
      if (ListSW <> nil) and ListSW.Destroyed then FreeAndNil(ListSW);
      if ListSW = nil then begin
        ListSW := TacScrollWnd.Create(TWinControl(SkinData.FOwnerControl).Handle, SkinData, SkinData.SkinManager, '');
      end;
    end
    else begin
      if ListSW <> nil then FreeAndNil(ListSW);
      InitializeFlatSB(TWinControl(SkinData.FOwnerControl).Handle);
    end;
  end;
end;

procedure RefreshEditScrolls(SkinData : TsCommonData; var ListSW : TacScrollWnd);
begin
  if SkinData.Skinned then begin
    if (ListSW <> nil) and ListSW.Destroyed then FreeAndNil(ListSW);
    if ListSW = nil then ListSW := TacEditWnd.Create(TWinControl(SkinData.FOwnerControl).Handle, SkinData, SkinData.SkinManager, s_Edit);
  end
  else begin
    if ListSW <> nil then FreeAndNil(ListSW);
  end;
end;

procedure RefreshTreeScrolls(SkinData : TsCommonData; var ListSW : TacScrollWnd);
begin
  if SkinData.Skinned then begin
    if (ListSW <> nil) and ListSW.Destroyed then FreeAndNil(ListSW);
    if ListSW = nil then ListSW := TacTreeViewWnd.Create(TWinControl(SkinData.FOwnerControl).Handle, SkinData, SkinData.SkinManager, s_Edit);
  end
  else begin
    if ListSW <> nil then FreeAndNil(ListSW);
  end;
end;

procedure UpdateScrolls(sw : TacScrollWnd; Repaint : boolean = False);
begin
  if sw <> nil then begin
    if (sw.sbarHorz <> nil) and (sw.sbarVert <> nil) then begin
      sw.sbarHorz.ScrollInfo.cbSize := SizeOf(TScrollInfo);
      sw.sbarHorz.ScrollInfo.fMask := SIF_ALL;
      GetScrollInfo(sw.CtrlHandle, SB_HORZ, sw.sbarHorz.ScrollInfo);

      sw.sbarVert.ScrollInfo.cbSize := SizeOf(TScrollInfo);
      sw.sbarVert.ScrollInfo.fMask := SIF_ALL;
      GetScrollInfo(sw.CtrlHandle, SB_VERT, sw.sbarVert.ScrollInfo);
      if Repaint then Ac_NCPaint(sw, sw.CtrlHandle, 1, 0);
    end;
  end;
end;

procedure PrepareCache(SkinData : TsCommonData; CtrlHandle : hwnd = 0; DlgMode : boolean = False);
var
  rForm, rCtrl : TRect;
  ci : TCacheInfo;
  P : TPoint;
  pHwnd : hwnd;
begin
  if (SkinData <> nil) and SkinData.BGChanged then begin
    if (CtrlHandle <> 0) then GetWindowRect(CtrlHandle, rCtrl) else Exit;
    CI := GetParentCacheHwnd(CtrlHandle);
    SkinData.InitCacheBmp;
    SkinData.FCacheBmp.Width := WidthOf(rCtrl);
    SkinData.FCacheBmp.Height := HeightOf(rCtrl);

    if DlgMode and (DefaultManager.SkinData.BorderColor <> clFuchsia) then begin
      FillDC(SkinData.FCacheBmp.Canvas.Handle, Rect(0, 0, SkinData.FCacheBmp.Width, SkinData.FCacheBmp.Height), clWindow);//DefaultManager.gd[SkinData.SkinIndex].Color);
      SkinData.FCacheBmp.Canvas.Brush.Color := DefaultManager.SkinData.BorderColor;
      SkinData.FCacheBmp.Canvas.FrameRect(Rect(0, 0, SkinData.FCacheBmp.Width, SkinData.FCacheBmp.Height));
    end
    else begin
      pHwnd := GetParent(CtrlHandle);
      if pHwnd <> 0 then GetWindowRect(pHwnd, rForm) else Exit;

      p.x := rCtrl.Left - rForm.Left - CI.X;
      p.y := rCtrl.Top - rForm.Top - CI.Y; 

      if Assigned(SkinData.SkinManager) and SkinData.SkinManager.IsValidSkinIndex(SkinData.SkinIndex) then begin
        PaintItem(SkinData, CI, False, 0, Rect(0, 0, SkinData.FCacheBmp.Width, SkinData.FCacheBmp.Height), P, SkinData.FCacheBmp, False);
      end;
    end;
    if SkinData.FOwnerControl <> nil then begin
      if not SkinData.FOwnerControl.Enabled then begin
        acGlobalDisabledKind := [];
        SendAMessage(CtrlHandle, AC_GETDISKIND);
        BmpDisabledKind(SkinData.FCacheBmp, acGlobalDisabledKind, SkinData.FOwnerControl.Parent, GetParentCache(SkinData), Point(SkinData.FOwnerControl.Left, SkinData.FOwnerControl.Top));
      end;
    end;
    SkinData.BGChanged := False;
  end;
end;

procedure UninitializeACScroll(Handle : hwnd; FreeSW : boolean; Repaint : boolean; var ListSW : TacScrollWnd);
var
  sw : TacScrollWnd;
begin
  if ListSW = nil then exit{sw := Ac_GetScrollWndFromHwnd(Handle) }else sw := ListSW;
  if (sw <> nil) and not sw.Destroyed and (sw.SkinData.FOwnerControl <> nil) then begin
    // restore the window procedure with the original one
    if Assigned(ListSW.OldWndProc) then begin
      if (sw.SkinData.FOwnerObject is TsSkinProvider) then begin
         TsSkinProvider(sw.SkinData.FOwnerObject).Form.WindowProc := ListSW.OldWndProc;
      end
      else TacWinControl(sw.SkinData.FOwnerControl).WindowProc := ListSW.OldWndProc;
    end
    else begin
      SetWindowLong(Handle, GWL_WNDPROC, longint(sw.oldproc));
      if sw.NewWndProcInstance <> nil then begin
        FreeObjectInstance(sw.NewWndProcInstance);
        sw.NewWndProcInstance := nil;
      end;
    end;
    RemoveProp(Handle, acPropStr);
    sw.RestoreStdParams;
    if Assigned(sw.sBarHorz) then begin
      sw.sBarHorz.sw := nil;
      FreeAndNil(sw.sBarHorz);
    end;
    if Assigned(sw.sBarVert) then begin
      sw.sBarVert.sw := nil;
      FreeAndNil(sw.sBarVert);
    end;
    // Force WM_NCCALCSIZE and WM_NCPAINT so the original scrollbars can kick in
    if IsWindowVisible(Handle) then Ac_RedrawNonClient(Handle, Repaint);
    sw.Destroyed := True;
  end;
  if FreeSW and (ListSW <> nil) then begin
    sw.oldproc := nil;
    sw.OldWndProc := nil;
    FreeAndnil(ListSW);
  end;
end;

procedure InitControl(Handle: hwnd; ASkinData: TsCommonData; ASkinManager: TsSkinManager);
begin
  if ASkinManager.Active then begin
    HookScrollWnd(Handle, ASkinManager, ASkinData);
  end
  else begin
    // !
  end;
end;

function Scrolls_SetStyle(Handle : hwnd; wBar : integer; nStyle : integer) : boolean;
var
  sbar : TacScrollBAr;
begin
  Result := False;
  if Ac_GetScrollWndFromHwnd(Handle) = nil then Exit;

  if (wBar = SB_HORZ) or (wBar = SB_BOTH) then begin
    sbar := Ac_GetScrollBarFromHwnd(Handle, SB_HORZ);
    if sbar <> nil then sbar.fFlatScrollbar := nStyle;
  end;
  if (wBar = SB_VERT) or (wBar = SB_BOTH) then begin
    sbar := Ac_GetScrollBarFromHwnd(Handle, SB_VERT);
    if sbar <> nil then sbar.fFlatScrollbar := nStyle;
  end;

  if IsWindowVisible(Handle) then Ac_RedrawNonClient(Handle, True);
  Result := True;
end;

procedure InitializeACScrolls(sw : TacScrollWnd; AHandle : hwnd; Repaint : boolean = True);
var
  dwCurStyle : LongInt;
begin
  with sw do begin
    DontRepaint := False;
    CtrlHandle := AHandle;
    sbarHorz := TacScrollBar.Create;
    sbarHorz.sw := sw;
    sbarVert := TacScrollBar.Create;
    sbarVert.sw := sw;

    sbarHorz.ScrollInfo.cbSize := SizeOf(TScrollInfo);
    sbarHorz.ScrollInfo.fMask := SIF_ALL;
    GetScrollInfo(CtrlHandle, SB_HORZ, sbarHorz.ScrollInfo);

    sbarVert.ScrollInfo.cbSize := SizeOf(TScrollInfo);
    sbarVert.ScrollInfo.fMask := SIF_ALL;
    GetScrollInfo(CtrlHandle, SB_VERT, sbarVert.ScrollInfo);

    fLeftScrollbar := GetWindowLong(CtrlHandle, GWL_EXSTYLE) and WS_EX_LEFTSCROLLBAR = WS_EX_LEFTSCROLLBAR;
    dwCurStyle := GetWindowLong(CtrlHandle, GWL_STYLE);
    SetProp(CtrlHandle, acPropStr, Cardinal(sw));

    if dwCurStyle and WS_HSCROLL <> 0 then sw.sBarHorz.fScrollFlags := CSBS_VISIBLE;
    if dwCurStyle and WS_VSCROLL <> 0 then sw.sbarVert.fScrollFlags := CSBS_VISIBLE;

    sbarHorz.nBarType := SB_HORZ;
    sbarVert.nBarType := SB_VERT;

⌨️ 快捷键说明

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