This must be an old problem whose solution must have been posted many times, but I can't figure out how to phrase it for Google.
Anyway, I have a TPanel-like component that has a TLabel-like component on it, and the TLabel thingy fills the whole client area of the TPanel (Align = alCLient). When I mouse-click the control I need for the TPanel to respond.
Of course, the TLabel-like component has it's own mouse events so why not use them? Because in a drag-drop operation the TLabel can't move, and the panel, which is what I want to drag, does not move. Also, the TLabel is a subcomponent of my TPanel-like component.
I've been trying something like:
procedure TksLabel.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if not (csSubComponent in ComponentStyle) then
begin
// Draw a border around the control
Canvas.Pen.Color:=clWindowFrame;
Canvas.Pen.Width:=1;
Canvas.Pen.Style:=psDash;
Canvas.Brush.Style:=bsClear;
Canvas.Rectangle(Canvas.ClipRect);
if ssCtrl in Shift then BeginDrag(True);
end;
inherited MouseDown(Button, Shift, X, Y);
end;
This should skip the part where the program draws a dashed line around the TLabel if the TLabel is a subcomponent of the TPanel, but if the TLabel itslef is on a form, I should see the outline.
But it doesn't seem to work. Or rather, only if I take out the NOT part will it draw the border. Does dropping a component on a form turn it into a subcomponent of the form?
Second part, the mouse event doesn't seem to be getting passed along to the TPanel.
Help?
Thanks!
And Happy new year, for those of you that Jan 1 is New Year's day.