Jump to content
PiedSoftware

Has anyone been able to get the Color TJvSpeedItem to work correctly on TFrame?

Recommended Posts

I am trying to get a reusable TFrame working to use in a number of places in our app to let the users edit and format text in a TJvRichEdit. It consists of a TJvRichEdit and a TJvSpeedBar. The JEDI example code works, and I have copied and pasted the relevant form into the test project where I am developing this frame. 

 

But there is a problem in the frame: the colour buttons (Color and Background), which drop down lists of colours in the sample code and change the colour of the text, don't display correctly in the frame. They appear full length but empty, although selecting an item does change the colour of the text. In contrast the Underline button has a drop down list that looks and works fine in my code. The code is essntially the same. I'm initializing the menus in the form's OnShow event, whereas the JEDI sample does it in the form's OnCreaate.


There's some strange behaviour in Delphi. If I bring up the Speedbar Designer and select the Color buttons, the list that appears in the Events tab is slightly different between the sample form and my frame, even though they should be the same. In the one that works there is a line for DropDownMenu, with the red font for properties that show up on the events tab. That line is absent from the correpsonding place in my frame. That line does show up for the buttons where the DropDownMenu is nil though. Curious.


I'm using Delphi 10.1 Berlin and JCL version 3.50.

JvRichEditToolBar.7z

sample code.png

my frame.png

Edited by PiedSoftware
Adding screen shots

Share this post


Link to post
Guest

hi @PiedSoftware 

 

it would be much more usual for a response if you posted your code for analysis. It is very difficult to imagine so many possibilities that could be occurring, in such an enigmatic case. Also, to avoid possible interpretations, a screenshot would be interesting to understand how you think the result of your code should be. Understood?

 

  • In addition, to know what a procedure should look like, for it to appear correctly in the Object Inspector, event properties, it is simple:
  • You create an event using the standard method, that is, double-click on the object's event, and the IDE will show you how the procedure should be presented in the code.
  • Then, you just have to look at the procedure header, and in this way, you can define your own procedure in the "published" section of the form, or the frame, as appropriate.
type
  TForm1 = class(TForm)
    Edit1: TEdit;
    procedure FormCreate(Sender: TObject);
  private
  public
  published
    procedure prcMyEditChangeProc(Sender: TObject); // <--- this will be my new "OnChange event to my EditXXX"
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Edit1.OnChange := prcMyEditChangeProc;
end;

procedure TForm1.prcMyEditChangeProc(Sender: TObject);
begin
  // your customized code here...
end;

 

hug

Share this post


Link to post

Thanks, emailx45. I have posted an archive as an attachment to the opening post. It is the pas, dfm and dpr / drpoj files. It should be self explanatory.

Of course it may be a bug that is fixed in later versions of Delphi and/or JVCL. 

Update: I have just added a pair of screenshots to show the correct look of the menu from the sample code and the incorrect look from my code.

Edited by PiedSoftware

Share this post


Link to post
Guest

unfortunatelly, I cannot install this suite in my environment... I see that it is from 2005-2015 ... it's very long time not?

try review your code.. maybe some wrong with him.

 

hug

Share this post


Link to post

I have just installed 10.4 Sydney. The problem of the improperly formed colour menus is happening in 10.4 as well.

Share this post


Link to post

You set the ColorMenu.Style to msOwnerDraw but then you don't implement the OnDrawItem and OnMeasureItem. So your menu items have a width of 0px and a height of 16px. And nothing is painted anyway because OnDrawItem is not assign. The "example form" creates its own style painter TJvXPColorMenuItemPainter and assigns it to ColorMenu.ItemPainter.

 

So this is not a bug but a handling error.


 

procedure TEditorMainForm.FormCreate(Sender: TObject);
...
begin
  ...
  ColorMenu.ItemPainter := TJvXPColorMenuItemPainter.Create(Self);
  BackgroundMenu.ItemPainter := TJvXPColorMenuItemPainter.Create(Self);

 

  • Thanks 1

Share this post


Link to post

Ah, thanks! I missed those two lines. I just added the 2 lines you highlighted into the constructor of my frame, and it worked 
 

    ColorMenu.ItemPainter := TJvXPColorMenuItemPainter.Create(Self);
    BackgroundMenu.ItemPainter := TJvXPColorMenuItemPainter.Create(Self);



"You set the ColorMenu.Style to msOwnerDraw but then you don't implement the OnDrawItem and OnMeasureItem."
That was not it.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×