⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 suidlg.pas

📁 suipack ver5控件 suipack ver5控件 suipack ver5控件 suipack ver5控件 suipack ver5控件
💻 PAS
📖 第 1 页 / 共 2 页
字号:
        (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;
    Tmp : Integer;
begin
    m_UIStyle := Value;

    if UsingFileTheme(m_FileTheme, m_UIStyle, OutUIStyle) then
    begin
        Tmp := m_FileTheme.GetColor(SUI_THEME_TITLEBAR_FONT_COLOR);
        if Tmp = -1 then
        begin
            Tmp := m_FileTheme.GetColor(SUI_THEME_CONTROL_FONT_COLOR);
            if (Tmp = 65536) or (Tmp = 262144) or (Tmp = 196608) or (Tmp = 327680) then
                m_CaptionFont.Color := clBlack
            else
                m_CaptionFont.Color := clWhite;
        end
        else
            m_CaptionFont.Color := Tmp;
    end
    else
    begin
{$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 + 20;
    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 + -