Home Devices

Selected component ?

edited February 2003 in Devices
Hi,

Iin delphi unit, I would know the component's ClassName which is selected on
the designer.

I tried :
MyReport.ActiveReport.Components[MyReport.ActiveReport.ComponentIndex] but
it isn't the component the end-user has selected.

Is-there a possibilite to know that ?

Comments

  • edited February 2003
    Inside of the designer's OnSelectionChanged event, you can get the selected
    components:

    procedure TForm1.ppDesigner1SelectionChanged(Components:
    TppDesignerSelectionList);
    begin
    Components[0].ClassName;
    end;

    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited February 2003
    And not in the OnSelectionChanged event ?



  • edited February 2003
    That event is the way to get at the current selection. Otherwise, the
    designer form's ActiveControl property returns a TEdit which is a
    "KeyCatcher" that listens to the keyboard strokes made while the designer is
    open.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited February 2003
    My exact problem is:
    When The end-user move a component with the mouse, at MouseUp an event
    "OnDrawItem" is generated to the EditToolBar.ComboBox(2) component. I
    implement this event and it's in my procedure that I require the classname
    to the selectionned's component.

    My code:
    Begin
    MyToolbarManager := TppDesignerWindow(MyDesigner.Form).ToolbarManager;
    MyEditToolBar := TppEditToolBar(MyToolbarManager.FindToolbar('Edit'));
    MyEditToolBar.ComboBox.OnDrawItem := ParamToolBarCombo;
    ...
    End;

    Procedure ParamToolBarComboParamToolBarCombo(Control: TWinControl; Index:
    Integer;

    Rect: TRect; State: TOwnerDrawState);
    Begin
    MyClassName := ? ? ? ? The Componet's class moved by the end-user
    ...
    End;

    Sorry for my english and thanks


  • edited February 2003
    Use the OnSelectionChanged event to grab a handle to the component which is
    currently selected. The OnDrawItem event should fire after that, because the
    user must select the combo box in the toolbar after selecting a component.
    Have you tried this?

    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.