quarta-feira, 23 de janeiro de 2019

C++ Builder - utilizando o objeto Memo

Quando queremos exibir textos simples
sem formatações no C++ Builder a melhor
opção é o objeto Memo.
O Memo possui diversas propriedades,
e a maioria destas propriedades são comuns
a outros componentes do C++ Builder.
Neste exemplo estamos usando apenas três,
destas propriedades que são:

Memo1->Enabled = false;
Não permite que o usuário faça qualquer
edição no texto apresentado pelo Memo.
Memo2->MaxLength = 300;
O comprimento máximo do número de caracteres
 digitados, o padrão é 0, isto é, ilimitado.
Memo2->WordWrap = true;
Quebra automática de palavras ao atingir a borda, 
se definido como verdadeiro .
Existem muitas outras propriedades,
mas para este exemplo não se fez necessário.




//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "OnPaint.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1 ( TComponent* Owner ) :
TForm ( Owner ) {
}
//---------------------------------------------------------------------------
void __fastcall TForm1::OnPaint ( TObject *Sender ) {
Label1 -> Caption  =  "Por: Samuel Lima";
String str_1 = " ";
int A [ 100 ], a, i;
for ( i = 0; i < 100; i++ ) {
A [ a ] = i;
a++;
}
for ( a = 0; a < 100; a++ ) {
if ( ( a > 0 ) ) {
str_1 += " ";
}
if ( A [ a ] >= 0 && A [ a ] < 10 ) {
str_1 += ( "0" );
}
str_1 += A [ a ];
}

Memo1->Enabled = false;
Memo1->Lines->Strings [ 0 ] = "Utilizando Objeto Memo";
Memo2->MaxLength = 300;
Memo2->Lines->Strings [ 0 ] = str_1;
Memo2->WordWrap = true;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------

#ifndef OnPaintH
#define OnPaintH
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ExtCtrls.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TShape *Shape1;
TMemo *Memo1;
TMemo *Memo2;
TLabel *Label1;
void __fastcall OnPaint(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif


object Form1: TForm1
  Left = 342
  Top = 219
  Caption = 'C++ Builder - utilizando Memo'
  ClientHeight = 300
  ClientWidth = 600
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  Position = poDesigned
  OnPaint = OnPaint
  PixelsPerInch = 96
  TextHeight = 13
  object Shape1: TShape
    Left = 0
    Top = 3
    Width = 601
    Height = 294
    Brush.Style = bsClear
    Pen.Color = clRed
    Pen.Width = 10
    Shape = stRoundRect
  end
  object Label1: TLabel
    Left = 232
    Top = 260
    Width = 6
    Height = 23
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -19
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentFont = False
  end
  object Memo1: TMemo
    Left = 176
    Top = 16
    Width = 249
    Height = 25
    BorderStyle = bsNone
    Color = clLime
    Font.Charset = BALTIC_CHARSET
    Font.Color = clBlack
    Font.Height = -21
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentFont = False
    TabOrder = 0
  end
  object Memo2: TMemo
    Left = 176
    Top = 47
    Width = 249
    Height = 210
    BorderStyle = bsNone
    Color = clMenuHighlight
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -17
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentFont = False
    TabOrder = 1
    WordWrap = False
  end
end

Nenhum comentário:

Postar um comentário

Observação: somente um membro deste blog pode postar um comentário.