Hello


Hello,

I'm working on a TGraphicControl that supports a parent relationship.

With RegisterSprigType I can handle the Drag&Drop in the structure view

I had to use RegisterComponentGuideLines to avoid a call to Parent.GetClientOrigin for a component that do not have a TWinControl Parent.

Now I have to fix two things, when I click on GraphicPanel2 inside GraphicPanel1 (on the form, not in the treeview) GraphicPanel1 is selected...

And the blue points are not relative to GraphicPanel2's parent...

Any idea ?

Thanks

Comments

  1. Perhaps the answer is to be found in the code.....

    ReplyDelete
  2. Publish your code. Allow for pull-requests.

    ReplyDelete
  3. there's nothing about that in my code.

    I've added a GraphicParent property that is handled with those well known and documented functions:

    procedure SetParentComponent(Value: TComponent); override;
    function HasParent: Boolean; override;
    function GetParentComponent: TComponent; override;
    procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;

    So GraphicPanel2.Parent is nil, and GraphicPanel2.GraphicParent is GraphicPanel1. when GraphicPanel1 is painted, it paints it's child also. There's no magic in that.

    And that don't tell my how to tell the IDE to select a child component of a TGraphicControl nor how to change de handles position of a child component when it is selected in the treeview

    ReplyDelete
  4. Still compilable source code would make it a lot easier for other people to take a closer look.

    ReplyDelete
  5. Attila Kovacs yes that's the problem, but how can I tell Delphi to take the parent's origin into account, that is the question. I've change the way the sub-components are drawn, so they match the selection boundaries, but that's not what I want, because Top/Left need to be parent related.

    What I'm looking for is another RegisterSomething() that can override de default behavior.

    Anyway, I'm not sure it's possible, the DesignForm source code is not available and I can't find how this works.

    ReplyDelete
  6. I've found something for the selection...TActionManager (TComponent) is parent of the actions (TGraphicControl) displayed in a ActionMainMenuBar (TWinControl)...and it use csDesignInteractive to handle the clicks :)

    EDIT: dead end, there's an ActionBarDesigner to handle this, I can't use it :/

    ReplyDelete
  7. No idea why you are concealing the code. It would be easy with a MCVE.

    ReplyDelete
  8. ahhh ! how many times will I make this mistake :/

    function TGraphicPanel.GetClientOrigin: TPoint;
    begin
    if FGraphicParent = nil then
    begin
    inherited;
    end else begin
    Result := FGraphicParent.GetClientOrigin;
    Inc(Result.X, Left);
    Inc(Result.Y, Top);
    end;
    end;

    ReplyDelete
  9. Reasoning about client origin spaces is never easy for me either.

    ReplyDelete
  10. Warren Postma it's not about the function, but the call to inherited is incorrect, it should be

    Result := inherited GetClientOrigin;

    ReplyDelete

Post a Comment