📄 acdials.pas
字号:
if f.Handle = hwnd then begin
Result := Screen.Forms[i];
exit;
end;
if Screen.Forms[i].FormStyle = fsMDIForm then begin
for j := 0 to Screen.Forms[i].MDIChildCount - 1 do begin
if Screen.Forms[i].MDIChildren[j].Handle = hwnd then begin
Result := Screen.Forms[i].MDIChildren[j];
exit;
end;
end;
end;
end;
}
end;
{ TacProvider }
function TacProvider.AddControl(aHwnd: hwnd) : boolean;
var
st : dword;
Style : LongInt;
s: string;
Wnd : TacMainWnd;
R : TRect;
begin
Result := True;
if GetBoolMsg(aHwnd, AC_CTRLHANDLED){(FindCtrlInList(ahWnd) <> nil)} then exit;
if (ahWnd = 0) then Exit;
acDlgMode := True;
s := LowerCase(GetWndClassName(aHwnd));
Style := GetWindowLong(aHwnd, GWL_STYLE);
Wnd := nil;
if s = 'static' then begin
GetWindowRect(aHwnd, R);
st := Style and SS_TYPEMASK;
if (WidthOf(R) = 152) and (HeightOf(R) = 49) then begin
Wnd := TacStaticWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_CheckBox);
DlgType := adtPrnDlg;
end
else if (WidthOf(R) = 150) and (HeightOf(R) = 37) then begin
DlgType := adtFontDlg;
end
else if (WidthOf(R) = 192) and (HeightOf(R) = 189) or
(WidthOf(R) = 210) and (HeightOf(R) = 140) or
(WidthOf(R) = 12) and (HeightOf(R) = 189) or
(WidthOf(R) = 210) and (HeightOf(R) = 46) or
(WidthOf(R) = 60) and (HeightOf(R) = 42) then begin
DlgType := adtColorDlg;
ListSW.SkinData.SkinSection := s_Form;
end
else if (Style and SS_ICON = SS_ICON) then begin // Icon
Wnd := TacIconWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_CheckBox)
end
else if (Style and SS_BITMAP = SS_BITMAP) then begin // Bitmap
end
else if (Style and SS_OWNERDRAW = SS_OWNERDRAW) then begin // Bitmap
end
else if st in [SS_SIMPLE, SS_GRAYRECT, SS_WHITERECT] then begin // Bitmap
inc(SimpleStaticCount);
end
else begin
Wnd := TacStaticWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_CheckBox)
end;
end
else if (s = rsfName) then begin
Wnd := TacTransPanelWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_CheckBox)
end
{ else if (s = 'tpanel') then begin
pwnd := GetParent(aHwnd);
GetClassName(pwnd, szBuf, 128);
s := LowerCase(szBuf);
if s <> 'tpanel' then
acSkinnedCtrls.Add(TacTransPanelWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_Button))
end}
else if (s = 'button') then begin
if Style and BS_GROUPBOX = BS_GROUPBOX then begin
Wnd := TacGroupBoxWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_GroupBox)
end
else if (Style and BS_AUTOCHECKBOX = BS_AUTOCHECKBOX) or (Style and BS_CHECKBOX =BS_CHECKBOX) or (Style and BS_3STATE = BS_3STATE) then begin
Wnd := TacCheckBoxWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_CheckBox)
end
else if (Style and BS_AUTORADIOBUTTON = BS_AUTORADIOBUTTON) or (Style and BS_RADIOBUTTON = BS_RADIOBUTTON) then begin
Wnd := TacCheckBoxWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_CheckBox)
end
else Wnd := TacBtnWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_Button)
end
else if (s = 'combobox') then begin
if (GetWindowLong(aHwnd, GWL_STYLE) and CBS_OWNERDRAWFIXED = CBS_OWNERDRAWFIXED) {or (GetWindowLong(aHwnd, GWL_STYLE) and CBS_OWNERDRAWFIXED = CBS_OWNERDRAWFIXED) }then begin
Wnd := TacComboBoxWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_ComboBox)
end
else begin
Wnd := TacComboBoxWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_ComboBox)
end;
TacEditWnd(Wnd).DlgMode := True;
end
else if (s = 'combolbox') then begin
inc(lBoxCount);
Wnd := TacEditWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_ComboBox);
end
else if (s = 'comboboxex32') then begin
Wnd := TacComboBoxWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_ComboBox)
end
else if (s = 'scrollbar') then begin
Wnd := TacSizerWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_CheckBox)
end
else if (s = 'systabcontrol32') then begin
if ((Style and TCS_OWNERDRAWFIXED) <> TCS_OWNERDRAWFIXED) then begin
// Wnd := TacTabWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_PageControl);
// TacTabWnd(Wnd).DlgMode := True;
end;
GetWindowRect(aHwnd, R);
if (WidthOf(R) = 470) and (HeightOf(R) = 349) then Result := False; // if Printer properties Dlg !!!
end
else if (s = 'syslistview32') then begin
Wnd := TacListViewWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_Edit);
TacEditWnd(Wnd).DlgMode := True;
end
else if (s = 'msctls_updown32') then begin
Wnd := TacSpinWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_SpeedButton_Small);
TacSpinWnd(Wnd).lOffset := 2;
end
{ else if (s = 'shelldll_defview') then begin
acSkinnedCtrls.Add(TacBtnWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_DlgEdit));
end}
else if (s = 'listbox') then begin
Wnd := TacEditWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_Edit);
TacEditWnd(Wnd).DlgMode := True;
end
else if (s = 'link window') then begin
Wnd := TacLinkWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_CheckBox);
end
else if (s = 'toolbarwindow32') then begin
if GetWindowLong(aHwnd, GWL_STYLE) and TBSTYLE_WRAPABLE = TBSTYLE_WRAPABLE
then Wnd := TacToolBarWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_Bar)
else Wnd := TacToolBarWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_CheckBox);
end
else if (s = 'edit') then begin
Wnd := TacEditWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_Edit);
TacEditWnd(Wnd).DlgMode := True;
end
else if (s = 'systreeview32') then begin
Wnd := TacTreeViewWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_Edit);
TacEditWnd(Wnd).DlgMode := True;
end
else if (pos('shbrowseforfolder', s) > 0) then begin
Wnd := TacTransPanelWnd.Create(aHwnd, nil, ListSW.SkinData.SkinManager, s_CheckBox)
end;
if Wnd <> nil then begin
acSkinnedCtrls.Add(Wnd);
InitCtrlData(CtrlHandle, Wnd.ParentWnd, Wnd.WndRect, Wnd.ParentRect, Wnd.WndSize, Wnd.WndPos, Wnd.Caption);
end;
acDlgMode := False;
end;
constructor TacProvider.Create(AOwner: TComponent);
begin
inherited;
// if AOwner <> nil then InitForm(TForm(AOwner));
DlgType := adtCommon;
BiDiLeft := False;
end;
destructor TacProvider.Destroy;
var
i : integer;
begin
if (sp = nil) then begin
if acSkinnedCtrls <> nil then begin
for i := 0 to acSkinnedCtrls.Count - 1 do TObject(acSkinnedCtrls[i]).Free;
FreeAndNil(acSkinnedCtrls);
end;
if (ListSW <> nil) then FreeAndNil(ListSW);
end
else for i := 0 to acSupportedList.Count - 1 do begin
if acSupportedList[i] = Self then begin
acSupportedList[i] := nil;
Break;
end;
end;
inherited;
end;
function TacProvider.FindCtrlInList(hwnd: THandle): TObject;
var
i: integer;
begin
Result := nil;
for i := 0 to acSkinnedCtrls.Count - 1 do begin
if TacScrollWnd(acSkinnedCtrls[i]).CtrlHandle = hwnd then begin
Result := TacScrollWnd(acSkinnedCtrls[i]);
Break;
end;
end;
end;
procedure TacProvider.InitForm(Form: TCustomForm);
begin
sp := TsSkinProvider.Create(Form);
sp.Form := TForm(Form);
end;
function TacProvider.InitHwndControls(hWnd : hwnd) : boolean;
var
hCtrl : THandle;
begin
Result := True;
hCtrl := GetTopWindow(hWnd);
while hCtrl <> 0 do begin
if not InitHwndControls(hCtrl) then begin
Result := False;
Exit;
end;
if (GetWindowLong(hCtrl, GWL_STYLE) and WS_CHILD) = WS_CHILD then if not AddControl(hCtrl) then begin
Result := False;
Exit;
end;
hCtrl := GetNextWindow(hCtrl, GW_HWNDNEXT);
end;
end;
function TacProvider.InitSkin(aHandle : hwnd) : boolean;
var
xStyle: LongInt;
WndClassName : string;
Manager : TsSkinManager;
i : integer;
begin
Result := True;
CtrlHandle := aHandle;
acSkinnedCtrls := TList.Create;
Manager := DefaultManager;
if (ListSW = nil) and (Manager <> nil) and Manager.Active then begin
style := GetWindowLong(CtrlHandle, GWL_STYLE);
xStyle := GetWindowLong(CtrlHandle, GWL_EXSTYLE);
BiDiLeft := (xStyle and WS_EX_LEFTSCROLLBAR) > 0;
WndClassName := GetWndClassName(CtrlHandle);
if (WndClassName = rsfName) or (WndClassName = 'TMessageForm') then begin
InitDialog(CtrlHandle, ListSW);
ListSW.Provider := Self;
if (DlgLeft <> -1) or (DlgTop <> -1) then SetWindowPos(CtrlHandle, 0, DlgLeft, DlgTop, 0, 0, SWP_NOOWNERZORDER or SWP_NOREDRAW or SWP_NOSIZE);
lBoxCount := 0;
SimpleStaticCount := 0;
if InitHwndControls(CtrlHandle) then begin
ListSW.InitParams;
if lBoxCount = 3 then begin
DlgType := adtFontDlg;
fRect := Rect(178, 181, 327, 217);
end;
SendAMessage(CtrlHandle, AC_SETNEWSKIN, longword(DefaultManager));
end
else begin
for i := 0 to acSupportedList.Count - 1 do begin
if acSupportedList[i] = Self then acSupportedList[i] := nil;
end;
Result := False;
end;
end;
end;
end;
procedure InitDialog(hwnd: THandle; var ListSW : TacDialogWnd);
begin
if Assigned(DefaultManager) and DefaultManager.Active then begin
UninitializeFlatSB(hwnd);
if (ListSW <> nil) and ListSW.Destroyed then FreeAndNil(ListSW);
if ListSW = nil then begin
ListSW := TacDialogWnd.Create(hwnd, nil, DefaultManager, s_Dialog, False);
ListSW.CtrlHandle := hwnd;
end;
end
else begin
if ListSW <> nil then FreeAndNil(ListSW);
InitializeFlatSB(hwnd);
end;
end;
procedure DrawAppIcon(ListSW : TacDialogWnd);
var
SmallIcon: HIcon;
IcoSize : TSize;
x, y : integer;
begin
if ListSW.TitleIcon <> 0 then begin
IcoSize.cx := GetSystemMetrics(SM_CXSMICON);
IcoSize.cy := GetSystemMetrics(SM_CYSMICON);
x := ListSW.SysBorderWidth;
y := (ListSW.CaptionHeight + ListSW.SysBorderHeight - IcoSize.cy) div 2;
SmallIcon := Windows.CopyImage(ListSW.TitleIcon, IMAGE_ICON, IcoSize.cx, IcoSize.cy, LR_COPYFROMRESOURCE);
if SmallIcon <> 0 then begin
DrawIconEx(ListSW.SkinData.FCacheBmp.Canvas.Handle, x, y, SmallIcon, IcoSize.cx, IcoSize.cy, 0, 0, DI_NORMAL);
DestroyIcon(SmallIcon);
end
else DrawIconEx(ListSW.SkinData.FCacheBmp.Canvas.Handle, x, y, LoadIcon(0, IDI_APPLICATION),
IcoSize.cx, IcoSize.cy, 0, 0, DI_NORMAL);
end
end;
function GetWndText(hwnd: THandle): WideString;
var
buf: array[0..1000] of char;
begin
Result := '';
if Win32Platform = VER_PLATFORM_WIN32_NT then begin
SetLength(Result, GetWindowTextLengthW(hwnd) + 1);
GetWindowTextW(hwnd, PWideChar(Result), Length(Result));
SetLength(Result, Length(Result) - 1);
end
else begin
SendMessage(hwnd, WM_GETTEXT, 1000, integer(@buf));
Result := StrPas(buf);
end;
end;
procedure FillArOR(ListSW : TacDialogWnd);
var
i : integer;
begin
SetLength(ListSW.ArOR, 0);
if ListSW.SkinData.SkinManager.IsValidImgIndex(ListSW.SkinData.BorderIndex) then begin
// TopBorderRgn
AddRgn(ListSW.ArOR, ListSW.WndSize.cx, ListSW.SkinData.SkinManager.ma[ListSW.SkinData.BorderIndex], 0, False);
// BottomBorderRgn
AddRgn(ListSW.ArOR, ListSW.WndSize.cx, ListSW.SkinData.SkinManager.ma[ListSW.SkinData.BorderIndex], ListSW.WndSize.cy - ListSW.SkinData.SkinManager.ma[ListSW.SkinData.BorderIndex].WB, True);
end;
// TitleRgn
i := ListSW.SkinData.SkinManager.GetSkinIndex(s_FormTitle);
if ListSW.SkinData.SkinManager.IsValidSkinIndex(i) then begin
i := ListSW.SkinData.SkinManager.GetMaskIndex(i, s_FormTitle, s_BordersMask);
if ListSW.SkinData.SkinManager.IsValidImgIndex(i) then AddRgn(ListSW.ArOR, ListSW.WndSize.cx, ListSW.SkinData.SkinManager.ma[i], 0, False);
end;
end;
procedure UpdateRgn(ListSW : TacDialogWnd; Repaint : boolean = True);
const
BE_ID = $41A2;
CM_BEWAIT = CM_BASE + $0C4D;
var
rgn : HRGN;
begin
if (ListSW.BorderStyle <> acbsNone) then with ListSW do begin
// if not FirstInitialized then
if SendMessage(CtrlHandle, CM_BEWAIT, BE_ID, 0) = BE_ID then Exit; // BE compatibility
RgnChanging := True;
rgn := GetRgnFromArOR(ListSW);
SetWindowRgn(CtrlHandle, rgn, Repaint); // True - repainting required
end;
end;
function GetRgnFromArOR(ListSW : TacDialogWnd; X : integer = 0; Y : integer = 0) : hrgn;
var
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -