Board index » delphi » Q: Capturing the user selected text in DBGrid to clipboard

Q: Capturing the user selected text in DBGrid to clipboard

 I need to get the user selected text in a DBGrid for Cut, Copy, Paste to the
clipboard. Some components have this capability, some don't. Any help would be
greatly appreciated. Thanks.

MJN...@ix.netcon.com

 

Re:Q: Capturing the user selected text in DBGrid to clipboard


MJ(???),
        Try typecasting the component as an ancestor component;
ie:  (Component1 as TComponentAncestor).Method;
I have done this several times before without any problems.

                        Happy pgming   - John

Quote
MJN...@ix.netcom.com wrote:

>  I need to get the user selected text in a DBGrid for Cut, Copy, Paste to the
> clipboard. Some components have this capability, some don't. Any help would be
> greatly appreciated. Thanks.

> MJN...@ix.netcon.com

Re:Q: Capturing the user selected text in DBGrid to clipboard


Quote
John Sklavounos wrote:

> MJ(???),
>         Try typecasting the component as an ancestor component;
> ie:  (Component1 as TComponentAncestor).Method;
> I have done this several times before without any problems.

Why would you need to do this?  Since in Delphi you can't hide any of the ancestors
public or published methods and properties, anything declared there should be available
in any descendent component.

--
Darren Clark
dar...@dgp.com
Delta Golf Productions

Re:Q: Capturing the user selected text in DBGrid to clipboard


Darren,
        Sometimes I talk out my ass and my breath stinks...  I realized
after reading your statement that I was doing this only because some
methods aren't documented properly - making me think that they don't
exist.  Oh well...
                                        - John

Quote
Darren Clark wrote:

> John Sklavounos wrote:

> > MJ(???),
> >         Try typecasting the component as an ancestor component;
> > ie:  (Component1 as TComponentAncestor).Method;
> > I have done this several times before without any problems.

> Why would you need to do this?  Since in Delphi you can't hide any of the ancestors
> public or published methods and properties, anything declared there should be available
> in any descendent component.

> --
> Darren Clark
> dar...@dgp.com
> Delta Golf Productions

Re:Q: Capturing the user selected text in DBGrid to clipboard


Quote
John Sklavounos wrote:

> Darren,
>         Sometimes I talk out my ass and my breath stinks...  I realized
> after reading your statement that I was doing this only because some
> methods aren't documented properly - making me think that they don't
> exist.  Oh well...
>                                         - John

> Darren Clark wrote:

> > John Sklavounos wrote:

> > > MJ(???),
> > >         Try typecasting the component as an ancestor component;
> > > ie:  (Component1 as TComponentAncestor).Method;
> > > I have done this several times before without any problems.

> > Why would you need to do this?  Since in Delphi you can't hide any of the ancestors
> > public or published methods and properties, anything declared there should be available
> > in any descendent component.

> > --
> > Darren Clark
> > dar...@dgp.com
> > Delta Golf Productions

There is in fact a valid reason for doing this in cases where a virtual method is hiding it's
ancestors implementation of the same method, type casting to the ancestor will allow you to call
the method from the ancestors VMT. ie conceivably Fred.method and TFredsDad(fred).method could
call different virtual methods.

Regards Tim Jarvis.

Re:Q: Capturing the user selected text in DBGrid to clipboard


Quote
Tim Jarvis wrote:

> There is in fact a valid reason for doing this in cases where a virtual method is hiding it's
> ancestors implementation of the same method, type casting to the ancestor will allow you to call
> the method from the ancestors VMT. ie conceivably Fred.method and TFredsDad(fred).method could
> call different virtual methods.

Oooh, neato.  I was actually trying to figure out how to do this earlier today.  Now I can take a
whole bunch of code out of the component I was writing.

Thanks for the info!
--
Darren Clark
dar...@dgp.com
Delta Golf Productions

Other Threads