Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1014
  • Last Modified:

Using the TSpeedItem on TSpeedBar in the RX library

Hi,
The title says everything.
My problem is that in the onClick event when I try following
(sender as tspeeditem).caption I get a class cast error.
When I look at run time at the sender.class I can see it's
class is TSpeedButton (or something like that).
The problem is that TSpeedButton is an unknown type
so I cannot use (sender as tspeedButton).caption
Just Try what I sayd and you will understand.
My goal is to do following

if (sender as tspeeditem).caption = 'test' then
begin
...
end
else
begin
...
end

What do you thing ?
I'm using RX library 2.32.
Jeurk
0
jeurk
Asked:
jeurk
  • 3
  • 2
1 Solution
 
ZifNabCommented:
Hi jeurk,

You can do it this way :

 if (Sender as TRXSpeedButton).Caption = 'test' then begin
 end
  else begin
  end;

Don't forget to add RXCtrls to the uses clausule!

Regards, Zif.
0
 
jeurkAuthor Commented:
Hello, thanks for the answer but I need to know something more.
I agree that what you say works.
The solution is done by adding rxctrls.
what I don't understand is that tspeedbarbutton is declared in
speedbar.pas so I tryed to include speedbar in de uses clausule.
At compilation it still says that it does not know tspeedbarbutton. After adding rxctrls it no longer complains.
I hope you'll understand what I mean ?
0
 
ZifNabCommented:
I don't know exactly, haven't looked at the code, but if you see, in my code I use TRXSpeedButton and not TSpeedBarButton. TSpeedBarButton is a descendant of TRXSpeedButton.


0
 
jeurkAuthor Commented:
I tryed the thing and it did not work, actually. the caption property is not connected to the (Sender as TRXSpeedButton).Caption
I had to use the btnCaption for my prog to work.
Thanks for your help.

0
 
ZifNabCommented:
Strange, I'd tested it myself on my computer and it did work exactly like I wrote here. Maybe it's a different version from yours and Delphi version too. Regards, Zif.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now