Visualizzazione dei risultati da 1 a 9 su 9
  1. #1
    piccaweb
    Guest

    [ Delphi ] Testo in MessageDlg

    ciao!
    La mia domanda é molto semplice, ma non riesco a trovare la soluzione!
    io vorrei inserire un ritorno a capo poiché il mio testo é molto lungo, come posso fare?

    ed inoltre , all'interno del testo vorrei evidenziare delle parole in grassetto , é possibile?

    GRazie


  2. #2
    Utente di HTML.it
    Registrato dal
    Jul 2002
    Messaggi
    64

    ecco a te la soluzione in parte

    MsgBox "cia " & Chr(13) & " cii"

  3. #3
    oppure
    MessageDlg('Primo rigo'+#13+'Secondo Rigo', mtWarning, [mbOK], 0);

  4. #4
    piccaweb
    Guest
    per il grassetto, nessuno lo sa?

  5. #5
    attraverso le funzioni di delphi non credo che è possibile, se usi direttamente le funzioni delle api allora puoi fare quello che vuoi... anche personalizzare l'immagine a sx.

  6. #6
    piccaweb
    Guest
    Avevo già pensato alle API, ma non saprei proprio dove cercare nella guida in linea per avere alcune informazioni!

  7. #7
    dammi un pò di tempo e ti faccio sapere

  8. #8
    ti ho risposto sull'email.

    ciao

  9. #9
    scusa ma prima ho sbagliato 3d

    Questa è la unit completa!

    i bottoni sono in italiano!!!
    ciao



    quote:
    --------------------------------------------------------------------------------

    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls, ExtCtrls;

    type
    TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;

    var
    Form1: TForm1;

    type
    TRound = (rtEccesso,rtDifetto,rtMath);
    TMsgDlgType = (mtAvviso, mtErrore, mtInformazione, mtConferma, mtPersonale);
    TMsgDlgBtn = (mbSi, mbNo, mbOk, mbAnnulla, mbAbbandona, mbRiprova,
    mbIgnora, mbTutto, mbHelp);
    TMsgDlgBtns = set of TMsgDlgBtn;

    implementation

    {$R *.DFM}

    function Max(I, J: Integer): Integer;
    begin
    if I > J then Result := I else Result := J;
    end;

    function GetAveCharSize(Canvas: TCanvas): TPoint;
    var Metrics: TTextMetric;
    begin
    GetTextMetrics(Canvas.Handle, Metrics);
    Result.X:=Metrics.tmAveCharWidth;
    Result.Y:=Metrics.tmHeight;
    end;

    function CreateMsgDialog(const Msg: string; DlgType: TMsgDlgType;
    Buttons: TMsgDlgBtns): TForm;
    const
    mcHorzMargin = 6;
    mcVertMargin = 6;
    mcHorzSpacing = 8;
    mcVertSpacing = 8;
    mcButtonWidth = 42;
    mcButtonHeight = 12;
    mcButtonSpacing = 4;
    const
    Captions: array[TMsgDlgType] of string = ('Avviso','Errore',
    'Informazione','Conferma','');
    IconIDs: array[TMsgDlgType] of PChar = (IDI_EXCLAMATION, IDI_HAND,
    IDI_ASTERISK, IDI_QUESTION, nil);
    ButtonNames: array[TMsgDlgBtn] of string = (
    'Si', 'No', 'Ok', 'Annulla', 'Abbandona', 'Riprova', 'Ignora', 'Tutto', 'Help');
    ButtonCaptions: array[TMsgDlgBtn] of string = (
    '&Si', '&No', '&Ok', '&Annulla', 'A&bbandona', '&Riprova', '&Ignora','&Tutto','&Help');
    ModalResults: array[TMsgDlgBtn] of Integer = (
    mrYes, mrNo, mrOk, mrCancel, mrAbort, mrRetry, mrIgnore, mrAll, mrNone);
    var
    DialogUnits: TPoint;
    HorzMargin, VertMargin, HorzSpacing, VertSpacing, ButtonWidth,
    ButtonHeight, ButtonSpacing, ButtonCount, ButtonGroupWidth,
    IconTextWidth, IconTextHeight, X: Integer;
    B, DefaultButton, CancelButton: TMsgDlgBtn;
    IconID: PChar;
    TextRect: TRect;
    begin
    Result := TForm.CreateNew(Application);
    with Result do
    begin
    BorderStyle := bsToolWindow;
    BorderIcons:=[];
    Canvas.Font := Font;
    //stile della finestra
    Font.Style := [fsBold];
    Font.size:=10;
    Font.Color:= clBlue;
    DialogUnits := GetAveCharSize(Canvas);
    HorzMargin := MulDiv(mcHorzMargin, DialogUnits.X, 4);
    VertMargin := MulDiv(mcVertMargin, DialogUnits.Y, 8);
    HorzSpacing := MulDiv(mcHorzSpacing, DialogUnits.X, 4);
    VertSpacing := MulDiv(mcVertSpacing, DialogUnits.Y, 8);
    ButtonWidth := MulDiv(mcButtonWidth, DialogUnits.X, 4);
    ButtonHeight := MulDiv(mcButtonHeight, DialogUnits.Y, 8);
    ButtonSpacing := MulDiv(mcButtonSpacing, DialogUnits.X, 4);
    SetRect(TextRect, 0, 0, Screen.Width div 2, 0);
    DrawText(Canvas.Handle, PChar(Msg), -1, TextRect,
    DT_CALCRECT or DT_WORDBREAK);
    IconID := IconIDs[DlgType];
    IconTextWidth := TextRect.Right;
    IconTextHeight := TextRect.Bottom;
    if IconID <> nil then
    begin
    Inc(IconTextWidth, 32 + HorzSpacing);
    if IconTextHeight < 32 then IconTextHeight := 32;
    end;
    ButtonCount := 0;
    for B := Low(TMsgDlgBtn) to High(TMsgDlgBtn) do
    if B in Buttons then Inc(ButtonCount);
    ButtonGroupWidth := 0;
    if ButtonCount <> 0 then
    ButtonGroupWidth := ButtonWidth * ButtonCount +
    ButtonSpacing * (ButtonCount - 1);
    ClientWidth := Max(IconTextWidth, ButtonGroupWidth) + HorzMargin * 2;
    ClientHeight := IconTextHeight + ButtonHeight + VertSpacing +
    VertMargin * 2;
    Left := (Screen.Width div 2) - (Width div 2);
    Top := (Screen.Height div 2) - (Height div 2);
    if DlgType =mtPersonale
    then Caption:=Application.name
    else Caption := Captions[DlgType];
    if IconID <> nil then
    with TImage.Create(Result) do
    begin
    Name := 'Image';
    Parent := Result;
    Picture.Icon.Handle := LoadIcon(0, IconID);
    SetBounds(HorzMargin, VertMargin, 32, 32);
    end;
    with TLabel.Create(Result) do
    begin
    Name := 'Message';
    Parent := Result;
    WordWrap := True;
    Caption := Msg;
    BoundsRect := TextRect;
    SetBounds(IconTextWidth - TextRect.Right + HorzMargin, VertMargin,
    TextRect.Right, TextRect.Bottom);
    end;
    if mbOk in Buttons then DefaultButton := mbOk else
    if mbSi in Buttons then DefaultButton := mbSi else
    DefaultButton := mbRiprova;
    if mbAnnulla in Buttons then CancelButton := mbAnnulla;

    X := (ClientWidth - ButtonGroupWidth) div 2;
    for B := Low(TMsgDlgBtn) to High(TMsgDlgBtn) do
    if B in Buttons then
    with TButton.Create(Result) do
    begin
    Name := ButtonNames[B];
    //stile dei bottoni
    Parent := Result;
    ParentFont:=true;
    Font.Style:=[fsBold];
    Font.Size:=10;
    Caption := ButtonCaptions[B];
    ModalResult := ModalResults[B];
    if B = DefaultButton then Default := True;
    if B = CancelButton then Cancel := True;
    SetBounds(X, IconTextHeight + VertMargin + VertSpacing,
    ButtonWidth, ButtonHeight);
    Inc(X, ButtonWidth + ButtonSpacing);
    end;
    end;
    end;

    function EfMsg(const Msg: string;
    DlgType: TMsgDlgType;
    Buttons: TMsgDlgBtns): Integer;

    begin
    with CreateMsgDialog(Msg, DlgType, Buttons) do
    try
    Result := ShowModal;
    finally
    Free;
    end;
    end;

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    EfMsg('Daniele',mtErrore,[mbOk]);
    end;

    end.

    --------------------------------------------------------------------------------



    __________________
    _________________________________
    La vita ha già le sue difficoltà,
    i computer le accentuano...
    noi cerchiamo di risolverle o cmq
    di non crearne altre.
    dnl

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.