delphi - How to draw on a TPanel -


I need to draw on a TPanel, ideally ideally so that I do not have another component on it Mousevent- Event trapping (I want to draw a little "shape-hold" on it) How should I go about doing this? To correct this, you probably should write a line class. To attract the sizing hold, override the paint method, and add mouseDown , MouseUp , and MouseMove Change the size of functionality in override the controls.

I think there is a better solution than trying to attract your app code to TPanel for some reasons:

  1. Canvas is protected in property in TPanel , so you have no access to it from outside the class. You can get it with type-casting, but this is fraud.
  2. Like the convenience of the "resizability" panel, if it seems more than an application's convenience, then put it in the code for panel control, not in the main code of your application.

There is something like this to get you started:

  type TSizablePanel = class (TPanel) Private FDragOrigin: TPoint; FSizeRect: TRCT; Painted protection process; Override; Process MouseDown (Button: TMouseButton; Shift: TShiftState; X, Y: Integer); Override; Process mousemove (shift: techfstat; x, y: integer); Override; Process MouseUp (button: TMouseButton; Shift: TShiftState; X, Y: integer); Override; End; Process TSizeablePanel.Paint; inherited from; // Hold the sizing on the canvas property // Marlat font has a size-grip grip, // then try the canvas. Text method in combination / canvas with // property finishes; Process TSizeablePanel.MouseDown; (Button = MBAFT) and (Shift = []) and PtInRect (FSizeRect, Point (X, Y)) then start FDragOrigin: = point (X, Y); // Mouse Mouse Control even if you need to capture it. See also: Release Capture SetCapture (Handle); End inherited; End;  

Comments