📄 acdials.pas
字号:
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{ + BorderWidth}, 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
if Assigned(Adapter) then Adapter.WndProc(Message)
end;
function TacDialogWnd.VisibleRestore: boolean;
begin
Result := not (BorderStyle in [acbsDialog, acbsNone, acbsSizeToolWin, acbsToolWindow]) and VisibleClose;
end;
procedure TacDialogWnd.Ac_WMNCHitTest(var Message: TMessage);
begin
Message.Result := HTProcess(TWMNCHitTest(Message));
case Message.Result of
Windows.HTCAPTION, Windows.HTNOWHERE : begin
Message.Result := CallWindowProc(OldProc, CtrlHandle, Message.Msg, Message.WParam, Message.LParam);
SetHotHT(0);
end;
end;
end;
function TacDialogWnd.HTProcess(var Message: TWMNCHitTest): integer;
const
BtnSpacing = 1;
var
p : TPoint;
cy1, cy2 : integer;
i, SysBtnCount, BtnIndex : integer;
b : boolean;
function GetBtnIndex(x : integer) : integer;
var
c : integer;
begin
Result := 0;
c := 0;
if VisibleClose then begin
inc(c);
if Between(x, ButtonClose.Rect.Left, ButtonClose.Rect.Right) then begin// CaptionWidth - SysBorderWidth - l, CaptionWidth - SysBorderWidth - l + w) then begin
Result := c;
Exit;
end;
if VisibleMax then begin
inc(c);
if Between(x, ButtonMax.Rect.Left, ButtonMax.Rect.Right) then begin
Result := c;
Exit;
end;
end;
if VisibleMin then begin
inc(c);
if Between(x, ButtonMin.Rect.Left, ButtonMin.Rect.Right) then begin
Result := c;
Exit;
end;
end;
if VisibleHelp then begin
inc(c);
if Between(x, ButtonHelp.Rect.Left, ButtonHelp.Rect.Right) then begin
Result := c;
Exit;
end;
end;
end;
end;
begin
p := CursorToPoint(Message.XPos, Message.YPos);
cy1 := (CaptionHeight - ButtonHeight(ButtonClose.ImageIndex) + SysBorderHeight) div 2;
cy2 := cy1 + ButtonHeight(ButtonClose.ImageIndex);
if Between(p.y, cy1, cy2) then begin // If in buttons
if Between(p.x, SysBorderWidth, SysBorderWidth + GetSystemMetrics(SM_CXSMICON)) // If system menu icon
then begin SetHotHT(HTSYSMENU); Result := HTSYSMENU; Exit; end;
// Title button?
SysBtnCount := 0;
if VisibleClose then inc(SysBtnCount);
if VisibleMax then inc(SysBtnCount);
if VisibleMin or IsIconic(CtrlHandle) then inc(SysBtnCount);
if VisibleHelp then inc(SysBtnCount);
BtnIndex := GetBtnIndex(p.x);
if (BtnIndex > 0) and (BtnIndex <= SysBtnCount) then begin // If system button
case BtnIndex of
1 : if VisibleClose then begin
SetHotHT(HTCLOSE); Result := HTCLOSE; Exit;
end;
2 : begin
if VisibleMax then begin
if (EnabledMax or EnabledRestore) then begin
SetHotHT(HTMAXBUTTON); Result := HTMAXBUTTON; Exit;
end
else begin
SetHotHT(HTCAPTION); Result := HTCAPTION; Exit;
end;
end
else if VisibleMin or IsIconic(CtrlHandle) then begin
if EnabledMin then begin
SetHotHT(HTMINBUTTON); Result := HTMINBUTTON; Exit;
end
else begin
SetHotHT(HTCAPTION); Result := HTCAPTION; Exit;
end;
end
else if VisibleHelp then begin
SetHotHT(HTHELP); Result := HTHELP; EXIT;
end;
end;
3 : begin
if (VisibleMin) or IsIconic(CtrlHandle) then begin
if not IsIconic(CtrlHandle) then begin
if EnabledMin then begin
SetHotHT(HTMINBUTTON); Result := HTMINBUTTON; Exit;
end
else begin
SetHotHT(HTCAPTION); Result := HTCAPTION; Exit;
end;
end
else begin
SetHotHT(HTMINBUTTON); Result := HTMINBUTTON; Exit;
end;
end
else if VisibleHelp then begin
SetHotHT(HTHELP); Result := HTHELP; EXIT;
end;
end;
4 : if VisibleHelp and VisibleMax then begin
SetHotHT(HTHELP); Result := HTHELP; EXIT;
end;
end;
end
else begin
Result := HTCAPTION;
Exit;
end;
end
else begin
if (BorderStyle = acbsSizeable) or (BorderStyle = acbsSizeToolWin) then begin
i := SkinData.SkinManager.GetMaskIndex(SkinData.SkinManager.ConstData.IndexGLobalInfo, s_GlobalInfo{SkinData.SkinSection}, s_GripImage);
if SkinData.SkinManager.IsValidImgIndex(i) then begin
if (p.y > RBGripPoint(i).y) and (p.x > RBGripPoint(i).x) then begin
Result := HTBOTTOMRIGHT; Exit;
end;
end;
end;
end;
b := IsZoomed(CtrlHandle);
if b and AboveBorder(Message) then Result := HTTRANSPARENT else Result := Message.Result;
end;
procedure TacDialogWnd.SetHotHT(i: integer; Repaint: boolean);
begin
if (CurrentHT = i) then Exit;
if (CurrentHT <> 0) then begin
case CurrentHT of
HTCLOSE : ButtonClose.State := 0;
HTMAXBUTTON : ButtonMax.State := 0;
HTMINBUTTON : ButtonMin.State := 0;
HTHELP : ButtonHelp.State := 0;
end;
if Repaint then RepaintButton(CurrentHT);
end;
CurrentHT := i;
case CurrentHT of
HTCLOSE : ButtonClose.State := 1;
HTMAXBUTTON : ButtonMax.State := 1;
HTMINBUTTON : ButtonMin.State := 1;
HTHELP : ButtonHelp.State := 1;
end;
biClicked := False;
if Repaint then RepaintButton(CurrentHT);
end;
function TacDialogWnd.CursorToPoint(x, y: integer): TPoint;
begin
Result := WndRect.TopLeft;
Result.x := x - Result.x;
Result.y := y - Result.y;
end;
function TacDialogWnd.AboveBorder(Message: TWMNCHitTest): boolean;
var
p : TPoint;
begin
p := CursorToPoint(Message.XPos, Message.YPos);
Result := not PtInRect(Rect(2, 2, WndSize.cx - 4, WndSize.cy - 4), p);
if Result then SetHotHT(0);
end;
procedure TacDialogWnd.RepaintButton(i: integer);
var
DC, SavedDC : hdc;
CurButton : TsCaptionButton;
cx, ind : integer;
BtnDisabled : boolean;
begin
CurButton.State := -1;
case i of
HTCLOSE : CurButton := ButtonClose;
HTMAXBUTTON : CurButton := ButtonMax;
HTMINBUTTON : CurButton := ButtonMin;
HTHELP : CurButton := ButtonHelp;
end;
if CurButton.State <> -1 then begin
BtnDisabled := False;
if CurButton.Rect.Left <= GetSystemMetrics(SM_CXSMICON) + BorderWidth then Exit;
cx := SkinData.FCacheBmp.Width - CurButton.Rect.Left;
BitBlt(SkinData.FCacheBmp.Canvas.Handle, // Restore a button BG
CurButton.Rect.Left, CurButton.Rect.Top, SysButtonwidth(CurButton), ButtonHeight(CurButton.ImageIndex),
TempBmp.Canvas.Handle, TempBmp.Width - cx, CurButton.Rect.Top, SRCCOPY);
// if Max btn and form is maximized then Norm btn
if (i = HTMAXBUTTON) and IsZoomed(CtrlHandle) then ind := SkinData.SkinManager.GetMaskIndex(SkinData.SkinIndex, s_GlobalInfo, s_BorderIconNormalize)
else if IsIconic(CtrlHandle) then begin
case i of
HTMINBUTTON : begin
ind := SkinData.SkinManager.GetMaskIndex(SkinData.SkinManager.ConstData.IndexGlobalInfo, s_GlobalInfo, s_BorderIconNormalize);
if ind < 0 then ind := SkinData.SkinManager.GetMaskIndex(SkinData.SkinIndex, SkinData.SkinSection, s_BorderIconNormalize); // For compatibility
end;
HTMAXBUTTON : begin
ind := SkinData.SkinManager.GetMaskIndex(SkinData.SkinManager.ConstData.IndexGlobalInfo, s_GlobalInfo, s_BorderIconMaximize);
if ind < 0 then ind := SkinData.SkinManager.GetMaskIndex(SkinData.SkinIndex, SkinData.SkinSection, s_BorderIconMaximize); // For compatibility
if not EnabledMax then BtnDisabled := True;
end
else ind := CurButton.ImageIndex;
end
end else ind := CurButton.ImageIndex;
if SkinData.SkinManager.IsValidImgIndex(ind) then begin // Drawing of the button from skin
if i < HTUDBTN // if not user defined
then DrawSkinGlyph(SkinData.FCacheBmp, Point(CurButton.Rect.Left, CurButton.Rect.Top),
CurButton.State, 1 + integer(not boolean(FormActive) or BtnDisabled) * integer(not (CurButton.State > 0) or BtnDisabled), SkinData.SkinManager.ma[ind]);
end;
// Copying to form
DC := GetWindowDC(CtrlHandle);
SavedDC := SaveDC(DC);
try
BitBlt(DC, CurButton.Rect.Left, CurButton.Rect.Top, WidthOf(CurButton.Rect), HeightOf(CurButton.Rect),
SkinData.FCacheBmp.Canvas.Handle, CurButton.Rect.Left, CurButton.Rect.Top, SRCCOPY);
finally
RestoreDC(DC, SavedDC);
ReleaseDC(CtrlHandle, DC);
end;
end;
end;
procedure TacDialogWnd.Ac_WMNCLButtonDown(var Message: TWMNCLButtonDown);
begin
case TWMNCLButtonDown(Message).HitTest of
HTCLOSE, HTMAXBUTTON, HTMINBUTTON, HTHELP, HTCHILDCLOSE..HTCHILDMIN : begin
SetPressedHT(TWMNCLButtonDown(Message).HitTest);
end;
HTSYSMENU : begin
if True{SkinData.SkinManager.SkinnedPopups} then begin
SetHotHT(0);
DropSysMenu(WndRect.Left + SysBorderWidth, WndRect.Top + BorderHeight + GetSystemMetrics(SM_CYSMICON));
end
else Message.Result := CallWindowProc(OldProc, CtrlHandle, Message.Msg, TMessage(Message).WParam, TMessage(Message).LParam);
end
else begin
if IsIconic(CtrlHandle) then begin
SendMessage(CtrlHandle, WM_SYSCOMMAND, $F012, 0);
end
else begin
SetHotHT(0);
if not IsZoomed(CtrlHandle) or (CursorToPoint(0, TWMNCLButtonDown(Message).YCursor).y > SysBorderHeight + CaptionHeight) then begin
Message.Result := CallWindowProc(OldProc, CtrlHandle, Message.Msg, TMessage(Message).WParam, TMessage(Message).LParam);
end
else if FormActive = 0 then SetFocus(CtrlHandle);
end;
end
end;
end;
procedure TacDialogWnd.SetPressedHT(i: integer);
begin
if (CurrentHT <> i
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -