aLiEn
July 29th, 2005, 12:54 AM
Hello, All!
I write on Borland++ Builder 6.
There is a main class in which GDI + is initialized. As there I declare
Gdiplus::Graphics* GM;
There is other class where I simply create the panel (I wish to draw and display on it pictures).
Now we create the project and the main class is initialized
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
GP = new TERedGDIP();
.....
}
After I create the panel on which I shall draw
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if( GP->CreateGP( Form1 ) )
// ShowMessage(" YES ");
Application->ProcessMessages();
GP->Document->Area->Height = 400;
GP->Document->Area->Width = 600;
GP->Document->Area->Color = clWhite;
GP->SetPageUnit( UnitPixel );
}
In the main class it is described so
bool __fastcall TERedGDIP::CreateGP( TForm* MainForm )
{
GM = 0;
Document = 0;
try
{
Document = new TDocGDIP( MainForm );
GM = new Gdiplus::Graphics( Document->hDC );
}
catch(...)
{
bGM = false;
delete Document;
return false;
}
bGM = true;
return true;
}
All is created, all sees on the main form of a program. But here has wanted to draw a line and to write, ан has not left.
void __fastcall TERedGDIP::OutTextT( )
{// I write in stupid to see result
WCHAR welcome[]=L"Welcome GDI+!";
RECT rc;
Gdiplus::Pen blackPen(Gdiplus::Color(255, 0, 0, 0), 3);
int x1 = 100;
int y1 = 100;
int x2 = 500;
int y2 = 200;
GM->DrawLine(&blackPen, x1, y1, x2, y2);
Gdiplus::RectF bounds(0, 0, 500, 500);
LinearGradientBrush brush(bounds, Gdiplus::Color(130, 255, 0, 0),
Gdiplus::Color(255, 0, 0, 255),
Gdiplus::LinearGradientModeBackwardDiagonal);
Gdiplus::StringFormat format;
format.SetAlignment(Gdiplus::StringAlignmentCenter);
format.SetLineAlignment(Gdiplus::StringAlignmentCenter);
Gdiplus::Font font(L"Arial", 30, Gdiplus::FontStyleBold);
GM->DrawString(welcome, -1, &font, bounds, &format, &brush);
}
All is fulfilled, but on the panel nothing is visible. If in this function I create Gdiplus:: Graphics g (Document-> hDC); (accordingly everywhere I change GM-> on g.), all works. Why? Where to look, where to dig?
THANKS!
I write on Borland++ Builder 6.
There is a main class in which GDI + is initialized. As there I declare
Gdiplus::Graphics* GM;
There is other class where I simply create the panel (I wish to draw and display on it pictures).
Now we create the project and the main class is initialized
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
GP = new TERedGDIP();
.....
}
After I create the panel on which I shall draw
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if( GP->CreateGP( Form1 ) )
// ShowMessage(" YES ");
Application->ProcessMessages();
GP->Document->Area->Height = 400;
GP->Document->Area->Width = 600;
GP->Document->Area->Color = clWhite;
GP->SetPageUnit( UnitPixel );
}
In the main class it is described so
bool __fastcall TERedGDIP::CreateGP( TForm* MainForm )
{
GM = 0;
Document = 0;
try
{
Document = new TDocGDIP( MainForm );
GM = new Gdiplus::Graphics( Document->hDC );
}
catch(...)
{
bGM = false;
delete Document;
return false;
}
bGM = true;
return true;
}
All is created, all sees on the main form of a program. But here has wanted to draw a line and to write, ан has not left.
void __fastcall TERedGDIP::OutTextT( )
{// I write in stupid to see result
WCHAR welcome[]=L"Welcome GDI+!";
RECT rc;
Gdiplus::Pen blackPen(Gdiplus::Color(255, 0, 0, 0), 3);
int x1 = 100;
int y1 = 100;
int x2 = 500;
int y2 = 200;
GM->DrawLine(&blackPen, x1, y1, x2, y2);
Gdiplus::RectF bounds(0, 0, 500, 500);
LinearGradientBrush brush(bounds, Gdiplus::Color(130, 255, 0, 0),
Gdiplus::Color(255, 0, 0, 255),
Gdiplus::LinearGradientModeBackwardDiagonal);
Gdiplus::StringFormat format;
format.SetAlignment(Gdiplus::StringAlignmentCenter);
format.SetLineAlignment(Gdiplus::StringAlignmentCenter);
Gdiplus::Font font(L"Arial", 30, Gdiplus::FontStyleBold);
GM->DrawString(welcome, -1, &font, bounds, &format, &brush);
}
All is fulfilled, but on the panel nothing is visible. If in this function I create Gdiplus:: Graphics g (Document-> hDC); (accordingly everywhere I change GM-> on g.), all works. Why? Where to look, where to dig?
THANKS!