IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Composants VCL Delphi Discussion :

Smiley (image dans un RichEdit)


Sujet :

Composants VCL Delphi

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Décembre 2002
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2002
    Messages : 3
    Points : 5
    Points
    5
    Par défaut Smiley (image dans un RichEdit)
    Salut à tous !
    Je developpe un chat et je voudrais integrer des smiley.
    Le probleme c'est que je ne sais pas comment insérer une image dans un memo ou un richedit. Quelcun pourrait m'aider ?
    Merci a tous.
    Nicolas
    Ancien pseudo => Blind
    Pour y arriver dans la programmation, il faut chercher ! Alors cherchez !
    Config :
    Athlon XP 3200+, GeFX 5900XT, Boitier thermaltake...
    Windows XP SP2
    Delphi 7 Entreprise Fr

  2. #2
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    21
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 21
    Points : 25
    Points
    25
    Par défaut
    Pour le memo, je pense pas que ce soit possible. Vu que c'est un fichier texte (txt) et qui n'y a pas d'image dans ce type de fichier.
    Pour les RichEdit, on en a déjà parlé.
    Pensez à ajouter [Résolu] dans le titre de votre premier message (en l'éditant) une fois que votre problème est résolu.

  3. #3
    Expert éminent
    Avatar de Lung
    Profil pro
    Analyste-programmeur
    Inscrit en
    Mai 2002
    Messages
    2 664
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Analyste-programmeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 664
    Points : 6 961
    Points
    6 961
    Par défaut
    Sinon, j'ai trouvé ca (pas testé ) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    uses 
      RichEdit; 
     
    // Stream Callback function 
    type 
      TEditStreamCallBack = function(dwCookie: Longint; pbBuff: PByte; 
        cb: Longint; var pcb: Longint): DWORD; 
      stdcall; 
     
      TEditStream = record 
        dwCookie: Longint; 
        dwError: Longint; 
        pfnCallback: TEditStreamCallBack; 
      end; 
     
    // RichEdit Type 
    type 
      TMyRichEdit = TRxRichEdit; 
     
    // EditStreamInCallback callback function 
    function EditStreamInCallback(dwCookie: Longint; pbBuff: PByte; 
      cb: Longint; var pcb: Longint): DWORD; stdcall; 
      // by P. Below 
    var 
      theStream: TStream; 
      dataAvail: LongInt; 
    begin 
      theStream := TStream(dwCookie); 
      with theStream do 
      begin 
        dataAvail := Size - Position; 
        Result := 0; 
        if dataAvail <= cb then 
        begin 
          pcb := read(pbBuff^, dataAvail); 
          if pcb <> dataAvail then 
            Result := UINT(E_FAIL); 
        end 
        else 
        begin 
          pcb := read(pbBuff^, cb); 
          if pcb <> cb then 
            Result := UINT(E_FAIL); 
        end; 
      end; 
    end; 
     
    // Insert Stream into RichEdit 
    procedure PutRTFSelection(RichEdit: TMyRichEdit; SourceStream: TStream); 
      // by P. Below 
    var 
      EditStream: TEditStream; 
    begin 
      with EditStream do 
      begin 
        dwCookie := Longint(SourceStream); 
        dwError := 0; 
        pfnCallback := EditStreamInCallBack; 
      end; 
      RichEdit.Perform(EM_STREAMIN, SF_RTF or SFF_SELECTION, Longint(@EditStream)); 
    end; 
     
    // Convert Bitmap to RTF Code 
    function BitmapToRTF(pict: TBitmap): string; 
    // by D3k 
    var 
      bi, bb, rtf: string; 
      bis, bbs: Cardinal; 
      achar: ShortString; 
      hexpict: string; 
      I: Integer; 
    begin 
      GetDIBSizes(pict.Handle, bis, bbs); 
      SetLength(bi, bis); 
      SetLength(bb, bbs); 
      GetDIB(pict.Handle, pict.Palette, PChar(bi)^, PChar(bb)^); 
      rtf := '{\rtf1 {\pict\dibitmap '; 
      SetLength(hexpict, (Length(bb) + Length(bi)) * 2); 
      I := 2; 
      for bis := 1 to Length(bi) do 
      begin 
        achar := Format('%x', [Integer(bi[bis])]); 
        if Length(achar) = 1 then 
          achar := '0' + achar; 
        hexpict[I - 1] := achar[1]; 
        hexpict[I] := achar[2]; 
        Inc(I, 2); 
      end; 
      for bbs := 1 to Length(bb) do 
      begin 
        achar := Format('%x', [Integer(bb[bbs])]); 
        if Length(achar) = 1 then 
          achar := '0' + achar; 
        hexpict[I - 1] := achar[1]; 
        hexpict[I] := achar[2]; 
        Inc(I, 2); 
      end; 
      rtf := rtf + hexpict + ' }}'; 
      Result := rtf; 
    end; 
     
     
    // Example to insert image from Image1 into RxRichEdit1 
    procedure TForm1.Button1Click(Sender: TObject); 
    var 
      SS: TStringStream; 
      BMP: TBitmap; 
    begin 
      BMP := TBitmap.Create; 
      BMP := Image1.Picture.Bitmap; 
      SS  := TStringStream.Create(BitmapToRTF(BMP)); 
      try 
        PutRTFSelection(RxRichEdit1, SS); 
      finally 
        SS.Free; 
      end; 
    end;
    L'urgent est fait, l'impossible est en cours, pour les miracles prévoir un délai. ___ Écrivez dans un français correct !!

    C++Builder 5 - Delphi 6#2 Entreprise - Delphi 2007 Entreprise - Delphi 2010 Architecte - Delphi XE Entreprise - Delphi XE7 Entreprise - Delphi 10 Entreprise - Delphi 10.3.2 Entreprise - Delphi 10.4.2 Entreprise - Delphi 11.1 Entreprise
    OpenGL 2.1 - Oracle 10g - Paradox - Interbase (XE) - PostgreSQL (15.4)

  4. #4
    Membre habitué

    Profil pro
    Inscrit en
    Mars 2002
    Messages
    4
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2002
    Messages : 4
    Points : 127
    Points
    127
    Par défaut
    Voici un composant Richedit qui supporte des images :

    "richview"

    Je l'ai trouvé sur torry.net

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. redimensionner une image dans de texte RTF (RichEdit)
    Par byhack0 dans le forum Autres outils décisionnels
    Réponses: 1
    Dernier message: 29/05/2008, 09h23
  2. Delphi 7 - Inserer une image dans RichEdit
    Par Nicolas Coolman dans le forum Composants VCL
    Réponses: 1
    Dernier message: 06/09/2007, 15h58
  3. Image gif dans un richedit
    Par Tetlis dans le forum Windows
    Réponses: 4
    Dernier message: 30/07/2006, 14h04
  4. Coloration syntaxique ASM dans un RichEdit
    Par Crick dans le forum Composants VCL
    Réponses: 5
    Dernier message: 20/12/2002, 01h53
  5. [VB6] [Excel] Insérer une image dans une feuille
    Par mathias dans le forum VB 6 et antérieur
    Réponses: 7
    Dernier message: 09/10/2002, 07h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo