terça-feira, 22 de janeiro de 2019

Função sprintf - Modo gráfico








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

#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)
{
Canvas->Font->Size = 20;
Canvas->Font->Name = "Garamond";
Canvas->Font->Color = clRed;;
Canvas->TextOut ( 150, 18, "Função sprintf - Modo gráfico" );
String str_1 = " ";
String str_2 = " ";
char buf [ 50 ];
int i;
float Temp [ 8 ] = { 8.9, 9.5, 8.0, 11.8, 12.7, 7.6, 10.3, 15.4 };

     for ( i = 0; i < 8; i++ ) {
sprintf ( buf, " %.1f ", Temp [ i ] );
str_1 += " ";
str_1 += buf;
}
Canvas->Font->Size = 16;
Canvas->Font->Name = "Garamond";
Canvas->Font->Color = clBlue;;
Canvas->TextOut ( 150, 48, "Vetor de floats convertido em string" );
Canvas->Font->Color = clBlack;;
Canvas->TextOut ( 150, 78, str_1 );
Canvas->Font->Size = 20;
Canvas->Font->Color = clBlack;
Canvas->TextOut ( 200, 160, "Por: " );
Canvas->Font->Color = clRed;
Canvas->TextOut ( 260, 160, "Samuel Lima");
Canvas->Font->Color = clBlack;
Canvas->TextOut ( 200, 197, "sa_sp10@hotmail.com");
Canvas->Font->Name = "Garamond";
Canvas->Font->Size = 40;
Canvas->Font->Color = clSkyBlue;
Canvas->TextOut ( 76, 236, "MUITO OBRIGADO");
SetBkMode(Canvas->Handle, TRANSPARENT);
Canvas->Font->Color = clBlue;
Canvas->TextOut ( 70, 230, "MUITO OBRIGADO");
}

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

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

#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;
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
  HorzScrollBar.Color = clWhite
  HorzScrollBar.ParentColor = False
  Caption = 'Abrindo imagem com canvas'
  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 = 0
    Width = 601
    Height = 297
    Brush.Style = bsClear
    Pen.Width = 10
    Shape = stRoundRect
  end
  object Label1: TLabel
    Left = 120
    Top = 22
    Width = 10
    Height = 39
    Color = clWhite
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -32
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentColor = False
    ParentFont = False
  end
end

Nenhum comentário:

Postar um comentário

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