Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: design time - register a custom items to right click menu


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 15 - Last Post: Oct 26, 2017 2:26 AM Last Post By: Lex Dean
Lex Dean

Posts: 132
Registered: 3/26/07
design time - register a custom items to right click menu  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 27, 2017 9:38 PM
http://www.scalabium.com/faq/dct0119.htm
http://etutorials.org/Programming/mastering+delphi+7/Part+II+Delphi+Object-Oriented+Architectures/Chapter+9+Writing+Delphi+Components/Writing+a+Component+Editor/

The above URL's describe how to add items to the right click menu at design time. Works well as I added it to my visual component with out any problems.

Now when I select a item from the menu, ExecuteVerb(Index: Integer); receives the message with item No. How to I link it to my object as thier is no link?
Do I find the current form (GetForm;), then find my object or focused object (identify object type), then execute a public procedure?

Or is thier a other or better way.

In my case I want to create and insert a new VCL to my main object.
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: design time - register a custom items to right click menu  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 27, 2017 11:52 PM   in response to: Lex Dean in response to: Lex Dean
Lex Dean wrote:

http://etutorials.org/Programming/mastering+delphi+7/Part+II+Delphi+Object-Oriented+Architectures/Chapter+9+Writing+Delphi+Components/Writing+a+Component+Editor/

The above URL's describe how to add items to the right click menu at
design time. Works well as I added it to my visual component with out
any problems.

Now when I select a item from the menu, ExecuteVerb(Index: Integer);
receives the message with item No. How to I link it to my object as
thier is no link? Do I find the current form (GetForm;), then find
my object or focused object (identify object type), then execute a
public procedure?

Or is thier a other or better way.

In my case I want to create and insert a new VCL to my main object.

Check out the DesignEditors, the TComponentEditor class contains public
properties Component and Designer in your code most probably you will
use these properties.
Lex Dean

Posts: 132
Registered: 3/26/07
Re: design time - register a custom items to right click menu  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 28, 2017 1:11 AM   in response to: Lajos Juhasz in response to: Lajos Juhasz
I do not get how to link TComponentEditorClass with my component as thier is no reference

uses
  Messages, Windows, SysUtils, Classes, Controls, Forms, Menus, Graphics,
  ImgList, VCLControl, CommCtrl, ToolWin, DesignIntf, DesignEditors;
 
type
 
 // my objects in hear
 
 
  TMovBarDropEditor = class(TComponentEditor)
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
  end;
 
procedure Register;
 
implementation
 
var
   Screen: TScreen;
 
procedure TMovBarDropEditor.ExecuteVerb(Index: Integer);
Var
   aControl: TControl;
   MovBut: TMovBut;
begin
  inherited;
  aControl := Screen.ActiveForm.ActiveControl;
  If aControl is my Main object then
   begin
    case Index of
      0: begin
          MovBut := TMovBut.Create(my Main object(aControl));
          MovBut.Style := tbsButton;
          my Main object(aControl).InsertButton(TControl(MovBut)); // installs the MovBut into object on a TList in my Main object.......
 in          end;
      1: begin
          MovBut := TMovBut.Create(my Main object(aControl));
          MovBut.Style := tbsSeparator;
          my Main object(aControl).InsertButton(TControl(MovBut));
         end;
    end;
  end;
end;
 
function TMovBarDropEditor.GetVerb(Index: Integer): string;
begin
   case Index of
    0: Result := 'New B&uttom';
    1: Result := 'New Se&parator'; // presented in the menu - good
  end;
end;
 
function TMovBarDropEditor.GetVerbCount: Integer;
begin
  Result := 2;   //count - good
end;
 
procedure Register;
Begin
  RegisterComponents('Win32', [my Main object]);
  RegisterComponentEditor(my Main object, TMovBarDropEditor);
End;
 


Edited by: Lex Dean on Sep 28, 2017 1:11 AM
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: design time - register a custom items to right click menu [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 28, 2017 2:22 AM   in response to: Lex Dean in response to: Lex Dean
Lex Dean wrote:

I do not get how to link TComponentEditorClass with my component as
thier is no reference

As I wrote the component property contains the component for which the
editor was activated.


procedure TMovBarDropEditor.ExecuteVerb(Index: Integer);
Var
    MovBut: TMovBut;
 begin
   inherited;
     case Index of
       0: begin
           MovBut := TMovBut.Create(Component);
           MovBut.Style := tbsButton;
           my Main object(Component).InsertButton(TControl(MovBut)); //
 installs the MovBut into object on a TList in my Main object.......
 in          end;       
       1: begin
           MovBut := TMovBut.Create(my Main object(Component));
           MovBut.Style := tbsSeparator;
           my Main object(Component).InsertButton(TControl(MovBut));
          end;
     end;
 
 end;
 
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: design time - register a custom items to right click menu [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 28, 2017 8:24 AM   in response to: Lajos Juhasz in response to: Lajos Juhasz
Lajos Juhasz wrote:

As I wrote the component property contains the component for which the
editor was activated.

Where "my main object" is the actual class type of your component:

uses
  ..., MyComponentUnit;
 
procedure TMovBarDropEditor.ExecuteVerb(Index: Integer);
var
  MovBut: TMovBut;
begin
  inherited;
  case Index of
    0: begin
      MovBut := TMovBut.Create(Component);
      MovBut.Style := tbsButton;
      TMyComponent(Component).InsertButton(MovBut);
    end;       
    1: begin
      MovBut := TMovBut.Create(Component);
      MovBut.Style := tbsSeparator;
      TMyComponent(Component).InsertButton(MovBut);
    end;
  end;
end;


--
Remy Lebeau (TeamB)
Lex Dean

Posts: 132
Registered: 3/26/07
Re: design time - register a custom items to right click menu [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 28, 2017 5:48 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
thanks Remy Lebeau you wrote it correctly and that seems correct code
I was basically on the correct tract but the editorial could have given a full example.

I found another problem in compiling - DesignIntf.dcu DesignEditors.dcu
I have Delphi 7 and the Proxies.pas file is missing
I've been reading https://edn.embarcadero.com/article/27717
In Delphi 7 I go - component>Install packages, but I cannot find the DesignIDE.bpl listed in Delphi
Am I doing this correctly or should I be some where else?

I was wondering when the day will come when we can add some code to fix this type of problem like some override switch
thanks in advance or get a Proxies.pas file
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: design time - register a custom items to right click menu [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 28, 2017 6:53 PM   in response to: Lex Dean in response to: Lex Dean
Lex Dean wrote:

I found another problem in compiling - DesignIntf.dcu
DesignEditors.dcu

Your design-time package needs to have 'DesignIDE.dcp' listed in its
'requires' list.

I have Delphi 7 and the Proxies.pas file is missing

I've been reading https://edn.embarcadero.com/article/27717

In Delphi 7 I go - component>Install packages, but I cannot find the
DesignIDE.bpl listed in Delphi

Am I doing this correctly or should I be some where else?

Read the article again more carefully. You are NOT supposed to install
DesigIDE.BPL into the IDE. It is already built-in. You are just
supposed to include 'DesignIDE.dcp' (and your component's runtime
package(s)) in your design-time package's 'requires' list. That is ALL
you need to do.

--
Remy Lebeau (TeamB)
Lex Dean

Posts: 132
Registered: 3/26/07
Re: design time - register a custom items to right click menu [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 29, 2017 1:17 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
for some reson I do not have a "DesignIDE.dcp" file at all unless it not under the Delphi folder
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: design time - register a custom items to right click menu [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 29, 2017 11:29 AM   in response to: Lex Dean in response to: Lex Dean
Lex Dean wrote:

for some reson I do not have a "DesignIDE.dcp" file at all unless it
not under the Delphi folder

There should be DesignIDE.bpi and DesignIDE.dcp files in the
"$(BDS)\lib\win32\release" folder, and a DesignIDE<version>.BPL file in
the "$(BDS)\bin" folder. If not, you might need to reinstall your IDE.

--
Remy Lebeau (TeamB)
Lex Dean

Posts: 132
Registered: 3/26/07
Re: design time - register a custom items to right click menu [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 29, 2017 5:13 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
I stand corrected
$(BDS)\lib\DesignIDE.dcp file does exist
Installing should be - component\install packages\runtime packages\add\browse - find designide.dcp and install
I do not see the package installed above in - design packages (no change). The edit line no has ;designide.dcp; added on the end.

When I right click on my menu of my design time object I still get - Access violation at address 51016711 in module 'dslusr70.bpl'. read of address 00000006C.
That means to me Delphi not using the designide.dcp package

I feal like taking the TMovBarDropEditor object and RegisterComponentEditor and putting it directly in my project, as I consider this is a stuff up by Delphi that needs a fix
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: design time - register a custom items to right click menu [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 29, 2017 6:20 PM   in response to: Lex Dean in response to: Lex Dean
Lex Dean wrote:

I stand corrected
$(BDS)\lib\DesignIDE.dcp file does exist

Installing should be - component\install packages\runtime
packages\add\browse - find designide.dcp and install

NO!!! DO NOT try to install DesignIDE manually at all. **ALL** you
need to do is make sure YOUR design-time package "requires"
DesignIDE.dcp (and make sure $(BDS)\lib is in the project's search
path). THAT IS ALL YOU NEED TO DO!!

When I right click on my menu of my design time object I still get -
Access violation at address 51016711 in module 'dslusr70.bpl'. read
of address 00000006C.

That has absolutely nothing to do with the DesignIDE package. Your
menu handler is doing something in code that it should not be doing.
Fix your code.

I feal like taking the TMovBarDropEditor object and
RegisterComponentEditor and putting it directly in my project

Design-time code, like property/component editors, MUST be in a
design-time package only. Putting it in your runtime package would be
a license violation. Design-time code is NOT ALLOWED in runtime
packages.

--
Remy Lebeau (TeamB)
Lex Dean

Posts: 132
Registered: 3/26/07
Re: design time - register a custom items to right click menu [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 30, 2017 6:48 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB)
Design time is clearly not execution time its ether one or the other set in TComponent
But how do I go about what you are talking about.
this point no one tells me in plain English they always talk around the point
Rudy Velthuis (...


Posts: 7,731
Registered: 9/22/99
Re: design time - register a custom items to right click menu [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 1, 2017 10:03 AM   in response to: Lex Dean in response to: Lex Dean
Lex Dean wrote:

Remy Lebeau (TeamB)
Design time is clearly not execution time its ether one or the other
set in TComponent But how do I go about what you are talking about.
this point no one tells me in plain English they always talk around
the point

<sigh>

Put the following line in the requires section of your package source
(the .pdk file):

requires
designide; // along with other packages you may need too.

Now make sure that, in the project options, you add $(BDS)\lib to the
Search Path

Now things should work, if your code is OK. There are several tutorials
on the web how to write an expert or plugin for Delphi (i.e. what the
code should look like).

But AFAIK, this is all documented (i.e. how to use a package,
designide.bpl is no different than other packages, except for the
license).

--
Rudy Velthuis http://www.rvelthuis.de

"Emulate your heros, but don't carry it too far. Especially
if they are dead."
Rudy Velthuis (...


Posts: 7,731
Registered: 9/22/99
Re: design time - register a custom items to right click menu [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 1, 2017 10:05 AM   in response to: Lex Dean in response to: Lex Dean
Lex Dean wrote:

Remy Lebeau (TeamB)
Design time is clearly not execution time its ether one or the other
set in TComponent But how do I go about what you are talking about.
this point no one tells me in plain English they always talk around
the point

The component runs (executes) in the context of the IDE, when you want
to use it in the designer.

In your app, it of course only runs in that context, but then you
should not have to use designide. Designide should only be used by the
package that registers the component in the IDE, not by the runtime
package.

--
Rudy Velthuis http://www.rvelthuis.de

"The competent programmer is fully aware of the strictly limited
size of his own skull; therefore he approaches the programming
task in full humility, and among other things he avoids clever
tricks like the plague." -- Edsger Dijkstra
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: design time - register a custom items to right click menu [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 2, 2017 10:14 AM   in response to: Lex Dean in response to: Lex Dean
Lex Dean wrote:

Design time is clearly not execution time its ether one or the other
set in TComponent

Component actually run at both design-time and run-time. The Form
Designer hosts live components in it.

A component can know if it is running at design-time by checking for
the csDesigning flag in its ComponentState property.

But how do I go about what you are talking about. this point no one
tells me in plain English they always talk around the point

There are numerous documents and tutorials readily available on how to
write custom packages and IDE/component editors. Start with
Embarcadero's own documentation:

http://docwiki.embarcadero.com/RADStudio/en/Packages

http://docwiki.embarcadero.com/RADStudio/en/Working_with_Packages_and_Components_Index

You MUST compile your component's runtime-related code in a
runtime-only package, and then compile your IDE-related code (editors,
registrations, etc) in a designtime-only package that "requires" your
runtime package (and the DesignIDE package when writing editors). Then
install the design-time package into the IDE.

--
Remy Lebeau (TeamB)
Lex Dean

Posts: 132
Registered: 3/26/07
Re: design time - register a custom items to right click menu [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 26, 2017 2:26 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
The problem was registering correctly

RegisterComponentEditor(TMyConponent, TDesignEditor);

Works good now
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02