📄 suititlebar.pas
字号:
SendMessage(Application.MainForm.Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0)
else
begin
//ShowWindow(ParentForm.Handle, SW_SHOWMINIMIZED);
ParentForm.WindowState := wsMinimized;
end;
end;
suiClose :
begin
ParentForm.Close();
end;
suiControlBox :
begin
if Assigned(m_ControlBoxMenu) then
begin
if ((Collection as TsuiTitleBarButtons).m_TitleBar.BidiMode = bdRightToLeft) and SysLocale.MiddleEast then
Point.X := 176
else
Point.X := 0;
Point.Y := (Collection as TsuiTitleBarButtons).m_TitleBar.Height;
Point := (Collection as TsuiTitleBarButtons).m_TitleBar.ClientToScreen(Point);
if Point.X < 0 then
Point.X := 0;
m_ControlBoxMenu.Popup(Point.X, Point.Y);
end;
end;
suiCustom :
begin
end;
end; // case
end;
procedure TsuiTitleBarButton.ProcessMaxBtn;
procedure InMAX(FileTheme : TsuiFileTheme);
var
OutUIStyle : TsuiUIStyle;
begin
if UsingFileTheme(FileTheme, m_UIStyle, OutUIStyle) then
begin
FileTheme.GetBitmap(SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicNormal.Bitmap, 18, 10);
FileTheme.GetBitmap(SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicMouseOn.Bitmap, 18, 11);
FileTheme.GetBitmap(SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicMouseDown.Bitmap, 18, 12);
end
else
begin
GetInsideThemeBitmap(OutUIStyle, SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicNormal.Bitmap, 18, 10);
GetInsideThemeBitmap(OutUIStyle, SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicMouseOn.Bitmap, 18, 11);
GetInsideThemeBitmap(OutUIStyle, SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicMouseDown.Bitmap, 18, 12);
end;
end;
procedure InNormal(FileTheme : TsuiFileTheme);
var
OutUIStyle : TsuiUIStyle;
begin
if UsingFileTheme(FileTheme, m_UIStyle, OutUIStyle) then
begin
FileTheme.GetBitmap(SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicNormal.Bitmap, 18, 7);
FileTheme.GetBitmap(SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicMouseOn.Bitmap, 18, 8);
FileTheme.GetBitmap(SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicMouseDown.Bitmap, 18, 9);
end
else
begin
GetInsideThemeBitmap(OutUIStyle, SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicNormal.Bitmap, 18, 7);
GetInsideThemeBitmap(OutUIStyle, SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicMouseOn.Bitmap, 18, 8);
GetInsideThemeBitmap(OutUIStyle, SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicMouseDown.Bitmap, 18, 9);
end;
end;
var
ParentForm : TCustomForm;
begin
if ButtonType <> suiMax then
Exit;
if (Collection as TsuiTitleBarButtons).m_TitleBar.Custom then
Exit;
ParentForm := GetParentForm((Collection as TsuiTitleBarButtons).m_TitleBar);
if ParentForm = nil then
begin
InNormal((Collection as TsuiTitleBarButtons).m_TitleBar.FileTheme);
Exit;
end;
if ParentForm.WindowState = wsMaximized then
InMax((Collection as TsuiTitleBarButtons).m_TitleBar.FileTheme)
else
InNormal((Collection as TsuiTitleBarButtons).m_TitleBar.FileTheme);
end;
procedure TsuiTitleBarButton.SetButtonType(const Value: TsuiTitleBarBtnType);
var
i : Integer;
begin
if Value = suiControlBox then
begin
for i := 0 to (Collection as TsuiTitleBarButtons).Count - 1 do
begin
if (Collection as TsuiTitleBarButtons).Items[i].ButtonType = suiControlBox then
begin
MessageDlg('Sorry, only one button''s ButtonType property can be "suiControlBox"', mtError, [mbOK], 0);
Exit;
end;
end;
end;
m_ButtonType := Value;
UpdateUIStyle();
(Collection as TsuiTitleBarButtons).m_TitleBar.Repaint();
end;
procedure TsuiTitleBarButton.SetPicMouseDown(const Value: TPicture);
begin
m_PicMouseDown.Assign(Value);
(Collection as TsuiTitleBarButtons).m_TitleBar.Repaint();
end;
procedure TsuiTitleBarButton.SetPicMouseOn(const Value: TPicture);
begin
m_PicMouseOn.Assign(Value);
(Collection as TsuiTitleBarButtons).m_TitleBar.Repaint();
end;
procedure TsuiTitleBarButton.SetPicNormal(const Value: TPicture);
begin
m_PicNormal.Assign(Value);
(Collection as TsuiTitleBarButtons).m_TitleBar.Repaint();
end;
procedure TsuiTitleBarButton.SetTop(const Value: Integer);
begin
m_Top := Value;
(Collection as TsuiTitleBarButtons).m_TitleBar.Repaint();
end;
procedure TsuiTitleBarButton.SetTransparent(const Value: Boolean);
begin
m_Transparent := Value;
(Collection as TsuiTitleBarButtons).m_TitleBar.Repaint();
end;
procedure TsuiTitleBarButton.SetUIStyle(const Value: TsuiUIStyle);
begin
m_UIStyle := Value;
UpdateUIStyle();
end;
procedure TsuiTitleBarButton.SetVisible(const Value: Boolean);
begin
m_Visible := Value;
(Collection as TsuiTitleBarButtons).m_TitleBar.Repaint();
end;
procedure TsuiTitleBarButton.UpdateFileTheme;
var
nNormal : Integer;
nMouseOn : Integer;
nMouseDown : Integer;
FileTheme : TsuiFileTheme;
begin
FileTheme := (Collection as TsuiTitleBarButtons).m_TitleBar.FileTheme;
Transparent := FileTheme.GetBool(SUI_THEME_TITLEBAR_BUTTON_TRANSPARENT_BOOL);
case m_ButtonType of
suiMax :
begin
nNormal := 7;
nMouseOn := 8;
nMouseDown := 9;
end;
suiMin :
begin
nNormal := 13;
nMouseOn := 14;
nMouseDown := 15;
end;
suiClose :
begin
nNormal := 16;
nMouseOn := 17;
nMouseDown := 18;
end;
suiHelp :
begin
nNormal := 4;
nMouseOn := 5;
nMouseDown := 6;
end;
suiControlBox :
begin
nNormal := 1;
nMouseOn := 2;
nMouseDown := 3;
end;
else Exit;
end; // case
FileTheme.GetBitmap(SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicNormal.Bitmap, 18, nNormal);
FileTheme.GetBitmap(SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicMouseOn.Bitmap, 18, nMouseOn);
FileTheme.GetBitmap(SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicMouseDown.Bitmap, 18, nMouseDown);
Top := FileTheme.GetInt(SUI_THEME_TITLEBAR_BUTTON_TOP_INT);
end;
procedure TsuiTitleBarButton.UpdateInsideTheme(UIStyle : TsuiUIStyle);
var
nNormal : Integer;
nMouseOn : Integer;
nMouseDown : Integer;
begin
Transparent := GetInsideThemeBool(UIStyle, SUI_THEME_TITLEBAR_BUTTON_TRANSPARENT_BOOL);
case m_ButtonType of
suiMax :
begin
nNormal := 7;
nMouseOn := 8;
nMouseDown := 9;
end;
suiMin :
begin
nNormal := 13;
nMouseOn := 14;
nMouseDown := 15;
end;
suiClose :
begin
nNormal := 16;
nMouseOn := 17;
nMouseDown := 18;
end;
suiHelp :
begin
nNormal := 4;
nMouseOn := 5;
nMouseDown := 6;
end;
suiControlBox :
begin
nNormal := 1;
nMouseOn := 2;
nMouseDown := 3;
end;
else Exit;
end; // case
GetInsideThemeBitmap(UIStyle, SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicNormal.Bitmap, 18, nNormal);
GetInsideThemeBitmap(UIStyle, SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicMouseOn.Bitmap, 18, nMouseOn);
GetInsideThemeBitmap(UIStyle, SUI_THEME_TITLEBAR_BUTTON_IMAGE, PicMouseDown.Bitmap, 18, nMouseDown);
Top := GetInsideThemeInt(UIStyle, SUI_THEME_TITLEBAR_BUTTON_TOP_INT);
end;
procedure TsuiTitleBarButton.UpdateUIStyle;
var
OutUIStyle : TsuiUIStyle;
begin
if UsingFileTheme((Collection as TsuiTitleBarButtons).m_TitleBar.FileTheme, m_UIStyle, OutUIStyle) then
UpdateFileTheme()
else
UpdateInsideTheme(OutUIStyle);
if m_ButtonType = suiMax then
ProcessMaxBtn();
end;
procedure TsuiTitleBar.CMFONTCHANGED(var Msg: TMessage);
begin
Repaint();
end;
procedure TsuiTitleBar.SetRoundCorner(const Value: Integer);
begin
m_RoundCorner := Value;
end;
procedure TsuiTitleBar.WMNCLBUTTONDOWN(var Msg: TMessage);
begin
Msg.Result := SendMessage(GetParentForm(Self).Handle, Msg.Msg, Msg.WParam, Msg.LParam);
end;
procedure TsuiTitleBar.WMNCLBUTTONUP(var Msg: TMessage);
begin
Msg.Result := SendMessage(GetParentForm(Self).Handle, Msg.Msg, Msg.WParam, Msg.LParam);
end;
procedure TsuiTitleBar.WMNCMOUSEMOVE(var Msg: TMessage);
begin
Msg.Result := SendMessage(GetParentForm(Self).Handle, Msg.Msg, Msg.WParam, Msg.LParam);
end;
procedure TsuiTitleBar.SetFileTheme(const Value: TsuiFileTheme);
begin
m_FileTheme := Value;
m_SelfChanging := true;
SetUIStyle(m_UIStyle);
m_SelfChanging := false;
end;
procedure TsuiTitleBar.UpdateFileTheme;
var
Sec : TsuiTitleBarSection;
Form : TCustomForm;
TempBmp : TBitmap;
begin
Sec := Sections.Add();
m_FileTheme.GetBitmap(SUI_THEME_TITLEBAR_LEFT_IMAGE, Sec.Picture.Bitmap);
Sec.AutoSize := true;
Sec := Sections.Add();
m_FileTheme.GetBitmap(SUI_THEME_TITLEBAR_RIGHT_IMAGE, Sec.Picture.Bitmap);
Sec.AutoSize := true;
Sec.Align := suiRight;
Sec := Sections.Add();
m_FileTheme.GetBitmap(SUI_THEME_TITLEBAR_CLIENT_IMAGE, Sec.Picture.Bitmap);
Sec.Align := suiClient;
LeftBtnXOffset := m_FileTheme.GetInt(SUI_THEME_TITLEBAR_BUTTON_LEFTOFFSET_INT);
RightBtnXOffset := m_FileTheme.GetInt(SUI_THEME_TITLEBAR_BUTTON_RIGHTOFFSET_INT);
m_BorderColor := m_FileTheme.GetColor(SUI_THEME_FORM_BORDER_COLOR);
TempBmp := TBitmap.Create();
m_FileTheme.GetBitmap(SUI_THEME_TITLEBAR_BUTTON_IMAGE, TempBmp);
m_BtnHeight := TempBmp.Height;
TempBmp.Free();
m_BtnTop := m_FileTheme.GetInt(SUI_THEME_TITLEBAR_BUTTON_TOP_INT);
if Inform() then
Dec(m_BtnTop, 3);
Form := GetParentForm(self);
if Form <> nil then
Form.Constraints.MinWidth := m_FileTheme.GetInt(SUI_THEME_FORM_MINWIDTH_INT);
m_RoundCorner := m_FileTheme.GetInt(SUI_THEME_FORM_ROUNDCORNER_INT);
m_RoundCornerBottom := m_FileTheme.GetInt(SUI_THEME_FORM_BOTTOMROUNDCORNOR_INT);
end;
procedure TsuiTitleBar.UpdateInsideTheme(UIStyle : TsuiUIStyle);
var
Sec : TsuiTitleBarSection;
Form : TCustomForm;
TempBmp : TBitmap;
begin
Sec := Sections.Add();
GetInsideThemeBitmap(UIStyle, SUI_THEME_TITLEBAR_LEFT_IMAGE, Sec.Picture.Bitmap);
Sec.AutoSize := true;
Sec := Sections.Add();
GetInsideThemeBitmap(UIStyle, SUI_THEME_TITLEBAR_RIGHT_IMAGE, Sec.Picture.Bitmap);
Sec.AutoSize := true;
Sec.Align := suiRight;
Sec := Sections.Add();
GetInsideThemeBitmap(UIStyle, SUI_THEME_TITLEBAR_CLIENT_IMAGE, Sec.Picture.Bitmap);
Sec.Align := suiClient;
LeftBtnXOffset := GetInsideThemeInt(UIStyle, SUI_THEME_TITLEBAR_BUTTON_LEFTOFFSET_INT);
RightBtnXOffset := GetInsideThemeInt(UIStyle, SUI_THEME_TITLEBAR_BUTTON_RIGHTOFFSET_INT);
m_BorderColor := GetInsideThemeColor(UIStyle, SUI_THEME_FORM_BORDER_COLOR);
TempBmp := TBitmap.Create();
GetInsideThemeBitmap(UIStyle, SUI_THEME_TITLEBAR_BUTTON_IMAGE, TempBmp);
m_BtnHeight := TempBmp.Height;
TempBmp.Free();
m_BtnTop := GetInsideThemeInt(UIStyle, SUI_THEME_TITLEBAR_BUTTON_TOP_INT);
if Inform() then
Dec(m_BtnTop, 3);
Form := GetParentForm(self);
if Form <> nil then
Form.Constraints.MinWidth := GetInsideThemeInt(UIStyle, SUI_THEME_FORM_MINWIDTH_INT);
m_RoundCorner := GetInsideThemeInt(UIStyle, SUI_THEME_FORM_ROUNDCORNER_INT);
m_RoundCornerBottom := 0;
end;
procedure TsuiTitleBar.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if (
(Operation = opRemove) and
(AComponent = m_FileTheme)
)then
begin
m_FileTheme := nil;
SetUIStyle(SUI_THEME_DEFAULT);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -