OLE:How to determine if AutoCad is already active 
Author Message
 OLE:How to determine if AutoCad is already active

Hi.

On a form I have a button that opens a drawing in AutoCad2000. Everything
works fine but if AutoCad is already started manually, a new instance of
AutoCad is loaded with the ?OLE{Prop:Create} statement. Is there a way to
determine is AutoCad is already loaded?
Something like:  ?Ole1{PROP:GetObject} = 'AutoCad.Application' that can be
run as a check, before I run the: ?Ole1{PROP:Create} =
'AutoCad.Application'.

regards,
Bj?rn Holm
Nordak as
Norway



Mon, 14 Jul 2003 22:21:58 GMT  
 OLE:How to determine if AutoCad is already active
If Autocad is a DDEserver you could use DDEquery to returns currently
executing DDE servers and then check for Autocad in the returnstring.


Quote:
> Hi.

> On a form I have a button that opens a drawing in AutoCad2000. Everything
> works fine but if AutoCad is already started manually, a new instance of
> AutoCad is loaded with the ?OLE{Prop:Create} statement. Is there a way to
> determine is AutoCad is already loaded?
> Something like:  ?Ole1{PROP:GetObject} = 'AutoCad.Application' that can be
> run as a check, before I run the: ?Ole1{PROP:Create} =
> 'AutoCad.Application'.

> regards,
> Bj?rn Holm
> Nordak as
> Norway




Tue, 15 Jul 2003 17:28:56 GMT  
 OLE:How to determine if AutoCad is already active
Hei Bjarne!
This will only tell me if AutoCad is running, that I know how to do.
What I need is a function that makes the already started AutoCad give
me a pointer to it's OLE object.(The same pointer that is being returned
when I do a ?OLE{Prop:Create}='AutoCad.Application')

regards,
Bj?rn Holm
Nordak as
Norway


Quote:
> If Autocad is a DDEserver you could use DDEquery to returns currently
> executing DDE servers and then check for Autocad in the returnstring.



> > Hi.

> > On a form I have a button that opens a drawing in AutoCad2000.
Everything
> > works fine but if AutoCad is already started manually, a new instance of
> > AutoCad is loaded with the ?OLE{Prop:Create} statement. Is there a way
to
> > determine is AutoCad is already loaded?
> > Something like:  ?Ole1{PROP:GetObject} = 'AutoCad.Application' that can
be
> > run as a check, before I run the: ?Ole1{PROP:Create} =
> > 'AutoCad.Application'.

> > regards,
> > Bj?rn Holm
> > Nordak as
> > Norway




Tue, 15 Jul 2003 19:42:00 GMT  
 OLE:How to determine if AutoCad is already active
Bjorn,

     I'm by no means an OLE expert, but I don't think what you're wanting to
do is possible. Jim Kane can correct me if I'm wrong.

     I tried a little experiment. I started a program that I use regularly
as an OLE control in my programs. I added some code to find the application
if it was active. I took that handle and used it as ?OLE{Prop:Create} =
whandle . I did this for lack of a better way to tell the OLE control to use
this instance. I was able to use API calls to manipulate the application,
Minimize, bring to front, etc... But I wasn't able to pass methods to ?OLE.
I believe you'll just have to deal with the annoying second window, or close
the first window with an API call when your application takes over.

Again, Jim jump in at any time <g>

Marty


Quote:
> Hei Bjarne!
> This will only tell me if AutoCad is running, that I know how to do.
> What I need is a function that makes the already started AutoCad give
> me a pointer to it's OLE object.(The same pointer that is being returned
> when I do a ?OLE{Prop:Create}='AutoCad.Application')

> regards,
> Bj?rn Holm
> Nordak as
> Norway



> > If Autocad is a DDEserver you could use DDEquery to returns currently
> > executing DDE servers and then check for Autocad in the returnstring.



> > > Hi.

> > > On a form I have a button that opens a drawing in AutoCad2000.
> Everything
> > > works fine but if AutoCad is already started manually, a new instance
of
> > > AutoCad is loaded with the ?OLE{Prop:Create} statement. Is there a way
> to
> > > determine is AutoCad is already loaded?
> > > Something like:  ?Ole1{PROP:GetObject} = 'AutoCad.Application' that
can
> be
> > > run as a check, before I run the: ?Ole1{PROP:Create} =
> > > 'AutoCad.Application'.

> > > regards,
> > > Bj?rn Holm
> > > Nordak as
> > > Norway




Tue, 15 Jul 2003 23:02:35 GMT  
 OLE:How to determine if AutoCad is already active
Hi Marty.
This is what I want to do(this code is from VB):

    Set oApp = GetObject(, "Word.Application")
    If Err.Number <> 0 Then
    Set oApp = CreateObject("Word.Application")
    End If

regards,
Bj?rn Holm
Nordak as
Norway


Quote:
> Bjorn,

>      I'm by no means an OLE expert, but I don't think what you're wanting
to
> do is possible. Jim Kane can correct me if I'm wrong.

