📄 suiform.pas
字号:
end;
function TsuiForm.GetSections: TsuiTitleBarSections;
begin
if m_TitleBar = nil then
Result := nil
else
Result := m_TitleBar.Sections;
end;
function TsuiForm.GetTitleBarCustom: Boolean;
begin
if m_TitleBar = nil then
Result := false
else
Result := m_TitleBar.Custom;
end;
function TsuiForm.GetTitleBarHeight: Integer;
begin
if (m_TitleBar = nil) or (not TitleBarVisible) then
Result := 0
else
Result := m_TitleBar.Height + 3
end;
function TsuiForm.GetTitleBarVisible: Boolean;
begin
if m_TitleBar = nil then
Result := false
else
Result := m_TitleBar.Visible;
end;
function TsuiForm.GetVersion: String;
begin
Result := '6.2';
end;
var
l_InFlag : Integer = 0;
procedure TsuiForm.Loaded;
begin
inherited;
if m_Form.FormStyle = fsMDIChild then
RegionWindow();
end;
procedure TsuiForm.NewParentWndProc(var Msg: TMessage);
var
Rect : TRect;
pcsp: PNCCalcSizeParams;
P : PWindowPos;
begin
if m_Destroyed then
Exit;
if Msg.Msg = WM_NCCALCSIZE then
begin
if Boolean(Msg.wParam) then
begin
pcsp := PNCCalcSizeParams(Msg.lParam);
P := pcsp^.lppos;
with pcsp^.rgrc[0] do
begin
Top := P^.y - Max(4, m_OldBottomBorderWidth) + 4;
if m_LeftBorderWidth <> 0 then
begin
Right := P^.x + P^.cx - Max(m_RightBorderWidth, 4) + Max(4, m_OldLeftBorderWidth) - 1;
Left := P^.x + Max(m_LeftBorderWidth, 4) - Max(4, m_OldLeftBorderWidth) + 1;
end
else
begin
Right := P^.x + P^.cx + Max(4, m_OldLeftBorderWidth) - 4;
Left := P^.x - Max(4, m_OldLeftBorderWidth) + 4;
end;
if m_BottomBorderWidth <> 0 then
Bottom := P^.y + P^.cy - Max(m_BottomBorderWidth, 4) + Max(4, m_OldBottomBorderWidth) - 1
else if m_Width = 3 then
Bottom := P^.y + P^.cy + Max(4, m_OldBottomBorderWidth) - 4
else
Bottom := P^.y + P^.cy - m_Width + 2 + Max(4, m_OldBottomBorderWidth) - 4;
end;
pcsp^.rgrc[1] := pcsp^.rgrc[0];
Msg.lParam := LongInt(pcsp);
Msg.Result := WVR_VALIDRECTS;
end
else
Msg.Result := 0;
end;
if Msg.Msg = SUIM_GETBORDERWIDTH then
begin
if m_LeftBorderWidth <> 0 then
Msg.Result := Max(m_LeftBorderWidth, 4)
else
Msg.Result := m_OldBottomBorderWidth - 1;
Exit;
end;
if (Msg.Msg <> WM_NCPAINT) and (Msg.Msg <> WM_NCACTIVATE) then
m_OldWndProc(Msg);
if Msg.Msg = WM_MDIACTIVATE then
begin
if TWMMDIActivate(Msg).ActiveWnd = m_Form.Handle then
begin
SendMessage(Application.MainForm.ClientHandle, WM_MDIREFRESHMENU, m_Form.Handle, 0);
m_TitleBar.FormActive := true;
end
else
m_TitleBar.FormActive := false;
end;
if Msg.Msg = WM_KEYDOWN then
ProcessKeyPress(Msg);
if Msg.Msg = WM_SHOWWINDOW then
begin
m_Form.Menu := nil;
end;
if Msg.Msg = WM_DESTROY then
begin
if m_Form.FormStyle = fsMDIChild then
begin
if Application = nil then
Exit;
if Application.MainForm.MDIChildCount = 1 then
SendMessage(Application.MainForm.ClientHandle, WM_MDIREFRESHMENU, m_Form.Handle, 0);
if m_Form.WindowState = wsMaximized then
SendMessage(Application.MainForm.ClientHandle, WM_MDIRESTORE, m_Form.Handle, 0);
end;
end;
if Msg.Msg = WM_ACTIVATE then
begin
if Msg.WParamLo = WA_INACTIVE then
m_TitleBar.FormActive := false
else
m_TitleBar.FormActive := true;
PaintFormBorder();
end;
if Msg.Msg = WM_NCACTIVATE then
begin
if m_Form.WindowState = wsMinimized then
m_OldWndProc(Msg)
else
begin
m_TitleBar.Repaint();
PaintFormBorder();
Msg.Result := 1;
end;
end;
if Msg.Msg = WM_NCPAINT then
begin
if m_Form.WindowState = wsMinimized then
m_OldWndProc(Msg)
else
begin
m_TitleBar.Repaint();
PaintFormBorder();
end;
end;
if (Msg.Msg = CM_RECREATEWND) or (Msg.Msg = CN_PARENTNOTIFY) or (Msg.Msg = CM_FLOAT) then
begin
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;
end;
if Msg.Msg = WM_SIZE then
begin
if (m_Form.WindowState = wsMaximized) and (csDesigning in ComponentState) then
Exit;
if m_FormInitMax then
begin
if m_Form.FormStyle <> fsMDIChild then
begin
if m_Form.WindowState <> wsMaximized then
begin
PlaceControl(m_Form, m_FormInitRect);
m_FormInitMax := false;
end
else if l_InFlag = 2 then
begin
m_Form.WindowState := wsMaximized;
end
else
Inc(l_InFlag);
end
else
begin
m_MaxFlag := true;
m_FormInitMax := false;
m_MaxFlag3 := true;
end;
end;
if (m_Form.WindowState = wsMaximized) and (m_Form.FormStyle <> fsMDIChild) then
begin
Rect := GetWorkAreaRect();
Dec(Rect.Bottom);
Dec(Rect.Top, 2);
Dec(Rect.Left, 2);
Inc(Rect.Right, 2);
PlaceControl(m_Form, Rect);
end;
m_TitleBar.ProcessMaxBtn();
m_TitleBar.Repaint();
PaintFormBorder();
if m_Form.FormStyle = fsMDIChild then
begin
if m_Form.WindowState = wsMaximized then
begin
m_SelfChanging := true;
TitleBarVisible := false;
m_SelfChanging := false;
if not m_MaxFlag then
begin
Self.ScrollBy(0, m_TitleBar.Height * -1 + 3);
m_MaxFlag := true;
SendMessage(Application.MainForm.ClientHandle, WM_MDIMAXIMIZE, m_Form.Handle, 0);
end;
end
else
begin
if m_MDIChildFormTitleVisible then
begin
m_SelfChanging := true;
TitleBarVisible := true;
m_SelfChanging := false;
end;
if m_MaxFlag then
begin
if (m_MaxFlag3 and m_MaxFlag2) or (not m_MaxFlag3) then
begin
Self.ScrollBy(0, m_TitleBar.Height - 3);
end;
m_MaxFlag2 := true;
m_MaxFlag := false;
m_TitleBar.ProcessMaxBtn();
SendMessage(Application.MainForm.ClientHandle, WM_MDIRESTORE, 0, 0);
end;
end;
end;
RegionWindow();
end;
if (Msg.Msg = WM_NCHITTEST) and (m_Form.FormStyle = fsMDIChild) and (m_OldBorderStyle = bsSingle) then
begin
if (
(Msg.Result = HTBOTTOM) or
(Msg.Result = HTBOTTOMLEFT) or
(Msg.Result = HTBOTTOMRIGHT) or
(Msg.Result = HTLEFT) or
(Msg.Result = HTRIGHT) or
(Msg.Result = HTTOP) or
(Msg.Result = HTTOPLEFT) or
(Msg.Result = HTTOPRIGHT)
) then
Msg.Result := HTBORDER;
end;
end;
procedure TsuiForm.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if AComponent = nil then
Exit;
if (
(Operation = opInsert) and
(csDesigning in ComponentState) and
(not (csLoading in ComponentState)) and
(AComponent.ClassName <> 'TsuiMainMenu') and
(AComponent is TMainMenu) and
(not g_SUIPackConverting)
) then
begin
MessageDlg(
'Strongly recommend you to use "TsuiMainMenu" instead of "TMainMenu".'
+ SUI_2ENTER + 'If you still want to use TMainForm, '
+ SUI_2ENTER + 'set ' + m_Form.Name + '''s MENU property to NIL please.'
+ SUI_2ENTER + 'And set ' + Name + '''s MENU property to this Menu when you finished designing the menu.',
mtInformation,
[mbOK],
0
);
end;
if (
(Operation = opInsert) and
(csDesigning in ComponentState) and
(not (csLoading in ComponentState)) and
(AComponent is TsuiMainMenu) and
(not g_SUIPackConverting) and
(Menu = nil) and
(AComponent.Owner = m_Form)
) then
begin
Menu := TsuiMainMenu(AComponent);
end;
if (
(Operation = opRemove) and
(AComponent = m_Panel)
)then
m_Panel := nil;
if (
(Operation = opRemove) and
(AComponent = m_Menu)
) then
DestroyMenuBar();
if (
(Operation = opRemove) and
(AComponent = self)
)then
begin
if m_Menu <> nil then
begin
if m_Menu is TsuiMainMenu then
(m_Menu as TsuiMainMenu).Form := nil;
end;
m_Destroyed := true;
if m_Form.HandleAllocated then
begin
SetWindowLong(m_Form.Handle, GWL_STYLE, GetWindowLong(m_Form.Handle, GWL_STYLE) or WS_CAPTION);
m_Form.WindowProc := m_OldWndProc;
SetWindowPos(m_Form.Handle, 0, 0, 0, 0, 0, SWP_DRAWFRAME or SWP_NOMOVE or SWP_NOZORDER or SWP_NOSIZE or SWP_NOACTIVATE);
end;
end;
if (
(Operation = opRemove) and
(AComponent = m_FileTheme)
)then
begin
m_FileTheme := nil;
ContainerApplyUIStyle(self, SUI_THEME_DEFAULT, nil);
SetUIStyle(SUI_THEME_DEFAULT);
end;
end;
{$IFDEF SUIPACK_D5}
procedure TsuiForm.OnApplicationHint(Sender: TObject);
begin
//
end;
{$ENDIF}
procedure TsuiForm.OnApplicationMessage(var Msg: TMsg;
var Handled: Boolean);
var
AMsg : TMessage;
begin
if Msg.message = 262 then
if LOWORD(Msg.wParam) = 32 then
begin
m_TitleBar.DefPopupMenu.Popup(Application.MainForm.Left, Application.MainForm.Top + m_TitleBar.Height);
Handled := true;
end;
if Msg.message = WM_KEYDOWN then
begin
AMsg.Msg := Msg.message;
AMsg.WParam := Msg.wParam;
AMsg.LParam := Msg.lParam;
ProcessKeyPress(AMsg);
Handled := Boolean(AMsg.Result);
end;
end;
procedure TsuiForm.Paint;
var
Buf : TBitmap;
Bmp : TBitmap;
begin
if m_Destroyed then
Exit;
if {$IFDEF RES_MACOS} (m_UIStyle = MacOS) {$ELSE} false {$ENDIF} or
{$IFDEF RES_PROTEIN} (m_UIStyle = Protein) {$ELSE} false {$ENDIF} then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -