Board index » delphi » tpainbox and keyboard events
Tobias Hermann
![]() Delphi Developer |
Mon, 21 Jul 2003 02:24:53 GMT
|
Tobias Hermann
![]() Delphi Developer |
Mon, 21 Jul 2003 02:24:53 GMT
tpainbox and keyboard events
Hi!
I just wrote a small control-class which instances can be handled as simple Even when the PaintBox or the ScrollBox (in which the PaintBox is placed) So how can I check the keyboard events in my TPaintBox? Thanx PS: By the way: using Delphi 3 Professional |
M.H. Avegaar
![]() Delphi Developer |
Mon, 21 Jul 2003 16:46:54 GMT
Re:tpainbox and keyboard eventsWrite controls that paint on a TPaintBox ? I think you are missing the point of the VCL. Inherit your controls from TCustomControl and override the Paint method to draw the control on the Canvas of the control. Now you can put these controls directly on the form instead of using a TPaintBox ! "Tobias Hermann" <to...@mayn.de> schreef in bericht Quote> Hi! |
Tobias Herman
![]() Delphi Developer |
Tue, 22 Jul 2003 02:52:36 GMT
Re:tpainbox and keyboard eventshi! I changed the whole thing to TCustomControl.... VEEERY slow now ! Perhaps I missed some things of my old system... But the grafix output was much much faster with my own system (drawing to the canvas of tpaintbox)... what do you think? --> there are many many controls I have to create, about 400-500 small Thanx in advance.. Quote> Write controls that paint on a TPaintBox ? I think you are missing the |
M.H. Avegaar
![]() Delphi Developer |
Tue, 22 Jul 2003 16:01:39 GMT
Re:tpainbox and keyboard eventsSmall cells with text in different colors ? Why not you use a TStringGrid with OnDrawCell to draw colors/formatting ? "Tobias Hermann" <to...@mayn.de> schreef in bericht Quote> hi! I changed the whole thing to TCustomControl.... VEEERY slow now ! |
Tobias Herman
![]() Delphi Developer |
Tue, 22 Jul 2003 16:40:58 GMT
Re:tpainbox and keyboard eventsHmm... The cells aren't all one next to the other... some lines have a bit space bew{*word*249} them, some not (only a 1 pixel line)... Can I use different cell widthes and heights with the stringgrid solution? I first thought of a string grid but thought it wansn't flexible enough ? :-) Perhaps my knowledge isn't that good and I don't know the componenst good enoght... My solution is pretty fast and works fine but has no keyboard event handling But perhaps I should check out the StringGrid component better (never did My problem is: I do things myself before looking into my delphi book if Tobi Quote> Small cells with text in different colors ? Why not you use a TStringGrid |
M.H. Avegaar
![]() Delphi Developer |
Tue, 22 Jul 2003 16:47:04 GMT
Re:tpainbox and keyboard eventsIf a TStringGrid isn't good enough for you, you will have to write your own component (descendant of TCustomControl) that draws all the items on in canvas and determines how mouse-clicks and button-presses should be handled. "Tobias Hermann" <to...@mayn.de> schreef in bericht Quote> Hmm... The cells aren't all one next to the other... some lines have a bit |
Tobias Herman
![]() Delphi Developer |
Tue, 22 Jul 2003 18:39:23 GMT
Re:tpainbox and keyboard eventsI did that, but I had many small instances of my descendant of TCustomControl and this was slow. Do you mean I should make ONE class that handles several cells in its ONE Thanx Quote> If a TStringGrid isn't good enough for you, you will have to write your |
M.H. Avegaar
![]() Delphi Developer |
Tue, 22 Jul 2003 19:06:23 GMT
Re:tpainbox and keyboard eventsYes, create ONE class that draws the 'controls' on its canvas. If you derrive your class from TCustomControl it will be able to receive keyboard focus (in contrast to a TGraphicControl descendant like TPaintBox). "Tobias Hermann" <to...@mayn.de> schreef in bericht Quote> I did that, but I had many small instances of my descendant of |
Tobias Herman
![]() Delphi Developer |
Tue, 22 Jul 2003 19:28:27 GMT
Re:tpainbox and keyboard eventsthanx that works fine !! And I only had to change a bit of code --> not drawing to painbox1.canvas but to the own canvas of my descendant class, etc. Quote> Yes, create ONE class that draws the 'controls' on its canvas. If you |