Automation controller Variant problem
- From: "Paul" <pstech@xxxxxxxxx>
- Date: 30 Jun 2006 13:34:55 -0700
I am now learning how to set up an automation controller in Delphi. I
would like to be able to connect, perform some operations, and
disconnect.
I declared the Variant here (it also worked with the commented type)
private
MyPADS: Variant; //IPowerPCBApp;
On FormCreate, I initialize it:
MyPADS := Unassigned;
This is probably not necessary, as it seems to be that by default.
My problem occurs here (Connect):
procedure TForm1.BtnConnectClick(Sender: TObject);
begin
if( VarType(MyPADS) = Unassigned ) then begin
Try
MyPADS:= CoApplication_.Create;
except
Application.MessageBox('Cannot connect', 'Ole server', MB_OK );
exit;
end;
powerPCBApp := MyPADS.Application_; // Connect to a running instance
of PowerPCB server
powerPCBDoc := MyPADS.ActiveDocument;
Edit1.text := powerPCBDoc;
end
end;
MyPADS is Unassigned at the start of the If statement. When it
executes, I get an Invalid Variant Operation, and MyPADS becomes a
Variant Array of Unknown. If I omit the VarType(), it also fails, and
MyPADS becomes Unknown.
If I remove the if statement, I get an error that Application is not
supported. If I change the declaration of MyPADS to IPowerPCBApp, then
everything works. However, I do not know how to implement the
Disconnect, as MyPADS cannot be set to Unassigned (which works for the
Variant). I also tried NULL and that didn't work.
A final problem is that the application has a timed backup function
that pops a modal dialog waiting for user input, and the commands from
the automation controller cannot be processed. Is there a way to detect
and handle that?
Sorry for the many questions. I want to be sure I have the basics OK
before I expand this and do more extensive processing.
Thanks,
Paul E. Schoen
www.pstech-inc.com
(posting from Google because my news server Coretel is not reliable -
sorry if duplicated)
.
- Follow-Ups:
- Re: Automation controller Variant problem
- From: Bjørge
- Re: Automation controller Variant problem
- Prev by Date: Re: Call to a DLL
- Next by Date: Re: Automation controller Variant problem
- Previous by thread: Call to a DLL
- Next by thread: Re: Automation controller Variant problem
- Index(es):