📄 suiform.pas
字号:
if BottomMax > BottomMin then
Y := BottomMax + 1
else
Y := BottomBmp.Height;
if BottomMin > 0 then
begin
TempRgn := CreateRectRgn(0, Offset, Width, Offset + BottomMin);
CombineRgn(Rgn, Rgn, TempRgn, RGN_OR);
DeleteObject(TempRgn);
end;
for i := X to Y - 1 do
begin
Left := 0;
Right := 0;
PreWhite := true;
for j := 0 to BottomBmp.Width - 1 do
begin
if (
(BottomBmp.Canvas.Pixels[j, i] = TransColor) or
(j = BottomBmp.Width - 1)
) then
begin
if (j = BottomBmp.Width - 1) and (BottomBmp.Canvas.Pixels[j, i] <> TransColor) then
begin
TempRgn := CreateRectRgn(Left, Offset + i, j + 1, Offset + i + 1);
CombineRgn(Rgn, Rgn, TempRgn, RGN_OR);
DeleteObject(TempRgn);
end
else if not PreWhite then
begin
TempRgn := CreateRectRgn(Left, Offset + i, Right + 1, Offset + i + 1);
CombineRgn(Rgn, Rgn, TempRgn, RGN_OR);
DeleteObject(TempRgn);
end;
PreWhite := true;
end
else
begin
if PreWhite then
begin
Left := j;
Right := j;
end
else
Inc(Right);
PreWhite := false;
end;
end;
end;
if Y < BottomBmp.Height then
begin
TempRgn := CreateRectRgn(0, Offset + Y, Width, Offset + BottomBmp.Height);
CombineRgn(Rgn, Rgn, TempRgn, RGN_OR);
DeleteObject(TempRgn);
end;
end
else
begin
TempRgn := CreateRectRgn(0, Height - BottomHeight, Width, Height);
CombineRgn(Rgn, Rgn, TempRgn, RGN_OR);
DeleteObject(TempRgn);
end;
SetWindowRgn(HandleOfWnd, Rgn, true);
DeleteObject(Rgn);
end;
procedure TsuiForm.RegionWindow;
var
R1, R2 : TRect;
Rgn, Rgn1 : HRGN;
C, C2 : Integer;
TempRgn : HRGN;
W, H : Integer;
OutUIStyle : TsuiUIStyle;
TitleBmp : TBitmap;
begin
if UsingFileTheme(m_FileTheme, m_UIStyle, OutUIStyle) then
begin
if ((not m_TitleNeedRegion) and (not m_BottomNeedRegion)) or ((m_Form.WindowState <> wsNormal) and (m_Form.FormStyle = fsMDIChild)) then
begin
Rgn := CreateRectRgn(0, 0, m_Form.Width, m_Form.Height);
SetWindowRgn(m_Form.Handle, Rgn, true);
DeleteObject(Rgn);
Exit;
end;
m_TitleBar.ForcePaint();
m_TitleBar.GetTitleImage(-1, TitleBmp);
SetBitmapWindow(m_Form.Handle,
TitleBmp, m_BottomBufRgn,
m_TitleNeedRegion, m_BottomNeedRegion,
m_TitleRegionMin, m_TitleRegionMax, m_BottomRegionMin, m_BottomRegionMax,
m_TransparentColor, m_Form.Height, m_Form.Width
);
end
else
begin
if csDesigning in ComponentState then
Exit;
H := m_Form.Height;
W := m_Form.Width;
R1 := Rect(0, 0, W, H div 2);
R2 := Rect(0, H div 2, W, H);
C := RoundCorner;
C2 := RoundCornerBottom;
if C2 = -1 then
C2 := 0;
Rgn := CreateRoundRectRgn(R1.Left, R1.Top, R1.Right + 1, R1.Bottom + 1, C, C);
TempRgn := CreateRectRgn(
R1.Left,
R1.Bottom,
R1.Left + C * 2,
R1.Bottom - C * 2
);
CombineRgn(Rgn, Rgn, TempRgn, RGN_OR);
DeleteObject(TempRgn);
TempRgn := CreateRectRgn(
R1.Right,
R1.Bottom,
R1.Right - C * 2,
R1.Bottom - C * 2
);
CombineRgn(Rgn, Rgn, TempRgn, RGN_OR);
DeleteObject(TempRgn);
Rgn1 := CreateRoundRectRgn(R2.Left, R2.Top, R2.Right + 1, R2.Bottom + 1, C2, C2);
TempRgn := CreateRectRgn(
R2.Left,
R2.Top,
R2.Left + C2 * 2,
R2.Top + C2 * 2
);
CombineRgn(Rgn1, Rgn1, TempRgn, RGN_OR);
DeleteObject(TempRgn);
TempRgn := CreateRectRgn(
R2.Right,
R2.Top,
R2.Right - C2 * 2,
R2.Top + C2 * 2
);
CombineRgn(Rgn1, Rgn1, TempRgn, RGN_OR);
DeleteObject(TempRgn);
CombineRgn(Rgn, Rgn, Rgn1, RGN_OR);
DeleteObject(Rgn1);
if not (csDesigning in m_Form.ComponentState) then
SetWindowRgn(m_Form.Handle, Rgn, true);
DeleteObject(Rgn);
end;
end;
procedure TsuiForm.RepaintMenuBar;
begin
if (m_MenuBar = nil) or (m_Menu = nil) then
Exit;
if m_Menu is TsuiMainMenu then
if (m_Menu as TsuiMainMenu).UseSystemFont then
Menu_GetSystemFont(m_MenuBar.Font)
else
begin
m_MenuBar.Font.Name := (m_Menu as TsuiMainMenu).FontName;
m_MenuBar.Font.Size := (m_Menu as TsuiMainMenu).FontSize;
m_MenuBar.Font.Charset := (m_Menu as TsuiMainMenu).FontCharset;
end;
m_MenuBar.Repaint();
end;
procedure TsuiForm.Resize;
begin
inherited;
m_TitleBar.Align := alTop;
{$IFDEF SUIPACK_D9UP}
if WS_CAPTION and GetWindowLong(m_Form.Handle, GWL_STYLE) <> 0 then
begin
SetWindowLong(m_Form.Handle, GWL_STYLE, GetWindowLong(m_Form.Handle, GWL_STYLE) and (not WS_CAPTION));
SetWindowPos(m_Form.Handle, 0, 0, 0, 0, 0, SWP_DRAWFRAME or SWP_NOMOVE or SWP_NOZORDER or SWP_NOSIZE or SWP_NOACTIVATE);
end;
{$ENDIF}
end;
procedure TsuiForm.SetBorderWidth(const Value: Integer);
begin
m_Width := Value;
PaintFormBorder();
end;
procedure TsuiForm.SetButtons(const Value: TsuiTitleBarButtons);
begin
m_TitleBar.Buttons.Assign(Value);
end;
procedure TsuiForm.SetCaption(const Value: TCaption);
begin
m_TitleBar.Caption := Value;
m_Form.Caption := Value;
end;
procedure TsuiForm.SetColor(const Value: TColor);
begin
m_Color := Value;
PaintFormBorder();
end;
procedure TsuiForm.SetDrawAppIcon(const Value: Boolean);
begin
m_TitleBar.DrawAppIcon := Value;
end;
procedure TsuiForm.SetFileTheme(const Value: TsuiFileTheme);
begin
if m_FileTheme = Value then
Exit;
m_FileTheme := Value;
SetUIStyle(m_UIStyle);
end;
procedure TsuiForm.SetFont(const Value: TFont);
begin
m_TitleBar.Font := Value;
end;
procedure TsuiForm.SetInactiveCaptionColor(const Value: TColor);
begin
if m_TitleBar <> nil then
m_TitleBar.InactiveCaptionColor := Value;
end;
procedure TsuiForm.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;
if m_Menu is TsuiMainMenu then
(m_Menu as TsuiMainMenu).Form := self;
if m_Menu <> nil then
begin
if m_MenuBar = nil then
CreateMenuBar();
UpdateMenu();
m_TitleBar.Top := 0;
end
else
DestroyMenuBar();
end;
procedure TsuiForm.SetMenuBarColor(const Value: TColor);
begin
m_MenuBarColor := Value;
if m_MenuBar <> nil then
m_MenuBar.Color := Value;
end;
procedure TsuiForm.SetMenuBarHeight(const Value: Integer);
var
i : Integer;
begin
m_MenuBarHeight := Value;
if m_MenuBar <> nil then
begin
m_MenuBar.Height := m_MenuBarHeight;
for i := 0 to m_MenuBar.ButtonCount - 1 do
m_MenuBar.Buttons[i].Height := m_MenuBarHeight;
end;
end;
procedure TsuiForm.SetMenuBarToColor(const Value: TColor);
begin
m_MenuBarToColor := Value;
if m_MenuBar <> nil then
m_MenuBar.Repaint();
end;
procedure TsuiForm.SetOnBtnClick(
const Value: TsuiTitleBarButtonClickEvent);
begin
m_TitleBar.OnCustomBtnsClick := Value;
end;
procedure TsuiForm.SetOnHelpBtnClick(
const Value: TsuiTitleBarButtonClickEvent);
begin
m_TitleBar.OnHelpBtnClick := Value;
end;
procedure TsuiForm.SetPanel(const Value: TCustomPanel);
begin
if Value = self then
begin
MessageDlg('Sorry, you can''t select the Form assign to FormPanel property', mtError, [mbOK], 0);
Exit;
end;
m_Panel := Value;
if m_Panel = nil then
Exit;
m_Panel.Align := alClient;
if m_Panel is TPanel then
begin
TPanel(m_Panel).BevelOuter := bvNone;
TPanel(m_Panel).BevelInner := bvNone;
TPanel(m_Panel).BorderStyle := bsNone;
TPanel(m_Panel).Caption := '';
end
else if m_Panel is TsuiImagePanel then
TsuiImagePanel(m_Panel).Caption := '';
end;
procedure TsuiForm.SetRoundCorner(const Value: Integer);
begin
m_TitleBar.RoundCorner := Value;
RegionWindow();
end;
procedure TsuiForm.SetRoundCornerBottom(const Value: Integer);
begin
m_TitleBar.RoundCornerBottom := Value;
RegionWindow();
end;
procedure TsuiForm.SetSections(const Value: TsuiTitleBarSections);
begin
m_TitleBar.Sections.Assign(Value);
end;
procedure TsuiForm.SetTitleBarCustom(const Value: Boolean);
begin
m_TitleBar.Custom := Value;
end;
procedure TsuiForm.SetTitleBarVisible(const Value: Boolean);
begin
if m_TitleBar.Visible = Value then
Exit;
if not m_SelfChanging then
m_MDIChildFormTitleVisible := Value;
m_TitleBar.Visible := Value;
m_TitleBar.Top := 0;
PaintFormBorder();
end;
procedure TsuiForm.SetUIStyle(const Value: TsuiUIStyle);
var
OutUIStyle : TsuiUIStyle;
Rect: TRect;
Tmp : TBitmap;
begin
Rect := m_Form.BoundsRect;
m_UIStyle := Value;
if UsingFileTheme(m_FileTheme, m_UIStyle, OutUIStyle) then
begin
Color := m_FileTheme.GetColor(SKIN2_FORMCOLOR);
MenuBarColor := m_FileTheme.GetColor(SKIN2_MENUBARSTARTCOLOR);
MenuBarToColor := m_FileTheme.GetColor(SKIN2_MENUBARENDCOLOR);
m_LeftBorderWidth := m_FileTheme.GetBitmap(SKIN2_FORMLEFTBORDER).Width;
m_RightBorderWidth := m_FileTheme.GetBitmap(SKIN2_FORMRIGHTBORDER).Width;
m_BottomBorderWidth := m_FileTheme.GetBitmap(SKIN2_FORMBOTTOMBORDER1).Height;
m_TransparentColor := m_FileTheme.GetColor(SKIN2_TRANSCOLOR);
m_TitleNeedRegion := m_FileTheme.GetBool(SKIN2_TITLEBARNEEDREGION);
m_BottomNeedRegion := m_FileTheme.GetBool(SKIN2_BOTTOMBORDERNEEDREGION);
m_TitleBar.ForcePaint();
m_TitleBar.GetTitleImage(-1, Tmp);
Tmp.Transparent := m_TitleNeedRegion;
Tmp.TransparentColor := m_TransparentColor;
m_BottomBufRgn.Transparent
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -