Subject RE: [IBO] Need help with Interfaces and Delphi 3
Author Norman Dunbar
Jason,

found this on Google - looks like D3 is broken but D4 is fixed.

regards,
Norman.

----------------------------------------------------------------------------
-
Norman Dunbar EMail: Norman.Dunbar@...
Database/Unix administrator Phone: 0113 289 6265
Fax: 0113 289 3146
Lynx Financial Systems Ltd. URL: http://www.Lynx-FS.com
----------------------------------------------------------------------------
-

All messages from thread
Message 1 in thread
From: Harry Bosma (hbosma@...)
Subject: GetInterface: Should this sample work?
Newsgroups: borland.public.delphi.objectpascal
View this article only
Date: 1999/04/12


I'm trying to find out what can be done with interfaces. The code
below has an interface IHelloWorld which is used with a THelloBtn.

The actual implementation of IHelloWorld is in the button (which is
the thing I'm looking for: interface and implementation are completely
separated, yet I can easily merge the interface with other
components). Why does this code crash?

Regards,

Harry



unit Btns;

interface

uses
Buttons, Dialogs;

type
IHelloWorld = interface
['{61C3A3A1-F0F9-11D2-A685-0020182DFB83}']
procedure SayHello;
end;

THelloBtn = class(TSpeedButton, IHelloWorld)
protected
procedure SayHello;
public
procedure Click; override;
end;

const
IID_HelloWorld: TGUID = '{61C3A3A1-F0F9-11D2-A685-0020182DFB83}';

implementation

procedure THelloBtn.SayHello;
begin
ShowMessage('Hello world');
end;

procedure THelloBtn.Click;
var
HelloWorld: IHelloWorld;
begin
if Self.GetInterface(IID_HelloWorld, HelloWorld) then
HelloWorld.SayHello;
end;

end.


Message 2 in thread
From: TeamB (Stefan.Hoffmeister@..._(Stefan_Hoffmeister)
Subject: Re: GetInterface: Should this sample work?
Newsgroups: borland.public.delphi.objectpascal
View this article only
Date: 1999/04/12


: hbosma@... (Harry Bosma) wrote:
>Why does this code crash?

It does not crash for me if I use it as in:

with THelloBtn.Create(Self) do
begin
Parent := Self;
end;

and then click that button.

--
Stefan Hoffmeister (TeamB) http://www.econos.de/
Please do apply judgement when sending email.


Message 3 in thread
From: Harry Bosma (hbosma@...)
Subject: Re: GetInterface: Should this sample work?
Newsgroups: borland.public.delphi.objectpascal
View this article only
Date: 1999/04/12


On Mon, 12 Apr 1999 16:35:03 GMT, Stefan.Hoffmeister@... (Stefan
Hoffmeister (TeamB)) wrote:

Stefan, thanks for checking my code.

>It does not crash for me if I use it as in:
>
> with THelloBtn.Create(Self) do
> begin
> Parent := Self;
> end;
>
>and then click that button.

I copied your code (basically the same as what I used) to the
FormCreate event. But I still get an exception complaining about "read
of address FFFFFFFF". I'm using Delphi 3, but I doubt that explains
it. I use default compiler settings. Not that it should matter but I'm
running Window 95 OSR 2 and IE 5.

??

I also tried your code from within a TButton event on the form. No
difference.

Harry


Message 4 in thread
From: David Baer (dbaer@...)
Subject: Re: GetInterface: Should this sample work?
Newsgroups: borland.public.delphi.objectpascal
View this article only
Date: 1999/04/12


Harry,

>I'm using Delphi 3, but I doubt that explains it.

Actually, it *does*. In D3, nasty things would happen in
TComponent.QueryInterface where QueryInterface was not overridden.
The code (i.e., TComponent.QueryInterface) was modified in D4 so that
that sort of thing no longer seems to happen.

Regards,
D.B.


Message 5 in thread
From: Harry Bosma (hbosma@...)
Subject: Re: GetInterface: Should this sample work?
Newsgroups: borland.public.delphi.objectpascal
View this article only
Date: 1999/04/14


On Mon, 12 Apr 1999 23:52:57 GMT, dbaer@... (David
Baer) wrote:

>Actually, it *does*. In D3, nasty things would happen in
>TComponent.QueryInterface where QueryInterface was
>not overridden. The code (i.e., TComponent.QueryInterface)
>was modified in D4 so that that sort of thing no longer
>seems to happen.

Thanks, this pointed me in the right direction.

I couldn't log in to the newsserver for a day but I had seen your
message on Dejanews. I also found plenty of message on this same topic
about a year ago, though none of them seemed to have the solution I
was looking for.

I added my D3 solution below for others. It replaces the GetInterface
and _Release implementations.

Regards,

Harry



unit Btns;

interface

uses
Buttons, Dialogs;

type
IHelloWorld = interface
['{61C3A3A1-F0F9-11D2-A685-0020182DFB83}']
procedure SayHello;
end;

THelloBtn = class(TSpeedButton, IHelloWorld)
protected
function GetInterface(const IID: TGUID; out Obj): Boolean;
function _Release: Integer; stdcall;
procedure SayHello;
public
procedure Click; override;
end;

implementation
Read the rest of this message... (38 more lines)





C2001 Google

-------------------------------------
Norman Dunbar
Database/Unix administrator
Lynx Financial Systems Ltd.
mailto:Norman.Dunbar@...
Tel: 0113 289 6265
Fax: 0113 289 3146
URL: http://www.Lynx-FS.com
-------------------------------------


-----Original Message-----
From: Jason Wharton [mailto:jwharton@...]
Sent: Tuesday, November 27, 2001 9:35 AM
To: IBObjects@yahoogroups.com
Subject: [IBO] Need help with Interfaces and Delphi 3
Importance: High


I am getting an AV on address 000000000 when calling GetInterface()
function.

Does anyone know if Delphi 3 actually had interfaces working? The exact same
code works with Delphi 5 and up. Haven't checked Delphi 4 yet. I presume it
works because the code has been there this was a while now without it
breaking for anyone.

I've got someone in a tight spot and I need this resolved ASAP. Any help
would be appreciated.
At this point I am just about to IFDEF out the interfaces for IB_Grid in
Delphi 3.

PS. I will soon be dropping Delphi 3 anyway.

Thanks,
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com





___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

This email is intended only for the use of the addressees named above and
may be confidential or legally privileged. If you are not an addressee you
must not read it and must not use any information contained in it, nor copy
it, nor inform any person other than Lynx Financial Systems or the
addressees of its existence or contents. If you have received this email
and are not a named addressee, please delete it and notify the Lynx
Financial Systems IT Department on 0113 2892990.