>      I tried a little experiment. I started a program that I use regularly
> as an OLE control in my programs. I added some code to find the
application
> if it was active. I took that handle and used it as ?OLE{Prop:Create} =
> whandle . I did this for lack of a better way to tell the OLE control to
use
> this instance. I was able to use API calls to manipulate the application,
> Minimize, bring to front, etc... But I wasn't able to pass methods to
?OLE.
> I believe you'll just have to deal with the annoying second window, or
close
> the first window with an API call when your application takes over.

> Again, Jim jump in at any time <g>

> Marty



> > Hei Bjarne!
> > This will only tell me if AutoCad is running, that I know how to do.
> > What I need is a function that makes the already started AutoCad give
> > me a pointer to it's OLE object.(The same pointer that is being returned
> > when I do a ?OLE{Prop:Create}='AutoCad.Application')

> > regards,
> > Bj?rn Holm
> > Nordak as
> > Norway



> > > If Autocad is a DDEserver you could use DDEquery to returns currently
> > > executing DDE servers and then check for Autocad in the returnstring.



> > > > Hi.

> > > > On a form I have a button that opens a drawing in AutoCad2000.
> > Everything
> > > > works fine but if AutoCad is already started manually, a new
instance
> of
> > > > AutoCad is loaded with the ?OLE{Prop:Create} statement. Is there a
way
> > to
> > > > determine is AutoCad is already loaded?
> > > > Something like:  ?Ole1{PROP:GetObject} = 'AutoCad.Application' that
> can
> > be
> > > > run as a check, before I run the: ?Ole1{PROP:Create} =
> > > > 'AutoCad.Application'.

> > > > regards,
> > > > Bj?rn Holm
> > > > Nordak as
> > > > Norway




Tue, 15 Jul 2003 22:28:39 GMT  
 OLE:How to determine if AutoCad is already active
I understand that Bjorn,

It's the GetObject that you'll have problems with. You can find out if there
is an instance of the OLE control running in your application. You can find
out if the application is running outside your application. But I don't know
how you will take control of an already running instance outside of your
application. If you have this figured out already, you can do as Jim Kane
pointed out to find the instance outside of yours. Or you can use API calls
(findwindow comes to mind). But how do you plan to take control of an
already running instance of the application?

Marty


Quote:
> Hi Marty.
> This is what I want to do(this code is from VB):

>     Set oApp = GetObject(, "Word.Application")
>     If Err.Number <> 0 Then
>     Set oApp = CreateObject("Word.Application")
>     End If

> regards,
> Bj?rn Holm
> Nordak as
> Norway



> > Bjorn,

> >      I'm by no means an OLE expert, but I don't think what you're
wanting
> to
> > do is possible. Jim Kane can correct me if I'm wrong.

> >      I tried a little experiment. I started a program that I use
regularly
> > as an OLE control in my programs. I added some code to find the
> application
> > if it was active. I took that handle and used it as ?OLE{Prop:Create} =
> > whandle . I did this for lack of a better way to tell the OLE control to
> use
> > this instance. I was able to use API calls to manipulate the
application,
> > Minimize, bring to front, etc... But I wasn't able to pass methods to
> ?OLE.
> > I believe you'll just have to deal with the annoying second window, or
> close
> > the first window with an API call when your application takes over.

> > Again, Jim jump in at any time <g>

> > Marty



> > > Hei Bjarne!
> > > This will only tell me if AutoCad is running, that I know how to do.
> > > What I need is a function that makes the already started AutoCad give
> > > me a pointer to it's OLE object.(The same pointer that is being
returned
> > > when I do a ?OLE{Prop:Create}='AutoCad.Application')

> > > regards,
> > > Bj?rn Holm
> > > Nordak as
> > > Norway



> > > > If Autocad is a DDEserver you could use DDEquery to returns
currently
> > > > executing DDE servers and then check for Autocad in the
returnstring.



> > > > > Hi.

> > > > > On a form I have a button that opens a drawing in AutoCad2000.
> > > Everything
> > > > > works fine but if AutoCad is already started manually, a new
> instance
> > of
> > > > > AutoCad is loaded with the ?OLE{Prop:Create} statement. Is there a
> way
> > > to
> > > > > determine is AutoCad is already loaded?
> > > > > Something like:  ?Ole1{PROP:GetObject} = 'AutoCad.Application'
that
> > can
> > > be
> > > > > run as a check, before I run the: ?Ole1{PROP:Create} =
> > > > > 'AutoCad.Application'.

> > > > > regards,
> > > > > Bj?rn Holm
> > > > > Nordak as
> > > > > Norway




Wed, 16 Jul 2003 01:41:04 GMT  
 OLE:How to determine if AutoCad is already active
Bj?rn,

I do not know the answer but

Quote:
>if AutoCad is already started manually, a new instance of AutoCad is loaded

Isn't this desired? Suppose the user has opened AutoCAD and
starts editing a drawing. Then he wants to see an example and
clicks on the button in your program to call the other drawing.
What, if you succeed in taking over the current instance of
AutoCAD, will happen to the user's drawing, he's currently editing ?

--
Best regards,
Maarten
CDD3.1, C5EEb - ABC & C5.5EEgold
Certainly Clarion Developer



Wed, 16 Jul 2003 03:26:52 GMT  
 OLE:How to determine if AutoCad is already active
Hi Maarten!

Quote:
> What, if you succeed in taking over the current instance of
> AutoCAD, will happen to the user's drawing, he's currently editing ?

Nothing will happen. As this is in AutoCad2000, a new drawing is opened
and you now has two drawings opened in AutoCad. : )

regards,
Bj?rn Holm
Nordak as
Norway



Wed, 16 Jul 2003 06:01:11 GMT  
 OLE:How to determine if AutoCad is already active
Hi,

Quote:
> On a form I have a button that opens a drawing in AutoCad2000. Everything
> works fine but if AutoCad is already started manually, a new instance of
> AutoCad is loaded with the ?OLE{Prop:Create} statement. Is there a way to
> determine is AutoCad is already loaded?
> Something like:  ?Ole1{PROP:GetObject} = 'AutoCad.Application' that can be
> run as a check, before I run the: ?Ole1{PROP:Create} =
> 'AutoCad.Application'.

This is a snippit from my COM classes but the important thing here is the
call to GetActiveObject which is an API function. This is what you need to
call. It returns an interface ptr.

CvOutlookApp.CreateInstance procedure(bool bDisplay)

hr      HRESULT
pUnk    long

  code
    hr = GetActiveObject(address(__IOutlookApplication), 0, pUnk)
    if (hr = S_OK)
      hr = self.Attach(pUnk)
    else
      hr = self.CreateInstance(address(__IOutlookApplication),
address(_IOutlookApplication))
      if (hr ~= S_OK)
        assert(0, 'Failed to Create Instance of Outlook.Application')
      else
        if (bDisplay)
          hr  = self.Display(self.nFolder).
      end
    end
    return hr

HTH

Regards

Andy Ireland.



Wed, 16 Jul 2003 10:41:21 GMT  
 OLE:How to determine if AutoCad is already active
Andy,

     The part I was saying may not be possible with the standard interface
is the part not shown here <g> How is he supposed to "self.attach" with the
standard OLE interface? Or maybe I'm being dense and overlooking something.
That's always possible, wouldn't be the first time, not even the first time
today <g>

Marty


Quote:
> Hi,

> > On a form I have a button that opens a drawing in AutoCad2000.
Everything
> > works fine but if AutoCad is already started manually, a new instance of
> > AutoCad is loaded with the ?OLE{Prop:Create} statement. Is there a way
to
> > determine is AutoCad is already loaded?
> > Something like:  ?Ole1{PROP:GetObject} = 'AutoCad.Application' that can
be
> > run as a check, before I run the: ?Ole1{PROP:Create} =
> > 'AutoCad.Application'.

> This is a snippit from my COM classes but the important thing here is the
> call to GetActiveObject which is an API function. This is what you need to
> call. It returns an interface ptr.

> CvOutlookApp.CreateInstance procedure(bool bDisplay)

> hr      HRESULT
> pUnk    long

>   code
>     hr = GetActiveObject(address(__IOutlookApplication), 0, pUnk)
>     if (hr = S_OK)
>       hr = self.Attach(pUnk)
>     else
>       hr = self.CreateInstance(address(__IOutlookApplication),
> address(_IOutlookApplication))
>       if (hr ~= S_OK)
>         assert(0, 'Failed to Create Instance of Outlook.Application')
>       else
>         if (bDisplay)
>           hr  = self.Display(self.nFolder).
>       end
>     end
>     return hr

> HTH

> Regards

> Andy Ireland.



Wed, 16 Jul 2003 13:16:01 GMT  
 OLE:How to determine if AutoCad is already active
Hi Marty,

I only answered the question which was 'how to get the interface'<g>. I
don't know clarions COM that well so I figured answering one bit was better
than answering none! I'm sure there is a way of attaching to a clarion OLE
interface but I don't know how to do it and nor do I have the time to look
into it unfortunately. So you're not being dense<g>! My guess would be to
look at the Asm and see what the wrapper is doing and poke the pIUnk into it
but that assumes clarion does all of the initialisation before hand. Sorry I
can't be of more help.

Regards

Andy.

Quote:
>      The part I was saying may not be possible with the standard interface
> is the part not shown here <g> How is he supposed to "self.attach" with
the
> standard OLE interface? Or maybe I'm being dense and overlooking
something.
> That's always possible, wouldn't be the first time, not even the first
time
> today <g>



Sat, 19 Jul 2003 02:23:48 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. OLE and AutoCAD R14

2. LOGOUT Already Active (56) - why ?

3. LOGOUT Already Active (56)

4. Determining whether a process is active?

5. Determine active EIP-field

6. OLE document active?

7. determine a excel file exists or not by active x

8. Determining active Screen

9. determine active widget

10. I am having problems setting the page break through Active X

11. C-level routine to determine what procedure I am in

12. Am I missing some patches on C4 OLE ?

 

 
Powered by phpBB® Forum Software