TPanel.Canvas ?

How Can i access to The TPanel.Canvas property ?

I am writing a annual calendar component. Each day is a TPanel. It works fine, but now i want to be abble to write :
1) In the Top Left Corner, in bold : the day number
2) In the Bottom right corner, in standard style : another number (User defined)

So, how could i do ?
The source code for the component is ready to use another object for the days. But this one have to publish all Drag events (used for multi-selection)
helpme020897Asked:
Who is Participating?
 
BlackManConnect With a Mentor Commented:
You can't! What you can to it to create a TPanel decendant component that creates a TBitmap in it's constuctor and then put your controls on the bitmap..
0
 
ZifNabCommented:
Hi helpme,

what about using TLables?

Make your own TPanel, inherit the TCustomPanel and overide the Paint method.

Regards, Zif.
0
 
ZifNabCommented:
Hi blackman. See that you were first :-)
0
 
SmillyCommented:
Hi there,
You can get the canvas, on almost all control like this,
you have to make your own canvas....

procedure TForm1.Button1Click(Sender: TObject);
var DC: HDC;
    Canvas: TCanvas;
begin
     DC:=GetDC(panel1.handle);
     Canvas:=TCanvas.Create;
     Canvas.Handle := DC;
     Canvas.LineTo(100,100);
     Canvas.Free;
end;

Hope this will help you....
0
 
viktornetCommented:
Smilly u also should release the DC..

ReleaseDC(Panel1.Handle, DC);

Merry Christmas!

-Viktor
--Ivanov
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.