Home Component Writing
New Blog Posts: Merging Reports - Part 1 and Part 2

events on a TppLabel desendent

edited September 2002 in Component Writing
Hallo

I have (would like) to add 2 private events to my custome component.
1: onDblClick := show default property editor.
2: OnTextChanged := Set my Translated property to false.

These are not events that the user can use but would make my life a lot
easier. I tried copieng the regular TControl OnDoubleClick but did not
get it to work at all.

Do you have some sample of how I can do this, that is if it is posible.

Thanks,

Walter
CPI AG

Comments

  • edited September 2002
    A private event? Do you mean event handler? If it is private, just call the
    method directly. An event property allows communication between two objects
    at rutime so that when one has some action that takes place and it wants to
    notify a single listener, it can call a method in the listnening object
    through the method pointer.

    I'm gonna guess that you have a popup menu and want to listed for changes in
    it. You need two private event handlers I imagine. What are the event types
    that you need handlers for? You need to check the signature of the event
    type to see what the handler should look like. For example, TNotifyEvent has
    Sender: TObject as a single parameter, and so any event handler that is
    connected to it has to match that signature so that it can be assigned.

    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited September 2002
    If you want to catch the user double-click and show the default property
    editor just like in delphi design. You can't. Event aren't transmited from
    the designer to the report components.

    The only way out is to add an item in the popup menu that would call the
    property editor.

    --
    Daniel Lemire
    Programmeur,
    Conception Design Ware Inc.
    Tél.: 819-868-8853
    Fax : 819-868-8855
  • edited September 2002
    Hi Jim


    Can I react on a double-click on the component ad designtime, if so how.

    Walter

  • edited September 2002
    You can access the component's design control. The design control is what
    is created in the designer. However, since method pointers only support one
    method, then you will lose any event handlers that were previously assigned
    by the code internal to the designer. The following code does work.
    However, a better alternative would be to hook into the Windows messaging to
    listen for the mouse double click on the design control.

    uses
    ppDsgnCt;

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    ppDesigner1.ShowModal;
    end;

    procedure TForm1.ppDesigner1Show(Sender: TObject);
    begin
    if (ppLabel1.DesignControl <> nil) then
    ppLabel1.DesignControl.OnDblClick := DoubleClickHandler;
    end;

    procedure TForm1.DoubleClickHandler(Sender: TObject);
    begin
    Beep;
    end;


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited September 2002
    After further review, the double click won't be able to be hooked into using
    the DesignControl as shown in the code below.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited September 2002
    Hi Jim

    Can one hook into the Windows messaging system?

    walter



  • edited September 2002
    Here is an article on hooks and Delphi:

    http://delphi.about.com/library/bluc/text/uc063001a.htm


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited December 2002
    This is a multi-part message in MIME format.
  • edited January 2003
    I've found part of the solution for the infinite loop caused when changing bands.

    The InstantiateDesignControl is called again but not the FreeDesignControl. So the events are
    linked back to my own event methods.

    So here's what I did in the InstantiateDesignControl:

    if not Assigned(fMyDblClick) then
    begin
    fMyDblClick := DesignControl.OnDblClick;
    DesignControl.OnDblClick := MyDblClick;
    end;

    Any idea why the InstantiateDesignControl is called without the FreeDesignControl?
    Is this normal behavior and I didn't understand the designcontrol workings correctly?

    --
    Daniel Lemire
This discussion has been closed.