📄 sskinprovider.pas
字号:
// Menu Line refresh
FCommonData.BGChanged := True;
FLinesCount := -1;
SendMessage(Form.Handle, WM_NCPaint, 0, 0);
if (TForm(Form).FormStyle = fsMDIForm) then begin
if not Assigned(MDIForm) then HookMDI;
TsMDIForm(MDIForm).ConnectToClient
end;
end;
end;
AC_BEFORESCROLL : begin
if FCommonData.RepaintIfMoved then begin
SendMessage(Form.Handle, WM_SETREDRAW, 0, 0);
end;
end;
AC_AFTERSCROLL : begin
if FCommonData.RepaintIfMoved then begin
SendMessage(Form.Handle, WM_SETREDRAW, 1, 0);
RedrawWindow(Form.Handle, nil, 0, RDW_NOERASE or RDW_UPDATENOW or RDW_INVALIDATE or RDW_ALLCHILDREN or RDW_FRAME);
if MDISkinProvider = Self then begin
RedrawWindow(Form.ClientHandle, nil, 0, RDW_NOERASE or RDW_UPDATENOW or RDW_INVALIDATE or RDW_ALLCHILDREN or RDW_FRAME);
end;
end;
end;
AC_URGENTPAINT : begin // v4.08
CommonWndProc(Message, FCommonData);
if FCommonData.UrgentPainting then PaintAll;
Exit;
end;
end
else case Message.Msg of
WM_INITMENUPOPUP : begin
if Message.LParam <> 0 then acCanHookMenu := True; // Menu skinning is supported
OldWndProc(Message);
end;
CM_SHOWINGCHANGED : if FCommonData.BGChanged and (Win32MajorVersion < 6) then begin // If first showing
fAnimating :=
(Form.FormStyle <> fsMDIChild) and (Form.Parent = nil) and
((Form.BorderStyle = bsDialog) and SkinData.SkinManager.AnimEffects.DialogShow.Active or
(Form.BorderStyle <> bsDialog) and SkinData.SkinManager.AnimEffects.FormShow.Active);
if fAnimating then SendMessage(Form.Handle, WM_SETREDRAW, 0, 0);
OldWndProc(Message);
RefreshFormScrolls(Self, ListSW, False);
if fAnimating then begin
fAnimating := False;
if (Form.BorderStyle = bsDialog)
then i := SkinData.SkinManager.AnimEffects.DialogShow.Time
else i := SkinData.SkinManager.AnimEffects.FormShow.Time;
AnimShowControl(Form, i);
SendMessage(Form.Handle, WM_SETREDRAW, 1, 0);
UpdateRgn(Self, False);
RedrawWindow(Form.Handle, nil, 0, RDW_NOERASE or RDW_UPDATENOW or RDW_INVALIDATE or RDW_ALLCHILDREN or RDW_FRAME);
RgnChanging := False;
end;
if (Form.FormStyle = fsMDIChild) and (Form.WindowState = wsMaximized) then begin
TsSkinProvider(MDISkinProvider).RepaintMenu;
end;
end else OldWndProc(Message);
WM_SHOWWINDOW : begin
OldWndProc(Message);
if (Form.FormStyle = fsMDIChild) and (Form.WindowState = wsMaximized) then begin
TsSkinProvider(MDISkinProvider).RepaintMenu;
end;
end;
WM_SETTEXT : if Form.Visible then begin
MakeCaptForm(Self);
OldWndProc(Message);
if HaveBorder(Self) then begin
FCommonData.BGChanged := True;
Form.Perform(WM_NCPAINT, 0, 0);
end;
if Assigned(CaptForm) then FreeAndNil(CaptForm); // The Dillinger Escape Plan
end else OldWndProc(Message);
CM_ENABLEDCHANGED : begin
OldWndProc(Message);
SkinData.BGChanged := True;
SendMessage(Form.Handle, WM_NCPAINT, 0, 0);
end;
WM_SYSCOLORCHANGE : begin
OldWndProc(Message);
UpdateMenu;
end;
WM_CHILDACTIVATE : begin
OldWndProc(Message);
UpdateMenu;
if (MDISkinProvider <> nil) and (TsSkinProvider(MDISkinProvider).Form.ActiveMDIChild <> nil) then begin
if TsSkinProvider(MDISkinProvider).Form.ActiveMDIChild.WindowState = wsMaximized
then UpdateSkinCaption(TsSkinProvider(MDISkinProvider));
end;
end;
WM_SIZE : begin
FCommonData.BGChanged := True;
RgnChanged := True;
OldWndProc(Message);
if Form.Visible then begin
// Repaint MDI child buttons
if (Form.FormStyle = fsMDIChild) then begin
if (Form.WindowState = wsMaximized) then begin
TsSkinProvider(MDISkinProvider).FCommonData.BGChanged := (FCommonData.FCacheBmp.Width = CaptionWidth) or (FCommonData.FCacheBmp.Height = Form.Height);
SendMessage(TsSkinProvider(MDISkinProvider).Form.Handle, WM_NCPAINT, 0, 0);
end;
end;
if FCommonData.Skinned and // v4.27
(Length(FCommonData.SkinManager.gd) > FCommonData.SkinIndex) and
(FCommonData.SkinManager.gd[FCommonData.SkinIndex].GradientPercent > 0) then begin // If controls must be repainted
for i := 0 to Form.ControlCount - 1 do
if (i < Form.ControlCount) and not (csDestroying in Form.Controls[i].ComponentState)
then Form.Controls[i].Perform(SM_ALPHACMD, MakeWParam(1, AC_SETCHANGEDIFNECESSARY), 0);
end;
RedrawWindow(Form.Handle, nil, 0, RDW_INVALIDATE or RDW_UPDATENOW or RDW_ALLCHILDREN or RDW_FRAME);
end;
end;
WM_ENTERMENULOOP : begin
if (Form.FormStyle = fsMDIForm) and not InMenu and (Form.ActiveMDIChild <> nil) and (Form.ActiveMDIChild.WindowState = wsMaximized) then begin
InMenu := True;
if MDIIconsForm = nil then MDIIconsForm := TForm.Create(Application);
MDIIconsForm.Visible := False;
MDIIconsForm.Tag := -98;
MDIIconsForm.Name := 'acMDIIcons';
// MDIIconsForm.Tag := longint(Self);
MDIIconsForm.OnPaint := MdiIcoFormPaint;
MDIIconsForm.BorderStyle := bsNone;
SetWindowPos(MDIIconsForm.Handle, 0,
Form.BoundsRect.Right - 60, Form.Top + CaptionHeight, 60, GetSystemMetrics(SM_CYMENU) - 1 + 4,
SWP_NOACTIVATE or SWP_SHOWWINDOW or SWP_NOREDRAW);
end;
OldWndProc(Message);
end;
WM_EXITMENULOOP : begin
InMenu := False;
if Assigned(MDIIconsForm) then FreeAndNil(MDIIconsForm);
OldWndProc(Message);
end;
WM_GETMINMAXINFO : begin
PMinMaxInfo(Message.LParam)^.ptMaxTrackSize.x := -1;
PMinMaxInfo(Message.LParam)^.ptMaxTrackSize.y := -1;
PMinMaxInfo(Message.LParam)^.ptMaxPosition.x := -1;
PMinMaxInfo(Message.LParam)^.ptMaxPosition.y := -1;
OldWndProc(Message);
cR := WorkRect;
if PMinMaxInfo(Message.LParam)^.ptMaxTrackSize.x = -1 then PMinMaxInfo(Message.LParam)^.ptMaxTrackSize.x := WidthOf(cR) + integer(Form.BorderStyle <> bsNone) * SysBorderWidth * 2;
if PMinMaxInfo(Message.LParam)^.ptMaxTrackSize.y = -1 then PMinMaxInfo(Message.LParam)^.ptMaxTrackSize.y := HeightOf(cR) + integer(Form.BorderStyle <> bsNone) * SysBorderWidth * 2;
if PMinMaxInfo(Message.LParam)^.ptMaxPosition.x = -1 then PMinMaxInfo(Message.LParam)^.ptMaxPosition.x := {cR.Left} - integer(Form.BorderStyle <> bsNone) * SysBorderWidth;
if PMinMaxInfo(Message.LParam)^.ptMaxPosition.y = -1 then PMinMaxInfo(Message.LParam)^.ptMaxPosition.y := {cR.Top} - integer(Form.BorderStyle <> bsNone) * SysBorderWidth;
end;
WM_NCHITTEST : begin
if CaptionHeight = 0 then begin
OldWndProc(Message);
end
else begin
Message.Result := HTProcess(TWMNCHitTest(Message));
case Message.Result of
Windows.HTCAPTION : begin
OldWndProc(Message);
SetHotHT(0);
end;
Windows.HTNOWHERE : begin
OldWndProc(Message);
SetHotHT(0);
end;
end;
if (ResizeMode = rmBorder) and { MarkB } (nDirection = 0) and
(Message.Result in [HTCAPTION, HTBOTTOM, HTBOTTOMLEFT, HTBOTTOMRIGHT, HTLEFT,
HTRIGHT, HTTOP, HTTOPLEFT, HTTOPRIGHT]) then nDirection := Message.Result;
end;
end;
WM_SIZING : begin
OldWndProc(Message);
if FormChanged then begin
FCommonData.BGChanged := True;
FLinesCount := -1;
end;
end;
WM_MOUSELEAVE, CM_MOUSELEAVE : begin
SetHotHT(0);
OldWndProc(Message);
end;
CM_MOUSEENTER : begin
OldWndProc(Message);
for i := 0 to Form.ControlCount - 1 do begin
if (Form.Controls[i] is TsSpeedButton) and (Form.Controls[i] <> Pointer(Message.LParam)) and TsSpeedButton(Form.Controls[i]).SkinData.FMouseAbove then begin
Form.Controls[i].Perform(CM_MOUSELEAVE, 0, 0)
end;
end;
end;
WM_NCLBUTTONDOWN : begin
case TWMNCLButtonDown(Message).HitTest of
HTCLOSE, HTMAXBUTTON, HTMINBUTTON, HTHELP, HTCHILDCLOSE..HTCHILDMIN : begin
if Assigned(ChildProvider) then begin
if ((TWMNCLButtonDown(Message).HitTest = HTCHILDMIN) and not ChildProvider.SystemMenu.EnabledMin) or
((TWMNCLButtonDown(Message).HitTest = HTCHILDMAX) and not ChildProvider.SystemMenu.EnabledRestore)
then Exit;
end;
SetPressedHT(TWMNCLButtonDown(Message).HitTest);
end;
HTSYSMENU : begin
if True{SkinData.SkinManager.SkinnedPopups} then begin
SetHotHT(0);
if Form.FormStyle = fsMDIChild then begin
if Assigned(MDISkinProvider) then begin
p := FormLeftTop;
DropSysMenu(p.x, p.y + CaptionHeight + 4);
end;
end
else begin
DropSysMenu(FormLeftTop.x + SysBorderWidth, FormLeftTop.y + BorderHeight + HeightOf(IconRect));
end;
end
else OldWndProc(Message);
end
else if BetWeen(TWMNCLButtonDown(Message).HitTest, HTUDBTN, HTUDBTN + TitleButtons.Count - 1) then begin
SetPressedHT(TWMNCLButtonDown(Message).HitTest);
TitleButtons.Items[TWMNCHitMessage(Message).HitTest - HTUDBTN].MouseDown(TWMNCHitMessage(Message).HitTest - HTUDBTN, mbLeft, [], TWMNCHitMessage(Message).XCursor, TWMNCHitMessage(Message).YCursor);
end
else begin
if IsIconic(Form.Handle) then begin
Form.Perform(WM_SYSCOMMAND, $F012, 0);
end
else begin
SetHotHT(0);
if (Form.WindowState <> wsMaximized) or (CursorToPoint(0, TWMNCLButtonDown(Message).YCursor).y > SysBorderHeight + CaptionHeight) then begin
if (ResizeMode = rmBorder) and not (TWMNCLButtonDown(Message).HitTest in [HTMENU]) then begin // MarkB
// If caption pressed then activate form (standard procedure)
if (TWMNCLButtonDown(Message).HitTest in [HTMENU, HTCAPTION]) then OldWndProc(Message);
bMode := not (TWMNCLButtonDown(Message).HitTest in [HTRIGHT, HTLEFT, HTBOTTOM, HTTOP, HTTOPLEFT, HTTOPRIGHT, HTBOTTOMLEFT, HTBOTTOMRIGHT]);
p := Point(TWMNCLButtonDown(Message).XCursor, TWMNCLButtonDown(Message).YCursor);
if bMode then SendMessage(Form.Handle, WM_SYSCOMMAND, SC_MOVE, 0) else SendMessage(Form.Handle, WM_SYSCOMMAND, SC_SIZE, 0);
StartMove(p.X, p.Y);
end
else OldWndProc(Message);
end
else if not Form.Active then Form.SetFocus; // Focusing if maximized
end;
end
end;
end;
WM_SETTINGCHANGE : begin
FCommonData.BGChanged := True;
if TitleBG <> nil then FreeAndNil(TitleBG);
OldWndProc(Message);
end;
WM_MOUSEMOVE : begin // MarkB
OldWndProc(Message);
if (DefaultManager <> nil) and not (csDesigning in DefaultManager.ComponentState) then DefaultManager.ActiveControl := 0;
if ResizeMode = rmBorder then begin
p := Form.ClientToScreen(Point(TWMMouseMove(Message).XPos, TWMMouseMove(Message).YPos));
X := p.X;
Y := p.Y;
if bMode then begin //Move section
if bCapture then begin
bCapture := FALSE;
end;
if bInProcess then begin
DrawFormBorder(nleft, ntop);
nleft := nleft + (X - nX);
ntop := ntop + (Y - nY);
nY := Y;
nX := X;
DrawFormBorder(nleft, ntop);
end;
end
else begin
//Size section
if bCapture then begin
nX := X;
nY := Y;
bCapture := False;
end;
if bInProcess then begin
DrawFormBorder(0, 0);
case nDirection of
HTLEFT : begin
nleft := Form.left + X - nX;
if nright - nleft < nMinWidth then nleft := nright - nMinWidth;
end;
HTRIGHT : begin
nright := Form.left + Form.width + X - nX;
if nright - nleft < nMinWidth then nright := Form.left + nMinWidth;
end;
HTBOTTOM : begin
nbottom := Form.top + Form.height + Y - nY;
if nbottom - ntop < nMinHeight then nbottom := Form.top + nMinHeight;
end;
HTTOP : begin
ntop := Form.top + Y - nY;
if nbottom - ntop < nMinHeight then ntop := nbottom - nMinHeight;
end;
HTBOTTOMLEFT : begin
nbottom := Form.top + Form.height + Y - nY;
if nbottom - ntop < nMinHeight then nbottom := Form.top + nMinHeight;
nleft := Form.left + X - nX;
if nright - nleft < nMinWidth then nleft := nright - nMinWidth;
end;
HTTOPRIGHT : begin
ntop := Form.top + Y - nY;
if nbottom - ntop < nMinHeight then ntop := nbottom - nMinHeight;
nright := Form.left + Form.width + X - nX;
if nright - nleft < nMinWidth then nright := Form.left + nMinWidth;
end;
HTTOPLEFT : begin
ntop := Form.top + Y - nY;
if nbottom - ntop < nMinHeight then ntop := nbottom - nMinHeight;
nleft := Form.left + X - nX;
if nright - nleft < nMinWidth then nleft := nright - nMinWidth;
end
else begin
nbottom := Form.top + Form.height + Y - nY;
if nbottom - ntop < nMinHeight then nbottom := Form.top + nMinHeight;
nright := Form.left + Form.width + X - nX;
if nright - nleft < nMinWidth then nright := Form.left + nMinWidth;
end;
end;
DrawFormBorder(0, 0);
end;
end;
end;
end;
WM_NCRBUTTONDOWN : begin
if not (TWMNCLButtonUp(Message).HitTest in [HTCA
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -