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

📄 acdials.pas

📁 Alpha Controls.v5.46b Source
💻 PAS
📖 第 1 页 / 共 5 页
字号:

        if SkinData.SkinManager.gd[SkinData.SkinIndex].ReservedBoolean and ((TitleBG = nil) or (TitleBG.Width <> WndSize.cx)) then MakeTitleBG;
        ci := MakeCacheInfo(SkinData.FCacheBmp, OffsetX, OffsetY); // Prepare cache info
        if (CaptionHeight <> 0) then begin // Paint title
          i := SkinData.SkinManager.GetSkinIndex(s_FormTitle);
          if SkinData.SkinManager.IsValidSkinIndex(i) then if IsIconic(CtrlHandle)
            then PaintItem(i, s_FormTitle, ci, True, integer(FormActive),
              Rect(0, 0, WndSize.cx, WndSize.cy), Point(0, 0), SkinData.FCacheBmp, SkinData.SkinManager)
            else PaintItem(i, s_FormTitle, ci, True, integer(FormActive),
              Rect(0, 0, WndSize.cx, h - CY), Point(0, 0), SkinData.FCacheBmp, SkinData.SkinManager);
          DrawAppIcon(Self); // Draw app icon
          if dwStyle and WS_SYSMENU = WS_SYSMENU then begin // Paint title toolbar if exists
            i := SkinData.SkinManager.GetMaskIndex(SkinData.SkinIndex, SkinData.SkinSection, s_NormalTitleBar);
            if SkinData.SkinManager.IsValidImgIndex(i) then DrawSkinRect(SkinData.FCacheBmp,
                        Rect(WndSize.cx - BarWidth(i), 0, SkinData.FCacheBmp.Width, h - CY),
                        True, EmptyCI, SkinData.SkinManager.ma[i], integer(FormActive), True);
          end;
          // Store bg for buttons
          TempBmp.Width := TitleBtnsWidth + SysBorderWidth;
          TempBmp.Height := HeaderHeight;
          BitBlt(TempBmp.Canvas.Handle, 0, 0, TempBmp.Width, TempBmp.Height, SkinData.FCacheBmp.Canvas.Handle, WndSize.cx - TempBmp.Width - 1, 0, SRCCOPY);
          // Paint buttons
          PaintBorderIcons;
          // Out the title text
          SkinData.FCacheBmp.Canvas.Font.Assign(TitleFont);
          R := Rect(SysBorderWidth + GetSystemMetrics(SM_CXSMICON) * integer(TitleIcon <> 0) + 4, CY, WndSize.cx - TitleBtnsWidth - 6, CaptionHeight);
          if not IsRectEmpty(R) then begin
{$IFDEF TNTUNICODE}
          WriteTextExW(SkinData.FCacheBmp.Canvas, PWideChar(Caption), True, R, DT_LEFT or DT_END_ELLIPSIS or DT_SINGLELINE or DT_VCENTER, SkinData.SkinManager.GetSkinIndex(s_FormTitle), boolean(FormActive));
{$ELSE}
          s := CutText(SkinData.FCacheBmp.Canvas, Caption, WndSize.cx - GetSystemMetrics(SM_CXSMICON) - SysBorderWidth - TitleBtnsWidth - 6);
          WriteTextEx(SkinData.FCacheBmp.Canvas, PChar(s), True, R, DT_LEFT or DT_SINGLELINE or DT_VCENTER, SkinData.SkinManager.GetSkinIndex(s_FormTitle), boolean(FormActive));
{$ENDIF}
          end;
        end;
      end;
    end;
    SkinData.BGChanged := False
  end;
end;

procedure TacDialogWnd.PaintBorderIcons;
var
  i, b, Offset : integer;
  procedure PaintButton(var Btn : TsCaptionButton; var Index : integer; SkinIndex : integer; BtnEnabled : boolean; UserBtn : TsTitleButton = nil);
  var
    w, btnH : integer;
  begin
    w := SysButtonWidth(Btn);
    Btn.Rect.Left := Btn.Rect.Right - w;
    btnH := ButtonHeight(Btn.ImageIndex);
    Btn.Rect.Top := (CaptionHeight - btnH + SysBorderHeight) div 2;
    if btnH < 16 then inc(Btn.Rect.Top, 2);
    Btn.Rect.Bottom := Btn.Rect.Top + btnH;
    if SkinIndex > -1 then DrawSkinGlyph(SkinData.FCacheBmp, Point(Btn.Rect.Left, Btn.Rect.Top),
      Btn.State, 1 + integer(not boolean(FormActive) or not BtnEnabled), SkinData.SkinManager.ma[SkinIndex]);
    inc(Index);
  end;
begin
  b := 1;
  Offset := WndSize.cx - SysBorderWidth;
  if (dwStyle and WS_SYSMENU = WS_SYSMENU) then begin // Accommodation of a buttons in a special order...
    if SkinData.SkinManager.IsValidImgIndex(ButtonClose.ImageIndex) then begin
      ButtonClose.Rect.Right := Offset;
      PaintButton(ButtonClose, b, ButtonClose.ImageIndex, EnabledClose);
      Offset := ButtonClose.Rect.Left;
    end;
    if VisibleMax then begin
      if not IsZoomed(CtrlHandle) then begin
        if SkinData.SkinManager.IsValidImgIndex(ButtonMax.ImageIndex) then begin
          ButtonMax.Rect.Right := Offset;
          PaintButton(ButtonMax, b, ButtonMax.ImageIndex, EnabledMax);
          Offset := ButtonMax.Rect.Left;
        end;
      end
      else begin
        i := SkinData.SkinManager.GetMaskIndex(SkinData.SkinManager.ConstData.IndexGLobalInfo, s_GlobalInfo, s_BorderIconNormalize);
        if i < 0 then i := SkinData.SkinManager.GetMaskIndex(SkinData.SkinIndex, SkinData.SkinSection, s_BorderIconNormalize); // For compatibility
        if i > -1 then begin
          ButtonMax.Rect.Right := Offset;
          PaintButton(ButtonMax, b, i, EnabledRestore);
          Offset := ButtonMax.Rect.Left;
        end;
      end;
    end;
    if VisibleMin then begin
      if IsIconic(CtrlHandle) then begin // If form is minimized then changing to Normalize
        i := SkinData.SkinManager.GetMaskIndex(SkinData.SkinManager.ConstData.IndexGLobalInfo, s_GlobalInfo, s_BorderIconNormalize);
        if i < 0 then i := SkinData.SkinManager.GetMaskIndex(SkinData.SkinIndex, SkinData.SkinSection, s_BorderIconNormalize);
        if SkinData.SkinManager.IsValidImgIndex(i) then begin
          ButtonMin.Rect.Right := Offset;
          PaintButton(ButtonMin, b, i, EnabledRestore); // For compatibility
          Offset := ButtonMin.Rect.Left;
        end;
      end
      else begin
        if SkinData.SkinManager.IsValidImgIndex(ButtonMin.ImageIndex) then begin
          ButtonMin.Rect.Right := Offset;
          PaintButton(ButtonMin, b, ButtonMin.ImageIndex, EnabledMin);
          Offset := ButtonMin.Rect.Left;
        end;
      end;
    end;
    if VisibleHelp then begin
      if SkinData.SkinManager.IsValidImgIndex(ButtonHelp.ImageIndex) then begin
        ButtonHelp.Rect.Right := Offset;
        PaintButton(ButtonHelp, b, ButtonHelp.Imageindex, True);
      end;
    end;
  end;
end;

procedure TacDialogWnd.PaintForm(var DC: hdc; SendUpdated : boolean = True);
begin
  PaintAll;
  BitBlt(DC, 0, 0, WndSize.cx, WndSize.cy, SkinData.FCacheBmp.Canvas.Handle, BorderWidth, HeaderHeight, SRCCOPY);
  SetParentUpdated(CtrlHandle);
end;

procedure TacDialogWnd.PrepareTitleGlyph;
var
  SmallIcon: HIcon;
  cx, cy: Integer;
  Bmp : TBitmap;
begin
  Bmp := TBitmap.Create;
  cx := GetSystemMetrics(SM_CXSMICON);
  cy := GetSystemMetrics(SM_CYSMICON);
  Bmp.Width := cx;
  Bmp.Height := cy;
  Bmp.Canvas.Brush.Color := clFuchsia;
  TitleIcon := hIcon(SendMessage(CtrlHandle, WM_GETICON, ICON_SMALL, 0));
  if TitleIcon = 0 then TitleIcon := hIcon(SendMessage(CtrlHandle, WM_GETICON, ICON_BIG, 0));

  if TitleIcon <> 0 then begin
    SmallIcon := Windows.CopyImage(TitleIcon, IMAGE_ICON, cx, cy, LR_COPYFROMRESOURCE);
    DrawIconEx(Bmp.Canvas.Handle, 0, 0, SmallIcon, cx, cy, 0, 0, DI_NORMAL);
    DestroyIcon(SmallIcon);
    if TitleGlyph = nil then TitleGlyph := TBitmap.Create;
    TitleGlyph.Assign(Bmp);
  end;
  FreeAndNil(Bmp);
end;

function TacDialogWnd.RBGripPoint(ImgIndex: integer): TPoint;
begin
  if SkinData.SkinManager.ma[ImgIndex].Bmp = nil then begin
    Result := Point(SkinData.FCacheBmp.Width - WidthOf(SkinData.SkinManager.ma[ImgIndex].R) div SkinData.SkinManager.ma[ImgIndex].ImageCount - SysBorderWidth,
                    SkinData.FCacheBmp.Height - HeightOf(SkinData.SkinManager.ma[ImgIndex].R) div (1 + SkinData.SkinManager.ma[ImgIndex].MaskType) - SysBorderHeight
              );
  end
  else begin
    Result := Point(SkinData.FCacheBmp.Width - SkinData.SkinManager.ma[ImgIndex].Bmp.Width div 3 - SysBorderWidth,
                    SkinData.FCacheBmp.Height - SkinData.SkinManager.ma[ImgIndex].Bmp.Height div 2 - SysBorderHeight
              );
  end;
end;

function TacDialogWnd.SysBorderHeight: integer;
begin
  Result := 0;
  if BorderStyle = acbsnone then Exit;
  if BorderStyle in [acbsToolWindow, acbsSingle, acbsDialog]
    then Result := GetSystemMetrics(SM_CYFIXEDFRAME)
    else Result := GetSystemMetrics(SM_CYSIZEFRAME);
end;

function TacDialogWnd.SysBorderWidth: integer;
begin
  Result := 0;
  if BorderStyle = acbsnone then Exit;
  if BorderStyle in [acbsToolWindow, acbsSingle, acbsDialog]
    then Result := GetSystemMetrics(SM_CXFIXEDFRAME)
    else Result := GetSystemMetrics(SM_CXSIZEFRAME);
end;

function TacDialogWnd.SysButtonWidth(Btn: TsCaptionButton): integer;
begin
  if SkinData.SkinManager.IsValidImgIndex(Btn.ImageIndex) then begin
    if SkinData.SkinManager.ma[Btn.ImageIndex].Bmp = nil
     then Result := WidthOf(SkinData.SkinManager.ma[Btn.ImageIndex].R) div SkinData.SkinManager.ma[Btn.ImageIndex].ImageCount
     else Result := SkinData.SkinManager.ma[Btn.ImageIndex].Bmp.Width div SkinData.SkinManager.ma[Btn.ImageIndex].ImageCount;
  end
  else Result := 21;
end;

function TacDialogWnd.TitleBtnsWidth: integer;
begin
  Result := 0;
  if VisibleClose then begin
    inc(Result, SysButtonWidth(ButtonClose));
    if VisibleMax then inc(Result, SysButtonWidth(ButtonMax));
    if VisibleMin then inc(Result, SysButtonWidth(ButtonMin));
    if VisibleHelp then inc(Result, SysButtonWidth(ButtonHelp));
  end;
end;

function TacDialogWnd.VisibleClose: boolean;
begin
  Result := dwStyle and WS_SYSMENU = WS_SYSMENU                
end;

function TacDialogWnd.VisibleHelp: boolean;
begin
  Result := dwExStyle and WS_EX_CONTEXTHELP = WS_EX_CONTEXTHELP
end;

function TacDialogWnd.VisibleMax: boolean;
begin
  Result := dwStyle and WS_MAXIMIZEBOX = WS_MAXIMIZEBOX

end;

function TacDialogWnd.VisibleMin: boolean;
begin
  Result := dwStyle and WS_MINIMIZEBOX = WS_MINIMIZEBOX
end;

procedure TacDialogWnd.Ac_WMNCPaint(var Message: TMessage);
var
  DC, SavedDC : hdc;
  i : integer;
begin
  Provider.InitHwndControls(CtrlHandle);


  GetWindowRect(CtrlHandle, WndRect);
  WndSize.cx := WidthOf(WndRect);
  WndSize.cy := HeightOf(WndRect);


  if not RgnChanging and RgnChanged and ((BorderStyle <> acbsNone) or (dwStyle and WS_SIZEBOX = WS_SIZEBOX)) then begin
    FillArOR(Self);
    RgnChanged := False;
    if not RgnChanging then UpdateRgn(Self);
  end;

  DC := GetWindowDC(CtrlHandle);
  SavedDC := SaveDC(DC);
  try
    if (BorderStyle = acbsNone) and (dwStyle and WS_SIZEBOX = WS_SIZEBOX) then begin // v4.14
      if SkinData.BGChanged then begin
        PaintAll;
        SkinData.BGChanged := False;
        SkinData.Updating := False;
      end;
      i := 3;
      // Title and menu line update
      BitBlt(DC, 0, 0, WndSize.cx, i, SkinData.FCacheBmp.Canvas.Handle, 0, 0, SRCCOPY);
      // Left border update
      BitBlt(DC, 0, i, i, SkinData.FCacheBmp.Height, SkinData.FCacheBmp.Canvas.Handle, 0, i, SRCCOPY);
      // Bottom border update
      BitBlt(DC, i, WndSize.cy - i, WndSize.cx - i, i, SkinData.FCacheBmp.Canvas.Handle, i, WndSize.cy - i, SRCCOPY);
      // Right border update
      BitBlt(DC, SkinData.FCacheBmp.Width - i, i, i, SkinData.FCacheBmp.Height, SkinData.FCacheBmp.Canvas.Handle, SkinData.FCacheBmp.Width - i, i, SRCCOPY);
    end
    else PaintCaption(DC);
  finally
    RestoreDC(DC, SavedDC);
    ReleaseDC(CtrlHandle, DC);
  end;
  SkinData.Updating := False;//SkinData.Updating;

  RgnChanging := False;
end;

procedure TacDialogWnd.PaintCaption(dc: hdc);
var
  h, bw, bh : integer;
begin
  h := SysBorderHeight + CaptionHeight;
  if IsIconic(CtrlHandle) then inc(h);
  if SkinData.BGChanged then begin
    PaintAll;
    SkinData.BGChanged := False;
    SkinData.Updating := False;
  end;

  bw := BorderWidth;
  bh := BorderHeight;
  // Title update
  BitBlt(DC, 0, 0, WndSize.cx, HeaderHeight, SkinData.FCacheBmp.Canvas.Handle, 0, 0, SRCCOPY);
  // Left border update
  BitBlt(DC, 0, h, SysBorderwidth, SkinData.FCacheBmp.Height, SkinData.FCacheBmp.Canvas.Handle, 0, h, SRCCOPY);

  // Bottom border update
  BitBlt(DC, bw, WndSize.cy - bh, WndSize.cx - bw, bh,
             SkinData.FCacheBmp.Canvas.Handle,
             SysBorderwidth,
             WndSize.cy - SysBorderHeight, SRCCOPY);
  // Right border update
  BitBlt(DC, SkinData.FCacheBmp.Width - SysBorderWidth, h{ + BorderWidth}, SysBorderHeight, SkinData.FCacheBmp.Height, SkinData.FCacheBmp.Canvas.Handle, SkinData.FCacheBmp.Width - SysBorderwidth, h, SRCCOPY);

  if Assigned(acMagnForm) then SendMessage(acMagnForm.Handle, SM_ALPHACMD, MakeWParam(0, AC_REFRESH), 0);
end;

function TacDialogWnd.BorderHeight: integer;
begin
  Result := SysBorderHeight
end;

