📄 suiform.pas
字号:
begin
ShowWindow(m_Form.ActiveMDIChild.Handle, SW_SHOWMINIMIZED);
end;
-1382 : // restore
begin
SendMessage(m_Form.ClientHandle, WM_MDIRESTORE, m_Form.ActiveMDIChild.Handle, 0);
end;
-1381 : // close
begin
m_Form.ActiveMDIChild.Close();
end;
end;
end;
procedure TsuiMDIForm.PaintBorder;
var
Canvas : TCanvas;
begin
if m_Form = nil then
Exit;
Canvas := TCanvas.Create();
Canvas.Handle := GetWindowDC(m_Form.Handle);
Canvas.Pen.Color := m_BorderColor;
Canvas.MoveTo(0, 1);
Canvas.LineTo(0, m_Form.Height - 1);
Canvas.LineTo(m_Form.Width - 1, m_Form.Height -1);
Canvas.LineTo(m_Form.Width - 1, 0);
ReleaseDC(m_Form.Handle, Canvas.Handle);
Canvas.Free();
end;
procedure TsuiMDIForm.ProcessKeyPress(var Msg: TMessage);
begin
if not Assigned(m_TopMenu) then
Msg.Result := 0
else if m_TopMenu.IsShortCut(TWMKEY(Msg)) then
Msg.Result := 1
else
Msg.Result := 0;
end;
procedure TsuiMDIForm.SetBorderColor(const Value: TColor);
begin
m_BorderColor := Value;
if csDesigning in ComponentState then
Exit;
PaintBorder();
end;
procedure TsuiMDIForm.SetCaption(const Value: TCaption);
begin
m_Form.Caption := Value;
m_TitleBar.Caption := Value;
GetTitleBarCaption();
end;
procedure TsuiMDIForm.SetFileTheme(const Value: TsuiFileTheme);
begin
if m_FileTheme = Value then
Exit;
m_FileTheme := Value;
SetUIStyle(m_UIStyle);
end;
procedure TsuiMDIForm.SetMenu(const Value: TMainMenu);
begin
if m_Menu <> nil then
begin
if m_Menu is TsuiMainMenu then
(m_Menu as TsuiMainMenu).Form := nil;
end;
m_Menu := Value;
UpdateMenu();
end;
procedure TsuiMDIForm.SetMenuBarColor(const Value: TColor);
begin
m_MenuBarColor := Value;
if (m_MenuBar = nil) then
Exit;
m_MenuBar.Color := Value;
end;
procedure TsuiMDIForm.SetUIStyle(const Value: TsuiUIStyle);
var
OutUIStyle : TsuiUIStyle;
i : Integer;
begin
m_UIStyle := Value;
if UsingFileTheme(m_FileTheme, m_UIStyle, OutUIStyle) then
begin
BorderColor := m_FileTheme.GetColor(SUI_THEME_FORM_BORDER_COLOR);
MenuBarColor := m_FileTheme.GetColor(SUI_THEME_FORM_BACKGROUND_COLOR);
end
else
begin
BorderColor := GetInsideThemeColor(OutUIStyle, SUI_THEME_FORM_BORDER_COLOR);
MenuBarColor := GetInsideThemeColor(OutUIStyle, SUI_THEME_FORM_BACKGROUND_COLOR);
end;
if (m_TitleBar = nil) then
Exit;
m_TitleBar.FileTheme := m_FileTheme;
m_TitleBar.UIStyle := m_UIStyle;
if not (csDesigning in ComponentState) then
for i := 1 to 3 do
m_ControlBtns[i].Color := MenuBarColor;
m_TitleBar.RoundCorner := 0;
end;
procedure TsuiMDIForm.ShowControlButtons;
var
i : Integer;
Form : TsuiForm;
begin
Form := GetActiveChildSUIForm();
if Form = nil then
Exit;
for i := 0 to Form.TitleBarButtons.Count - 1 do
begin
if Form.TitleBarButtons.Items[i].ButtonType = suiMin then
m_ControlBtns[3].Visible := true;
if Form.TitleBarButtons.Items[i].ButtonType = suiMax then
m_ControlBtns[2].Visible := true;
if Form.TitleBarButtons.Items[i].ButtonType = suiClose then
m_ControlBtns[1].Visible := true;
end;
end;
procedure TsuiMDIForm.ShowMenuBar;
begin
if (m_MenuBar = nil) then
Exit;
m_TopPanel.Visible := true;
end;
procedure TsuiMDIForm.Tile;
var
i : Integer;
nLeft, nTop, nWidth, nHeight : Integer;
nCount : Integer;
begin
nCount := 0;
for i := m_Form.MDIChildCount - 1 downto 0 do
begin
if m_Form.MDIChildren[i].WindowState = wsMinimized then
continue;
Inc(nCount);
end;
if nCount = 0 then
Exit;
nHeight := m_Form.ClientHeight - m_MenuBar.Height - m_TitleBar.Height - 4;
if nCount < m_Form.MDIChildCount then
Dec(nHeight, 20);
if m_Form.TileMode = tbVertical then
begin
nLeft := 0;
nWidth := m_Form.ClientWidth div nCount;
for i := m_Form.MDIChildCount - 1 downto 0 do
begin
if m_Form.MDIChildren[i].WindowState = wsMinimized then
continue;
m_Form.MDIChildren[i].SetBounds(nLeft, 0, nWidth, nHeight);
Inc(nLeft, nWidth - 6);
end;
end
else
begin
nTop := 0;
nHeight := nHeight div nCount;
nWidth := m_Form.ClientWidth - 4;
for i := m_Form.MDIChildCount - 1 downto 0 do
begin
if m_Form.MDIChildren[i].WindowState = wsMinimized then
continue;
m_Form.MDIChildren[i].SetBounds(0, nTop, nWidth, nHeight);
Inc(nTop, nHeight - 6);
end;
end;
end;
procedure TsuiMDIForm.UpdateMenu();
var
i : Integer;
Button : TToolButton;
begin
m_TopMenu := GetMainMenu();
if m_TopMenu = nil then
begin
HideMenuBar();
Exit;
end;
m_TopPanel.Constraints.MinHeight:=m_MenuBar.Height;
if m_TopMenu.Items.Count<m_MenuBar.ButtonCount then
for i := m_TopMenu.Items.Count to m_MenuBar.ButtonCount - 1 do
m_MenuBar.Buttons[0].Free();
if m_TopMenu.Items.Count>m_MenuBar.ButtonCount then
for i := m_MenuBar.ButtonCount to m_TopMenu.Items.Count - 1 do
begin
Button := TToolButton.Create(self);
Button.Parent := m_MenuBar;
Button.Grouped := true;
Button.AutoSize := true;
end;
for i := m_TopMenu.Items.Count - 1 downto 0 do
m_MenuBar.Buttons[i].MenuItem := m_TopMenu.Items[i];
ShowMenuBar();
m_TopPanel.Constraints.MinHeight:=m_MenuBar.Height;
m_TopPanel.Height := m_MenuBar.Height;
end;
function TsuiMDIForm.GetDrawAppIcon: Boolean;
begin
Result := m_TitleBar.DrawAppIcon;
end;
procedure TsuiMDIForm.SetDrawAppIcon(const Value: Boolean);
begin
m_TitleBar.DrawAppIcon := Value;
end;
function TsuiMDIForm.GetTitleBarCustom: Boolean;
begin
Result := m_TitleBar.Custom;
end;
procedure TsuiMDIForm.SetTitleBarCustom(const Value: Boolean);
begin
m_TitleBar.Custom := Value;
end;
function TsuiMDIForm.GetTitleBarVisible: Boolean;
begin
Result := m_TitleBar.Visible;
end;
procedure TsuiMDIForm.SetTitleBarVisible(const Value: Boolean);
begin
if m_TitleBar.Visible = Value then
Exit;
m_TitleBar.Visible := Value;
m_TitleBar.Top := 0;
end;
function TsuiMDIForm.GetSections: TsuiTitleBarSections;
begin
Result := m_TitleBar.Sections;
end;
procedure TsuiMDIForm.SetSections(const Value: TsuiTitleBarSections);
begin
m_TitleBar.Sections.Assign(Value);
end;
function TsuiMDIForm.GetButtons: TsuiTitleBarButtons;
begin
Result := m_TitleBar.Buttons;
end;
procedure TsuiMDIForm.SetButtons(const Value: TsuiTitleBarButtons);
begin
m_TitleBar.Buttons.Assign(Value);
end;
function TsuiMDIForm.GetTitleBarHeight: integer;
begin
result:=0;
if m_TitleBar.Visible then result:= result + m_TitleBar.Height;
if m_TopPanel.Visible then result:= result + m_TopPanel.Height;
end;
{ TsuiScrollBox }
//procedure TsuiScrollBox.CMEnabledChanged(var Msg: TMessage);
//begin
// inherited;
// UpdateScrollBars();
//end;
//
//constructor TsuiScrollBox.Create(AOwner: TComponent);
//begin
// inherited Create(AOwner);
// ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents, csSetCaption, csDoubleClicks];
// Width := 185;
// Height := 185;
//
// m_SelfChanging := false;
// m_MouseDown := false;
//end;
//
//procedure TsuiScrollBox.Notification(AComponent: TComponent;
// Operation: TOperation);
//begin
// inherited;
// if AComponent = nil then
// Exit;
//
// if (
// (Operation = opRemove) and
// (AComponent = m_VScrollBar)
// )then
// m_VScrollBar := nil;
//
// if (
// (Operation = opRemove) and
// (AComponent = m_HScrollBar)
// )then
// m_HScrollBar := nil;
//end;
//
//procedure TsuiScrollBox.OnHScrollBarChange(Sender: TObject);
//begin
// if m_SelfChanging then
// Exit;
// SendMessage(Handle, WM_HSCROLL, MakeWParam(SB_THUMBPOSITION, m_HScrollBar.Position), 0);
// Invalidate;
//end;
//
//procedure TsuiScrollBox.OnVScrollBarChange(Sender: TObject);
//begin
// if m_SelfChanging then
// Exit;
// SendMessage(Handle, WM_VSCROLL, MakeWParam(SB_THUMBPOSITION, m_VScrollBar.Position), 0);
// Invalidate;
//end;
//
//procedure TsuiScrollBox.SetHScrollBar(const Value: TsuiScrollBar);
//begin
// if m_HScrollBar = Value then
// Exit;
// if m_HScrollBar <> nil then
// begin
// m_HScrollBar.OnChange := nil;
// m_HScrollBar.LineButton := 0;
// m_HScrollBar.Max := 100;
// m_HScrollBar.Enabled := true;
// end;
//
// m_HScrollBar := Value;
// if m_HScrollBar = nil then
// Exit;
// m_HScrollBar.Orientation := suiHorizontal;
// m_HScrollBar.OnChange := OnHScrollBArChange;
// m_HScrollBar.BringToFront();
//
// UpdateScrollBarsPos();
//end;
//
//procedure TsuiScrollBox.SetVScrollBar(const Value: TsuiScrollBar);
//begin
// if m_VScrollBar = Value then
// Exit;
// if m_VScrollBar <> nil then
// begin
// m_VScrollBar.OnChange := nil;
// m_VScrollBar.LineButton := 0;
// m_VScrollBar.Max := 100;
// m_VScrollBar.Enabled := true;
// end;
//
// m_VScrollBar := Value;
// if m_VScrollBar = nil then
// Exit;
// m_VScrollBar.Orientation := suiVertical;
// m_VScrollBar.OnChange := OnVScrollBArChange;
// m_VScrollBar.BringToFront();
//
// UpdateScrollBarsPos();
//end;
//
//procedure TsuiScrollBox.UpdateScrollBars;
//var
// info : tagScrollInfo;
// barinfo : tagScrollBarInfo;
//begin
// m_SelfChanging := true;
// if m_VScrollBar <> nil then
// begin
// barinfo.cbSize := SizeOf(barinfo);
// GetScrollBarInfo(Handle, Integer(OBJID_VSCROLL), barinfo);
// if (barinfo.rgstate[0] = STATE_SYSTEM_INVISIBLE) or
// (barinfo.rgstate[0] = STATE_SYSTEM_UNAVAILABLE) then
// begin
// m_VScrollBar.LineButton := 0;
// m_VScrollBar.Enabled := false;
// m_VScrollBar.Visible := false;
// end
// else
// begin
// m_VScrollBar.LineButton := abs(barinfo.xyThumbBottom - barinfo.xyThumbTop);
// m_VScrollBar.Enabled := true;
// m_VScrollBar.Visible := true;
// end;
// info.cbSize := SizeOf(info);
// info.fMask := SIF_ALL;
// GetScrollInfo(Handle, SB_VERT, info);
// m_VScrollBar.Max := info.nMax - Integer(info.nPage) + 1;
// m_VScrollBar.Min := info.nMin;
// m_VScrollBar.Position := info.nPos;
// end;
//
// if m_HScrollBar <> nil then
// begin
// barinfo.cbSize := SizeOf(barinfo);
// GetScrollBarInfo(Handle, Integer(OBJID_HSCROLL), barinfo);
// if (barinfo.rgstate[0] = STATE_SYSTEM_INVISIBLE) or
// (barinfo.rgstate[0] = STATE_SYSTEM_UNAVAILABLE) then
// begin
// m_HScrollBar.LineButton := 0;
// m_HScrollBar.Enabled := false;
// m_HScrollBar.Visible := false;
// end
// else
// begin
// m_HScrollBar.LineButton := abs(barinfo.xyThumbBottom - barinfo.xyThumbTop);
// m_HScrollBar.Enabled := true;
// m_HScrollBar.Visible := true;
// end;
// info.cbSize := SizeOf(info);
// info.fMask := SIF_ALL;
// GetScrol
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -