Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem running ActiveX control created with VB6 in Delphi 5

Status
Not open for further replies.

nzman

IS-IT--Management
Aug 24, 2002
2
NZ
Hi,

My problem is the following:

I create a very basic ActiveX control in Visual Basic 6 using the ActiveX control wizard. It has one method that simply displayes a message box. When I compile this to an .OCX file, it works correctly in Visual C++ or other Visual Basic projects. I can also use TSTCON32.EXE (AxtiveX test container) to test it and it works fine.

When I try to Import it into a Delphi 5 project it is also listed correctly as a registered control and I can add it to my Delphi project. The control is then placed on a new Form together with a simple command button. It the Command button's Click event I simply call the VB control's method and expect to see the message box pop up...

When the program is run, the following error message is displayed:

"Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address66080E3B in module MSVBVM60.DLL. Read of address FFFFFFFF. Process stopped..."

This happens for any method call that I make to any control that I create with VB6.

I am sure that a simple control like this has to work in Delphi and that I am doing something stupid or am overlooking something...

Any help from the Delphi experts out there will be much appreciated!

Thanks!

NZMan

Here is my Delphi code. The VB test control is called SayWow.

*******************************************
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, OleCtrls, PRJSayWow_TLB;

type
TForm1 = class(TForm)
SayWow1: TSayWow;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
SayWow1.SayWow();
end;

end.
**************************************





 
I found an answer to my problem! Kim Little supplied me with the solution!

It has to do with the way that Delphi imports the VB control. It creates both a standard and a IDispatch interface. By default the Standard interface is selected.

If you modify the Type library file to use the IDispatch interface, the exception errors disappear and the control behaves the way it should!

Thanks Kim!

NZMan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top