Paint w C++ Builder - problem z rysowaniem, Random i odświeżaniem

0

Witam. Mam problem z moim programem PAINT w C++ Bulider 4, a właściwie kilka problemów. Jeden najważniejszy jest taki, że program narysuje mi linie, ale niestety nie narysuje mi prostokąta, a po kliknięciu przycisku wyczyść obszar jest czyszczony, ale nie narysuje już nic... Drugi problem jest taki, że nie mogę użyć funkcji Random, Randomize itp dla współrzędnych x i y. Proszę jeśli ktoś może pomóc to proszę o w miarę szybką pomoc, gdyż już się tyle nawkurzałem i próbowałem tylu rzeczy i nadal nic...

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <math.hpp>

#include "Paint_1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"

TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::ToolButton1Click(TObject *Sender)
{
SavePictureDialog1->Execute();
Image1->Picture->SaveToFile(SavePictureDialog1->FileName);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::RGFiguraClick(TObject *Sender)
{
if (RGFigura->ItemIndex==0)
{
CBWzorWyp->Enabled=false;
CBWypelnienie->Enabled=false;
}
if (RGFigura->ItemIndex==1)
{
CBWzorWyp->Enabled=true;
CBWypelnienie->Enabled=true;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(CBWypelnienie->ItemIndex==0) Image1->Canvas->Brush->Color = clRed;
if(CBWypelnienie->ItemIndex==1) Image1->Canvas->Brush->Color = clGreen;
if(CBWypelnienie->ItemIndex==2) Image1->Canvas->Brush->Color = clBlue;
if(CBWypelnienie->ItemIndex==3) Image1->Canvas->Brush->Color = clYellow;
if(CBWypelnienie->ItemIndex==4) Image1->Canvas->Brush->Color = clBlack;

if(CBWzorWyp->ItemIndex==0) Image1->Canvas->Brush->Style=bsHorizontal;
if(CBWzorWyp->ItemIndex==1) Image1->Canvas->Brush->Style=bsVertical;
if(CBWzorWyp->ItemIndex==2) Image1->Canvas->Brush->Style=bsBDiagonal;
if(CBWzorWyp->ItemIndex==3) Image1->Canvas->Brush->Style=bsCross;

if(CBKolorObwodu->ItemIndex==0) Image1->Canvas->Pen->Color = clRed;
if(CBKolorObwodu->ItemIndex==1) Image1->Canvas->Pen->Color = clGreen;
if(CBKolorObwodu->ItemIndex==2) Image1->Canvas->Pen->Color = clBlue;
if(CBKolorObwodu->ItemIndex==3) Image1->Canvas->Pen->Color = clYellow;
if(CBKolorObwodu->ItemIndex==4) Image1->Canvas->Pen->Color = clBlack;

if(CBWzorObwodu->ItemIndex==0) Image1->Canvas->Pen->Style = psDashDot;
if(CBWzorObwodu->ItemIndex==1) Image1->Canvas->Pen->Style = psDot;
if(CBWzorObwodu->ItemIndex==2) Image1->Canvas->Pen->Style = psDashDotDot;
if(CBWzorObwodu->ItemIndex==3) Image1->Canvas->Pen->Style = psSolid;

if (RGFigura->ItemIndex==0)
{
int x,y;
x=800;
y=400;

Image1->Canvas->LineTo (x,y);

}

if(RGFigura->ItemIndex==1)
{
int x1,x2,x3,x4;
x1=(800);
x2=400;
x3=800;
x4=400;

Image1->Canvas->Rectangle (x1,x2,x3,x4);
//---------------------------------------------------------------------------
}
}
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Image1->Canvas->Brush->Color = clWhite;
Image1->Canvas->Brush->Style = bsSolid;
Image1->Canvas->FillRect(TRect(0,0,Image1->Width-1,Image1->Height-1));
Image1->Refresh();


}
//---------------------------------------------------------------------------
0

x1=400;
x2=400;
x3=800;
x4=800;

0

Niestety problem dalej nie został naprawiony.

1 użytkowników online, w tym zalogowanych: 0, gości: 1