📄 acdials.pas
字号:
l, i : integer;
subrgn : HRGN;
begin
l := Length(ListSW.ArOR);
Result := CreateRectRgn(X, Y, ListSW.WndSize.cx + X, ListSW.WndSize.cy + Y);
if l > 0 then for i := 0 to l - 1 do begin
subrgn := CreateRectRgn(ListSW.ArOR[i].Left + X, ListSW.ArOR[i].Top + Y, ListSW.ArOR[i].Right + X, ListSW.ArOR[i].Bottom + Y);
CombineRgn(Result, Result, subrgn, RGN_DIFF);
DeleteObject(subrgn);
end;
end;
{ TacDialogWnd }
procedure TacDialogWnd.acWndProc(var Message: TMessage);
var
sw : TacMainWnd;
begin
{$IFDEF LOGGED}
// AddToLog(Message);
{$ENDIF}
case Message.Msg of
WM_DESTROY, WM_NCDESTROY: begin
if (OldProc <> nil) or Assigned(OldWndProc) then begin
sw := Self;
UninitializeACWnd(CtrlHandle, False, False, sw);
Message.Result := CallPrevWndProc(CtrlHandle, Message.Msg, Message.WParam, Message.LParam);
end;
Exit;
end;
end;
if Message.Msg = SM_ALPHACMD then case Message.WParamHi of
AC_SETNEWSKIN : begin
if (LongWord(Message.LParam) = LongWord(SkinData.SkinManager)) then begin
SkinData.UpdateIndexes;
if (SkinData.SkinManager <> nil) then UpdateIconsIndexes;
if Adapter = nil then AdapterCreate;
end;
Exit;
end;
AC_PREPARING : if (SkinData <> nil) then begin
Message.Result := integer(SkinData.BGChanged or SkinData.Updating);
Exit;
end;
AC_UPDATING : begin
SkinData.Updating := Message.WParamLo = 1;
if SkinData.Updating then SkinData.BGChanged := True;
end;
AC_GETCACHE : begin
GlobalCacheInfo := MakeCacheInfo(SkinData.FCacheBmp);//, OffsetX, OffsetY);
Exit;
end;
AC_GETCONTROLCOLOR : begin
if SkinData.Skinned then ParentCenterColor := SkinData.SkinManager.gd[SkinData.Skinindex].HotColor;
Exit;
end;
AC_UPDATECHILDREN : Provider.InitHwndControls(CtrlHandle); // SysListView re-init
AC_CHILDCHANGED : begin
Message.Result := integer((SkinData.SkinManager.gd[SkinData.SkinIndex].GradientPercent + SkinData.SkinManager.gd[SkinData.SkinIndex].ImagePercent > 0));
Exit;
end;
end
else case Message.Msg of
WM_GETDLGCODE : Exit;
WM_MOUSEMOVE : begin
if IsWindowEnabled(CtrlHandle) then DefaultManager.ActiveControl := 0;
end;
WM_ERASEBKGND : begin
case Provider.DlgType of
adtColorDlg : begin
SelectClipRgn(TWMPaint(Message).DC, ColorRgn);
Message.Result := CallWindowProc(OldProc, CtrlHandle, Message.Msg, Message.WParam, Message.LParam);
end
else Message.Result := 1;
end;
Exit;
end;
WM_NCHITTEST : begin
Ac_WMNCHitTest(Message);
Exit;
end;
WM_MOUSELEAVE : SetHotHT(0);
WM_NCLBUTTONDOWN : begin
Ac_WMNCLButtonDown(TWMNCLButtonDown(Message));
Exit;
end;
WM_NCRBUTTONDOWN : begin
if not (TWMNCLButtonUp(Message).HitTest in [HTCAPTION, HTSYSMENU]) then begin
inherited
end
else Exit;
end;
WM_CTLCOLORDLG : begin
Message.Result := LongInt(CreateSolidBrush(DefaultManager.GetGlobalColor)); // 5.21
Exit;
end;
WM_DRAWITEM : begin
case TWMDrawItem(Message).DrawItemStruct.CtlType of
ODT_COMBOBOX : begin
// Ac_DrawComboItem(Message);
end;
ODT_STATIC : begin
Ac_DrawStaticItem(TWMDrawItem(Message));
end;
end
end;
WM_NCRBUTTONUP : begin
case TWMNCLButtonUp(Message).HitTest of
HTCAPTION, HTSYSMENU : begin
SetHotHT(0);
DropSysMenu(TWMNCLButtonUp(Message).XCursor, TWMNCLButtonUp(Message).YCursor);
end
end;
Exit;
end;
WM_NCLBUTTONUP, WM_LBUTTONUP: begin
Ac_WMLButtonUp(Message);
Exit;
end;
WM_NCLBUTTONDBLCLK : begin
case TWMNCHitMessage(Message).HitTest of
HTSYSMENU : SendMessage(CtrlHandle, WM_SYSCOMMAND, SC_CLOSE, 0);
HTCAPTION : begin
if EnabledMax or EnabledRestore then begin
if IsZoomed(CtrlHandle) or IsIconic(CtrlHandle)
then SendMessage(CtrlHandle, WM_SYSCOMMAND, SC_RESTORE, 0)
else SendMessage(CtrlHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
SystemMenu.UpdateItems;
end;
TWMNCHitMessage(Message).HitTest := 0;
end;
end;
Exit;
end;
WM_PAINT : if IsWindowVisible(CtrlHandle) then begin
InitCtrlData(CtrlHandle, ParentWnd, WndRect, ParentRect, WndSize, WndPos, Caption);
Caption := GetWndText(CtrlHandle);
if Provider.DlgType in [adtFontDlg, adtColorDlg] then begin
if TWMPaint(Message).DC = 0 then begin
b := True;
TWMPaint(Message).DC := GetWindowDC(CtrlHandle);
end
else b := False;
case Provider.DlgType of
adtFontDlg : begin
IntersectClipRect(TWMPaint(Message).DC, fRect.Left, fRect.Top, fRect.Right, fRect.Bottom);
end;
{
adtColorDlg : begin
// IntersectClipRect(TWMPaint(Message).DC, 447, 0, 455, 202);
end;
}
end;
Message.Result := CallWindowProc(OldProc, CtrlHandle, Message.Msg, Message.WParam, Message.LParam);
if b then ReleaseDC(CtrlHandle, TWMPaint(Message).DC);
end;
Ac_WMPaint(TWMPaint(Message));
if not Initialized then begin
Initialized := True;
Provider.InitHwndControls(CtrlHandle); // Rezerved searching of controls
end;
Exit;
end;
WM_NCPAINT : if IsWindowVisible(CtrlHandle) then begin
InitCtrlData(CtrlHandle, ParentWnd, WndRect, ParentRect, WndSize, WndPos, Caption);
Caption := GetWndText(CtrlHandle);
Ac_WMNCPaint(Message);
Exit;
end;
WM_WINDOWPOSCHANGED, WM_SIZE : begin
SkinData.BGChanged := True;
RgnChanged := True;
end;
WM_SETTEXT : if IsWindowVisible(CtrlHandle) then begin
SendMessage(CtrlHandle, WM_SETREDRAW, 0, 0);
Message.Result := CallWindowProc(OldProc, CtrlHandle, Message.Msg, Message.WParam, Message.LParam);
SendMessage(CtrlHandle, WM_SETREDRAW, 1, 0);
SkinData.BGChanged := True;
SendMessage(CtrlHandle, WM_NCPAINT, 0, 0);
Exit;
end;
WM_ENABLE : if IsWindowVisible(CtrlHandle) then begin
SendMessage(CtrlHandle, WM_SETREDRAW, 0, 0);
Message.Result := CallWindowProc(OldProc, CtrlHandle, Message.Msg, Message.WParam, Message.LParam);
SendMessage(CtrlHandle, WM_SETREDRAW, 1, 0);
SkinData.BGChanged := True;
SendMessage(CtrlHandle, WM_NCPAINT, 0, 0);
Exit;
end;
WM_NCACTIVATE : if IsWindowVisible(CtrlHandle) then begin
SendMessage(CtrlHandle, WM_SETREDRAW, 0, 0);
Message.Result := CallWindowProc(OldProc, CtrlHandle, Message.Msg, Message.WParam, Message.LParam);
FFormActive := (TWMActivate(Message).Active <> WA_INACTIVE);
SendMessage(CtrlHandle, WM_SETREDRAW, 1, 0);
Ac_WMNCActivate(Message);
Exit;
end;
WM_ACTIVATE : if IsWindowVisible(CtrlHandle) then begin
SendMessage(CtrlHandle, WM_SETREDRAW, 0, 0);
Message.Result := CallWindowProc(OldProc, CtrlHandle, Message.Msg, Message.WParam, Message.LParam);
FFormActive := (TWMActivate(Message).Active <> WA_INACTIVE);
SendMessage(CtrlHandle, WM_SETREDRAW, 1, 0);
Ac_WMActivate(Message);
Exit;
end;
1326 : begin
SendMessage(CtrlHandle, WM_SETREDRAW, 0, 0);
inherited;
Provider.InitHwndControls(CtrlHandle); // SysListView re-init
SendMessage(CtrlHandle, WM_SETREDRAW, 1, 0);
RedrawWindow(CtrlHandle, nil, 0, RDW_ERASE or RDW_FRAME or RDW_INTERNALPAINT or RDW_INVALIDATE or RDW_UPDATENOW);
end;
end;
inherited;
case Message.Msg of
WM_SYSCOMMAND : begin
// ??? v5.40 if Message.WParamLo = $F012 then RedrawWindow(CtrlHandle, nil, 0, RDW_ERASE or RDW_FRAME or RDW_INTERNALPAINT or RDW_INVALIDATE or RDW_UPDATENOW);
case Message.WParam of
SC_MAXIMIZE, SC_RESTORE : begin
if VisibleMax then CurrentHT := HTMAXBUTTON;
SetHotHT(0);
end;
end;
end;
end;
end;
function TacDialogWnd.BarWidth(i: integer): integer;
begin
if Assigned(SkinData.SkinManager.ma[i].Bmp) then begin
Result := (SkinData.SkinManager.ma[i].Bmp.Width div 9) * 2 + TitleBtnsWidth;
end
else begin
Result := (WidthOf(SkinData.SkinManager.ma[i].R) div (3 * SkinData.SkinManager.ma[i].ImageCount)) * 2 + TitleBtnsWidth;
end;
end;
function TacDialogWnd.BorderWidth: integer;
begin
Result := SysBorderHeight
end;
function TacDialogWnd.CaptionHeight: integer;
begin
if (BorderStyle <> acbsNone) and (GetWindowLong(CtrlHandle, GWL_STYLE) and WS_CAPTION = WS_CAPTION) then begin
if BorderStyle in [acbsToolWindow, acbsSizeToolWin]
then Result := GetSystemMetrics(SM_CYSMCAPTION)
else Result := GetSystemMetrics(SM_CYCAPTION)
end
else Result := 0;
end;
constructor TacDialogWnd.Create(AHandle: hwnd; ASkinData: TsCommonData; ASkinManager: TsSkinManager; const SkinSection : string; Repaint: boolean);
begin
inherited;
Initialized := False;
RgnChanged := True;
BorderStyle := acbsSingle;
TempBmp := TBitmap.Create;
FFormActive := True;
SystemMenu := TacSystemMenu.Create(nil);
SystemMenu.FOwner := Self;
SystemMenu.UpdateItems;
if (DefaultManager <> nil) and DefaultManager.SkinnedPopups then DefaultManager.SkinableMenus.HookPopupMenu(SystemMenu, True);
end;
destructor TacDialogWnd.Destroy;
begin
if Assigned(Adapter) then FreeAndNil(Adapter);
if Assigned(TitleGlyph) then FreeAndNil(TitleGlyph);
if Assigned(TitleBG) then FreeAndNil(TitleBG);
if Assigned(TempBmp) then FreeAndnil(TempBmp);
FreeAndNil(SystemMenu);
if TitleFont <> nil then FreeAndnil(TitleFont);
inherited;
end;
procedure TacDialogWnd.Ac_WMPaint(var Msg: TWMPaint);
var
DC, SavedDC : hdc;
PS : TPaintStruct;
begin
BeginPaint(CtrlHandle, PS);
DC := GetDC(CtrlHandle);
SavedDC := SaveDC(DC);
try
SkinData.Updating := SkinData.Updating;
if not SkinData.Updating then begin
case Provider.DlgType of
adtFontDlg : ExcludeClipRect(DC, fRect.Left, fRect.Top, fRect.Right, fRect.Bottom);
adtColorDlg : begin
ExcludeClipRect(DC, 447, 0, 455, 200);
ExcludeClipRect(DC, 6, 23, 216, 163);
ExcludeClipRect(DC, 6, 189, 216, 235);
end;
end;
PaintForm(DC);
end;
finally
RestoreDC(DC, SavedDC);
ReleaseDC(CtrlHandle, DC);
EndPaint(CtrlHandle, PS);
end;
end;
function TacDialogWnd.EnabledClose: boolean;
begin
Result := VisibleClose and (GetClassLong(CtrlHandle, GCL_STYLE) and CS_NOCLOSE <> CS_NOCLOSE)
end;
function TacDialogWnd.EnabledMax: boolean;
begin
Result := VisibleMax and not IsZoomed(CtrlHandle) and (BorderStyle in [acbsSingle, acbsSizeable, acbsSizeToolWin]);
end;
function TacDialogWnd.EnabledMin: boolean;
begin
Result := VisibleMin and not IsIconic(CtrlHandle);
end;
function TacDialogWnd.EnabledRestore: boolean;
begin
Result := VisibleMax and (IsIconic(CtrlHandle) or IsZoomed(CtrlHandle));
end;
function TacDialogWnd.FormActive: integer;
begin
Result := integer(FFormActive);
end;
function TacDialogWnd.HeaderHeight: integer;
begin
if GetWindowLong(CtrlHandle, GWL_STYLE) and WS_CAPTION <> WS_CAPTION
then Result := WndSize.cy - GetClientHeight(CtrlHandle)
else Result := WndSize.cy - GetClientHeight(CtrlHandle) - SysBorderHeight;
if Result < 0 then Result := 0;
if IsIconic(CtrlHandle) then inc(Result, SysBorderHeight);
if Assigned(sBarHorz) and sBarHorz.fScrollVisible then begin
dec(Result, GetScrollMetric(sBarHorz, SM_CYHORZSB));
end;
end;
procedure TacDialogWnd.InitParams;
var
NonClientMetrics: TNonClientMetrics;
f : HFONT;
begin
dwStyle := GetWindowLong(CtrlHandle, GWL_STYLE);
dwExStyle := GetWindowLong(CtrlHandle, GWL_EXSTYLE);
BorderStyle := acbsSizeable;
if ((dwStyle and WS_POPUP) > 0) and ((dwStyle and WS_CAPTION) <> WS_Caption)
then BorderStyle := acbsNone
else if ((dwStyle and WS_THICKFRAME) > 0) or ((dwStyle and WS_SIZEBOX) > 0)
then BorderStyle := acbsSizeable
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -