trichview.com

trichview.support




Re: Finding which button was selected


Return to index


Author

Message

Arthur Dales

Posted: 02/27/2004 22:19:15


Henry,


Thanks. I will probably try this out (and need to someday!).


For the moment, Sergey's post (same as the last suggestion in your post)

works just the way I need. I just knew there was a simple way to do this

that I was missing.


- Arthur.


"shmp" <[email protected]> wrote in message news:[email protected]...

> > Hi,

> >

> > How do I find out which button was selected when I have more than one

> button

> > component inserted into a richview document?

> >

> > Setting the 'tag' when creating the button does not seem to work

(checking

> > the 'Sender' tag property in the click event returns unpredictable

> results),

> > and I am having no luck with getting 'GetFocusedItem' to provide any

> better

> > information (in fact, I am getting access violations, so I figure I am

> just

> > using it incorrectly).

>

> DO NOT USE the TButton.Tag, instead you should use the RichView

> control tag.

> e.g.

> if RichView1.GetItemStyle(ItemNo) = rvsComponent then begin

>   RichView1.GetControlInfo(ItemNo, Name, Ctrl, Align, Tag);

>   if Tag = ........ then

> end;

>

> or you can use 'name' of the control.

>

> You have to think of a way to get the ItemNo.

>

> Setting the control would be

>  RichView1.AddControlExTag('', MyButton, -1, Align, CountButton);

> where countButton is the tag.

>

> > I am trying to centralize my 'button click' code to one procedure (set

> with

> > the 'OnClick' property of the button when I create them), and then

branch

> to

> > the required code based on the state of the program. This has been

working

> > fine while I had just one button on any richview page - but is failing

> > miserably when I have to have more than one button.

>

> You can use OnControlAction.

>

> If you can add a property of either text or integer in the button

component

> then

> it would be convenient to centralize.

>

> The OnClick procedure would have something like this:

>

>     Test := TButton(TControl(Sender)).YourAddedProperty;

>

> The 'Test' could contain the ID you wanted.

>

> Good luck.

>

> Henry.





Powered by ABC Amber Outlook Express Converter