📄 acdials.pas
字号:
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
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) and (CurrentHT <> 0) then begin
case CurrentHT of
HTCLOSE : ButtonClose.State := 0;
HTMAXBUTTON : ButtonMax.State := 0;
HTMINBUTTON : ButtonMin.State := 0;
HTHELP : ButtonHelp.State := 0;
end;
RepaintButton(CurrentHT);
end;
CurrentHT := i;
case CurrentHT of
HTCLOSE : ButtonClose.State := 2;
HTMAXBUTTON : if EnabledMax or (IsZoomed(CtrlHandle) and EnabledRestore) then ButtonMax.State := 2;
HTMINBUTTON : ButtonMin.State := 2;
HTHELP : ButtonHelp.State := 2;
end;
biClicked := True;
RepaintButton(CurrentHT);
end;
procedure TacDialogWnd.DropSysMenu(x, y: integer);
begin
SystemMenu.WindowHandle := CtrlHandle;
SystemMenu.Popup(x, y);
end;
procedure TacDialogWnd.Ac_WMLButtonUp(var Message: TMessage);
var
p : TPoint;
begin
case TWMNCHitMessage(Message).HitTest of
HTCLOSE : if biClicked then begin
ButtonClose.State := 0;
SendMessage(CtrlHandle, WM_SYSCOMMAND, SC_CLOSE, 0);
end;
HTMAXBUTTON : if not IsIconic(CtrlHandle) or (IsIconic(CtrlHandle) and EnabledMax) then begin
if biClicked then begin
SetHotHT(0);
if IsZoomed(CtrlHandle) then begin
SendMessage(CtrlHandle, WM_SYSCOMMAND, SC_RESTORE, 0);
end
else begin
SendMessage(CtrlHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
end;
Application.ProcessMessages;
SystemMenu.UpdateItems;
end
else SetHotHT(0);
end;
HTMINBUTTON : if biClicked then begin
p := CursorToPoint(TWMMouse(Message).XPos, TWMMouse(Message).YPos);
if PtInRect(ButtonMin.Rect, p) then begin
SetHotHT(0);
if IsIconic(CtrlHandle) then begin
SendMessage(CtrlHandle, WM_SYSCOMMAND, SC_RESTORE, 0);
end
else SendMessage(CtrlHandle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
end
else Message.Result := CallWindowProc(OldProc, CtrlHandle, Message.Msg, Message.WParam, Message.LParam);
end else SetHotHT(0);
HTHELP : if biClicked then begin
SendMessage(CtrlHandle, WM_SYSCOMMAND, SC_CONTEXTHELP, 0);
SetHotHT(0);
SystemMenu.UpdateItems;
SendMessage(CtrlHandle, WM_NCPAINT, 0, 0);
end else SetHotHT(0);
// MDI child buttons
else begin
Message.Result := CallWindowProc(OldProc, CtrlHandle, Message.Msg, Message.WParam, Message.LParam);
end
end;
TWMNCHitMessage(Message).HitTest := 0;
end;
procedure TacDialogWnd.Ac_WMNCActivate(var Message: TMessage);
begin
SendMessage(CtrlHandle, WM_NCPAINT, 0, 0);
end;
procedure TacDialogWnd.Ac_WMActivate(var Message: TMessage);
begin
SkinData.BGChanged := True;
RedrawWindow(CtrlHandle, nil, 0, RDW_ALLCHILDREN or RDW_FRAME or RDW_INVALIDATE or RDW_UPDATENOW);
if Assigned(SystemMenu)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -