From: BeeJ on
Dee Earley formulated the question :
> On 10/08/2010 23:15, BeeJ wrote:
>> I would like to prevent my ActiveX EXE from starting by double-clicking
>> it in Windows Explorer.
>> Only the main app that instantiates the ActiveX EXE should do this.
>> How do I prevent this?
>> The only crude way I can think of is to start a timer in the Initialize
>> event and if a parameter is not set by the timeout then it is not the
>> main app that is starting it. But there has to be a more sophisticated
>> method.
>
> It will exit immediately unless you do something in the Sub Main.
> If you want to show a message, and exit, do something like:
> If App.StartMode = vbSModeStandalone Then
> MsgBox "This can not be run standalone"
> End If

But there is no sub main.
And the ActiveX EXE is starting.
The entry class has a startup call to a module where a form is opened.

So it looks like even with the parameters set as mentioned in a
previous post, the ActiveX still opens.

Maybe i can try the App.StartMode and see how it is starting and then
not call the startup and just drop thru.


From: Kevin Provance on

"BeeJ" <nospam(a)live.com> wrote in message
news:i3uhh7$g3e$1(a)speranza.aioe.org...
: Dee Earley formulated the question :
:
: But there is no sub main.
: And the ActiveX EXE is starting.
: The entry class has a startup call to a module where a form is opened.
:
: So it looks like even with the parameters set as mentioned in a
: previous post, the ActiveX still opens.
:
: Maybe i can try the App.StartMode and see how it is starting and then
: not call the startup and just drop thru.

Well, that answers it. If there is no Sub Main, VB automatically loads the
default form at startup.

Remedy: Add a module, add Sub Main and use Dee's code, or don't add a thing
if your AX EXE has no stand alone option. If nothing is in sub main, double
clicking the EXE will run through sub main and exit.

Running Dee's code from Form_Load *would* work, but then you run into
problem unloading a form from it's load code, which can be a PITA. Using a
Sub Main is better, and standard.

- Kev

From: BeeJ on
Kevin Provance explained :
> "BeeJ" <nospam(a)live.com> wrote in message
> news:i3uhh7$g3e$1(a)speranza.aioe.org...
>> Dee Earley formulated the question :
>>
>> But there is no sub main.
>> And the ActiveX EXE is starting.
>> The entry class has a startup call to a module where a form is opened.
>>
>> So it looks like even with the parameters set as mentioned in a
>> previous post, the ActiveX still opens.
>>
>> Maybe i can try the App.StartMode and see how it is starting and then
>> not call the startup and just drop thru.
>
> Well, that answers it. If there is no Sub Main, VB automatically loads the
> default form at startup.
>
> Remedy: Add a module, add Sub Main and use Dee's code, or don't add a thing
> if your AX EXE has no stand alone option. If nothing is in sub main, double
> clicking the EXE will run through sub main and exit.
>
> Running Dee's code from Form_Load *would* work, but then you run into
> problem unloading a form from it's load code, which can be a PITA. Using a
> Sub Main is better, and standard.
>
> - Kev

So it seems there are two startup modes for my ActiveX EXE.
And I need to set the start up as Sub Main? even though it is
instantiated by a main app and the main app directly references the
ActiveX.Entry class, the Sub Main may or may not run (assuming it runs,
but if empty will do nothing).


1) instantiated by my main app. Sub Main is a do nothing.
2) stand alone, Sub Main runs and falls through since it is the
startup.

Still a little confused but I am getting there and will try different
scenarios to see what happens.


From: Mayayana on
There's no Sub Main in an ActiveX EXE. It's
Class_Initialize. And you shouldn't be showing
a form there. The EXE is supposed to be providing
functions to the caller. Class_Initialize should only
have necessary setup ops, if anything. Write a
sub or function to show the form. If you need to
prevent it running except by your software you could
write some kind of Init sub:

Private CallValid as Boolean

Private Sub Class_Initialize()
CallValid = False
End Sub

Public Sub Init(iCode as long)
If iCode = 12345 then CallValid = True
End Sub

With that you can just not respond to any
functions if CallValid <> True.


| So it seems there are two startup modes for my ActiveX EXE.
| And I need to set the start up as Sub Main? even though it is
| instantiated by a main app and the main app directly references the
| ActiveX.Entry class, the Sub Main may or may not run (assuming it runs,
| but if empty will do nothing).
|
|
| 1) instantiated by my main app. Sub Main is a do nothing.
| 2) stand alone, Sub Main runs and falls through since it is the
| startup.
|
| Still a little confused but I am getting there and will try different
| scenarios to see what happens.
|
|


From: Tom Shelton on
Mayayana explained :
> There's no Sub Main in an ActiveX EXE.

There sure can be... Do you actually know vb6?

> It's
> Class_Initialize. And you shouldn't be showing
> a form there. The EXE is supposed to be providing
> functions to the caller.

That is one of an activex exe's primary functions, yes - but creating
an activex exe as a client app is the classic way to get threading
behavior in VB6... Again? Do you actually know this language?

<snip>

--
Tom Shelton