procedure TacDialogWnd.UpdateIconsIndexes;
begin
  if SkinData.SkinManager.IsValidSkinIndex(SkinData.SkinManager.ConstData.IndexGlobalInfo) then begin
    ButtonClose.ImageIndex := SkinData.SkinManager.GetMaskIndex(SkinData.SkinManager.ConstData.IndexGlobalInfo, s_GlobalInfo, s_BorderIconClose);
    if ButtonClose.ImageIndex > -1 then with SkinData.SkinManager do begin // For compatibility with skins with version < 4.33
      if BorderStyle in [acbsSingle, acbsSizeable] then begin
        ButtonMin.ImageIndex    := GetMaskIndex(ConstData.IndexGlobalInfo, s_GlobalInfo, s_BorderIconMinimize);
        ButtonMax.ImageIndex    := GetMaskIndex(ConstData.IndexGlobalInfo, s_GlobalInfo, s_BorderIconMaximize);
        ButtonClose.ImageIndex  := GetMaskIndex(ConstData.IndexGlobalInfo, s_GlobalInfo, s_BorderIconClose);
        ButtonHelp.ImageIndex   := GetMaskIndex(ConstData.IndexGlobalInfo, s_GlobalInfo, s_BorderIconHelp);
      end
      else begin
        ButtonClose.ImageIndex  := GetMaskIndex(ConstData.IndexGlobalInfo, s_GlobalInfo, s_SmallIconClose);
        ButtonMin.ImageIndex    := GetMaskIndex(ConstData.IndexGlobalInfo, s_GlobalInfo, s_SmallIconMinimize);
        ButtonMax.ImageIndex    := GetMaskIndex(ConstData.IndexGlobalInfo, s_GlobalInfo, s_SmallIconMaximize);
        ButtonHelp.ImageIndex   := GetMaskIndex(ConstData.IndexGlobalInfo, s_GlobalInfo, s_SmallIconHelp);
        if ButtonHelp.ImageIndex < 0 then ButtonHelp.ImageIndex := GetMaskIndex(ConstData.IndexGlobalInfo, s_GlobalInfo, s_BorderIconHelp);
      end;
      if ButtonClose.ImageIndex < 0 then begin
        ButtonClose.ImageIndex  := GetMaskIndex(ConstData.IndexGlobalInfo, s_GlobalInfo, s_BorderIconClose);
        ButtonMin.ImageIndex    := GetMaskIndex(ConstData.IndexGlobalInfo, s_GlobalInfo, s_BorderIconMinimize);
        ButtonMax.ImageIndex    := GetMaskIndex(ConstData.IndexGlobalInfo, s_GlobalInfo, s_BorderIconMaximize);
        ButtonHelp.ImageIndex   := GetMaskIndex(ConstData.IndexGlobalInfo, s_GlobalInfo, s_BorderIconHelp);
      end;
    end
    else begin
      ButtonMin.ImageIndex    := SkinData.SkinManager.GetMaskIndex(SkinData.SkinIndex, s_Form, s_BorderIconMinimize);
      ButtonMax.ImageIndex    := SkinData.SkinManager.GetMaskIndex(SkinData.SkinIndex, s_Form, s_BorderIconMaximize);
      ButtonClose.ImageIndex  := SkinData.SkinManager.GetMaskIndex(SkinData.SkinIndex, s_Form, s_BorderIconClose);
      ButtonHelp.ImageIndex   := SkinData.SkinManager.GetMaskIndex(SkinData.SkinIndex, s_Form, s_BorderIconHelp);
    end;
  end;
end;

function TacDialogWnd.ButtonHeight(Index: integer): integer;
begin
  if SkinData.SkinManager.IsValidImgIndex(Index) then begin
    if SkinData.SkinManager.ma[Index].Bmp = nil
      then Result := HeightOf(SkinData.SkinManager.ma[Index].R) div (1 + SkinData.SkinManager.ma[Index].MaskType)
      else Result := SkinData.SkinManager.ma[Index].Bmp.Height div 2;
  end
  else Result := 21;
end;

procedure TacDialogWnd.AdapterCreate;
begin
end;

procedure TacDialogWnd.AdapterRemove;
begin
  SendToAdapter(MakeMessage(SM_ALPHACMD, MakeWParam(0, AC_REMOVESKIN), LongWord(SkinData.SkinManager), 0));
  FreeAndNil(Adapter);
end;

procedure TacDialogWnd.SendToAdapter(Message: TMessage);
begin

⌨️ 快捷键说明

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