Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

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)
0
helpme020897
Asked:
helpme020897
1 Solution
 
BlackManCommented:
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now