Home All Groups Group Topic Archive Search About

can't get form to start up when activeX exe starts

Author
31 Jan 2006 7:45 PM
BLACKDOG157
I coded an activeX EXE using Visual Basic 6.  (Yes, I'm still in the
stone age).  Anyway, I wanted a form to appear when the EXE starts.  So
I added a module, put a "Sub Main" in the module, and set the project
properties to start Sub Main when the EXE starts.
The Sub looks like this:
Sub Main()
    FrmMain.Show
End Sub
When I look at the project properties, 'startup object' is "Sub Main",
which is what I want.
The only problem is, the form does not show.  I tried 'debug.print'
from Sub Main, and that doesn't work either.  I tried a MsgBox from Sub
Main, and that did not work either.  So it looks as if Sub Main is not
called at all.
When you create an activeX exe, a class file is created.  I tried
modifying the Initialize event of that class to show the form.  But
that didn't work either.

Any help is much appreciated.

Author
31 Jan 2006 7:55 PM
Ken Halter
<BLACKDOG***@LYCOS.COM> wrote in message
news:1138736730.388180.260520@g49g2000cwa.googlegroups.com...
>I coded an activeX EXE using Visual Basic 6.  (Yes, I'm still in the
> stone age).  Anyway, I wanted a form to appear when the EXE starts.  So
> I added a module, put a "Sub Main" in the module, and set the project
> properties to start Sub Main when the EXE starts.
> The Sub looks like this:
> Sub Main()
>    FrmMain.Show
> End Sub

While you may be able to get that to work by opening the 'Project
Properties' dialog, clicking on the 'Component' tab and setting the 'Start
Mode' to 'Standalone', it seems like you're defeating the purpose of an
ActiveX EXE (can't really tell without more info). There should be a class
in that EXE that gets instantiated. Once that takes place, there should be a
method in that class that shows the form(s).

Also, in that Sub Main, you can check the startmode property and be able to
tell whether it was started by automation or by (basically) double-clicking
directly on the file to launch it.

If App.StartMode = vbSModeStandalone Then
   Show your Form
Else
   Do Nothing because some other app's creating instances of this apps
classes
End If



--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm
Author
1 Feb 2006 3:11 PM
BLACKDOG157
Hello Ken,
You say that setting the Start Mode to "Standalone" defeats the purpose
of an ActiveX EXE.  Why is that?
Thanks.
Author
31 Jan 2006 8:06 PM
mayayana
I just tried the Intialize event and it worked fine.

Private Sub Class_Initialize()
  Load F1
  F1.Show 0
End Sub

  The project Project1 has a class Class1 and
a form named F1. When I created the object
Project1.Class1 the form appeared.

--
mayayanaX***@mindXXspring.com
(Remove Xs for return email.)
<BLACKDOG***@LYCOS.COM> wrote in message
Show quoteHide quote
news:1138736730.388180.260520@g49g2000cwa.googlegroups.com...
> I coded an activeX EXE using Visual Basic 6.  (Yes, I'm still in the
> stone age).  Anyway, I wanted a form to appear when the EXE starts.  So
> I added a module, put a "Sub Main" in the module, and set the project
> properties to start Sub Main when the EXE starts.
> The Sub looks like this:
> Sub Main()
>     FrmMain.Show
> End Sub
> When I look at the project properties, 'startup object' is "Sub Main",
> which is what I want.
> The only problem is, the form does not show.  I tried 'debug.print'
> from Sub Main, and that doesn't work either.  I tried a MsgBox from Sub
> Main, and that did not work either.  So it looks as if Sub Main is not
> called at all.
> When you create an activeX exe, a class file is created.  I tried
> modifying the Initialize event of that class to show the form.  But
> that didn't work either.
>
> Any help is much appreciated.
>
Author
1 Feb 2006 11:24 AM
J French
On 31 Jan 2006 11:45:30 -0800, BLACKDOG***@LYCOS.COM wrote:

Show quoteHide quote
>I coded an activeX EXE using Visual Basic 6.  (Yes, I'm still in the
>stone age).  Anyway, I wanted a form to appear when the EXE starts.  So
>I added a module, put a "Sub Main" in the module, and set the project
>properties to start Sub Main when the EXE starts.
>The Sub looks like this:
>Sub Main()
>    FrmMain.Show
>End Sub
>When I look at the project properties, 'startup object' is "Sub Main",
>which is what I want.
>The only problem is, the form does not show.  I tried 'debug.print'
>from Sub Main, and that doesn't work either.  I tried a MsgBox from Sub
>Main, and that did not work either.  So it looks as if Sub Main is not
>called at all.
>When you create an activeX exe, a class file is created.  I tried
>modifying the Initialize event of that class to show the form.  But
>that didn't work either.

Just a hunch, but it sounds as if you have two versions of the AX EXE,
and you are modifying one and your main App is invoking another older
version.

It's worth checking ...