📄 suidlg.pas
字号:
MsgDlg.FileTheme := FileTheme;
MsgDlg.Caption := Caption;
Result := MsgDlg.ShowModal();
MsgDlg.Free();
end;
{ TsuiDialog }
constructor TsuiDialog.Create(AOwner: TComponent);
begin
inherited;
m_Caption := 'suiDialog';
m_Position := poScreenCenter;
m_ButtonCursor := crHandPoint;
m_UIStyle := SUI_THEME_DEFAULT;
m_Font := TFont.Create();
m_CaptionFont := TFont.Create();
m_CaptionFont.Color := clWhite;
m_CaptionFont.Name := 'Tahoma';
m_CaptionFont.Style := [fsBold];
UIStyle := GetSUIFormStyle(AOwner);
end;
destructor TsuiDialog.Destroy;
begin
m_CaptionFont.Free();
m_CaptionFont := nil;
m_Font.Free();
m_Font := nil;
inherited;
end;
procedure TsuiDialog.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;
procedure TsuiDialog.SetCaptionFont(const Value: TFont);
begin
m_CaptionFont.Assign(Value);
end;
procedure TsuiDialog.SetFileTheme(const Value: TsuiFileTheme);
begin
m_FileTheme := Value;
SetUIStyle(m_UIStyle);
end;
procedure TsuiDialog.SetFont(const Value: TFont);
begin
m_Font.Assign(Value);
end;
procedure TsuiDialog.SetUIStyle(const Value: TsuiUIStyle);
var
OutUIStyle : TsuiUIStyle;
begin
m_UIStyle := Value;
if UsingFileTheme(m_FileTheme, m_UIStyle, OutUIStyle) then
begin
m_CaptionFont.Color := m_FileTheme.GetColor(SKIN2_TITLEFONTCOLOR);
m_Font.Color := m_FileTheme.GetColor(SKIN2_CONTROLFONTCOLOR);
end
else
begin
m_Font.Color := clBlack;
{$IFDEF RES_MACOS}
if m_UIStyle = MacOS then
m_CaptionFont.Color := clBlack
else
{$ENDIF}
m_CaptionFont.Color := clWhite;
end;
end;
{ TsuiMessageDialog }
constructor TsuiMessageDialog.Create(AOwner: TComponent);
begin
inherited;
ButtonCount := 1;
Button1Caption := 'OK';
Button2Caption := 'Cancel';
Button3Caption := 'Cancel';
Button1ModalResult := mrOK;
Button2ModalResult := mrCancel;
Button3ModalResult := mrCancel;
m_Text := 'Hello world!';
end;
function TsuiMessageDialog.ShowModal: TModalResult;
var
Dlg : TfrmMsg;
i : Integer;
Btn : TsuiButton;
lblHeight : Integer;
btnleft : Integer;
TmpBmp : TBitmap;
begin
Dlg := TfrmMsg.Create(Application);
Dlg.Font.Assign(m_Font);
Dlg.lbl.Caption := m_Text;
lblheight := Max(Dlg.Image1.BoundsRect.Bottom, Dlg.lbl.BoundsRect.Bottom);
if m_IconType <> suiNone then
begin
Dlg.lbl.Left := 88;
TmpBmp := TBitmap.Create();
TmpBmp.LoadFromResourceName(hInstance, 'MSGDLG');
SpitBitmap(TmpBmp, Dlg.Image1.Picture.Bitmap, 4, Ord(m_IconType));
TmpBmp.Free()
end
else
begin
Dlg.lbl.Left := 24;
Dlg.Image1.Visible := false;
if m_ButtonCount < 3 then
Dlg.Width := Dlg.Width - 64;
end;
btnleft := Dlg.Width - 73 - 24;
for i := m_ButtonCount downto 1 do
begin
Btn := TsuiButton.Create(Dlg);
Btn.Parent := Dlg.suiForm1;
Btn.Top := lblheight + 20;
Btn.Height := 25;
Btn.Width := 73;
Btn.Cursor := m_ButtonCursor;
Btn.Left := btnLeft;
Btn.TabStop := true;
Btn.TabOrder := 1;
Dec(btnLeft, 73 + 20);
case i of
1 :
begin
Btn.Caption := Button1Caption;
Btn.ModalResult := Button1ModalResult;
Dlg.ActiveControl := Btn;
end;
2 :
begin
Btn.Caption := Button2Caption;
Btn.ModalResult := Button2ModalResult;
Dlg.ActiveControl := Btn;
end;
3:
begin
Btn.Caption := Button3Caption;
Btn.ModalResult := Button3ModalResult;
Dlg.ActiveControl := Btn;
end;
end;
if Btn.ModalResult = mrCancel then
begin
Btn.Cancel := true;
Btn.Default := false;
end
else if Btn.ModalResult = mrOk then
begin
Btn.Cancel := false;
Btn.Default := true;
end
else
begin
Btn.Cancel := false;
Btn.Default := false;
end;
end;
Dlg.Height := lblheight + 20 + 25 + 30;
Dlg.Position := m_Position;
Dlg.suiForm1.ReAssign();
Dlg.suiForm1.Caption := m_Caption;
Dlg.suiForm1.UIStyle := m_UIStyle;
Dlg.suiForm1.FileTheme := m_FileTheme;
Dlg.suiForm1.Font.Assign(m_CaptionFont);
Result := Dlg.ShowModal();
Dlg.Free();
end;
{ TsuiPasswordDialog }
constructor TsuiPasswordDialog.Create(AOwner: TComponent);
begin
inherited;
Item1Caption := 'User name:';
Item2Caption := 'Password:';
Item1PasswordChar := #0;
Item2PasswordChar := '*';
Item1Text := '';
Item2Text := '';
ButtonOKCaption := 'OK';
ButtonCancelCaption := 'Cancel';
end;
function TsuiPasswordDialog.ShowModal: TModalResult;
var
Dlg : TfrmPass;
lblLength : Integer;
begin
Dlg := TfrmPass.Create(Application);
Dlg.Font.Assign(m_Font);
Dlg.lbl1.Caption := m_Item1Caption;
Dlg.lbl2.Caption := m_Item2Caption;
Dlg.edt1.Text := m_Item1Text;
Dlg.edt2.Text := m_Item2Text;
lblLength := Max(Dlg.lbl1.Width, Dlg.lbl2.Width);
Dlg.edt1.Left := Dlg.lbl1.Left + lblLength + 5;
Dlg.edt2.Left := Dlg.edt1.Left;
Dlg.edt1.PasswordChar := m_Item1PasswordChar;
Dlg.edt2.PasswordChar := m_Item2PasswordChar;
Dlg.btn1.Caption := m_ButtonOKCaption;
Dlg.btn1.Default := true;
Dlg.btn2.Caption := m_ButtonCancelCaption;
Dlg.btn2.Cancel := true;
Dlg.Width := Dlg.edt1.Left + Dlg.edt1.Width + 24;
Dlg.Position := m_Position;
Dlg.suiForm1.ReAssign();
Dlg.btn1.Left := Dlg.Width div 2 - 8 - Dlg.btn1.Width;
Dlg.btn2.Left := Dlg.Width div 2 + 8;
Dlg.btn1.Cursor := ButtonCursor;
Dlg.btn2.Cursor := ButtonCursor;
Dlg.suiForm1.Caption := m_Caption;
Dlg.suiForm1.UIStyle := m_UIStyle;
Dlg.suiForm1.FileTheme := m_FileTheme;
Dlg.suiForm1.Font.Assign(m_CaptionFont);
Result := Dlg.ShowModal();
if Result = mrOK then
begin
m_Item1Text := Dlg.edt1.Text;
m_Item2Text := Dlg.edt2.Text;
end;
Dlg.Free();
end;
{ TsuiInputDialog }
constructor TsuiInputDialog.Create(AOwner: TComponent);
begin
inherited;
PromptText := 'Prompt text:';
ValueText := '';
ButtonOKCaption := 'OK';
ButtonCancelCaption := 'Cancel';
end;
function TsuiInputDialog.ShowModal: TModalResult;
var
Dlg : TfrmInput;
begin
Dlg := TfrmInput.Create(Application);
Dlg.Font.Assign(m_Font);
Dlg.lbl_prompt.Caption := m_PromptText;
Dlg.edt_value.Text := m_ValueText;
Dlg.edt_value.PasswordChar := m_PasswordChar;
Dlg.btn1.Caption := m_ButtonOKCaption;
Dlg.btn1.Default := true;
Dlg.btn2.Caption := m_ButtonCancelCaption;
Dlg.btn2.Cancel := true;
Dlg.Position := m_Position;
Dlg.suiForm1.ReAssign();
Dlg.btn1.Left := Dlg.Width div 2 - 8 - Dlg.btn1.Width;
Dlg.btn2.Left := Dlg.Width div 2 + 8;
Dlg.btn1.Cursor := ButtonCursor;
Dlg.btn2.Cursor := ButtonCursor;
Dlg.suiForm1.Caption := m_Caption;
Dlg.suiForm1.UIStyle := m_UIStyle;
Dlg.suiForm1.FileTheme := m_FileTheme;
Dlg.suiForm1.Font.Assign(m_CaptionFont);
Result := Dlg.ShowModal();
if Result = mrOK then
m_ValueText := Dlg.edt_value.Text;
Dlg.Free();
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -