Your code looks good. The only thing I can suggest is that you test
that the line:
hInstance = GetModuleHandle(App.EXEName)
gives you a valid module handle, that is, test that hInstance <> 0
before using it to register your app with ctl3d. Also, I've looked at
an old project of mine and the way I got my module handle was:
hMod = GetModuleHandle(app.exename & ".exe")
I can't check to see why I appended the ".exe" since I don't have VB30
on disk anymore. However, consider this snippet from MSVC 4.0's help
file about the argument passed to the function:
--------
"Points to a null-terminated string that names a Win32 module (either
a .DLL or .EXE file). If the filename extension is omitted, the
default library extension .DLL is appended. The filename string can
include a trailing point character (.) to indicate that the module
name has no extension. The string does not have to specify a path. The
name is compared (case independently) to the names of modules
currently mapped into the address space of the calling process."
--------
I know the above refers to Win32 but the Win31 API help file doesn't
say much about the function. HTH.
George
Quote:
>I would be forever grateful if someone could check this code and tell me
>why it constantly causes apps to crash. All the code is stored in a .bas
>file which i add to many of my projects - usually with the same
>catastrophic results.
>Start3d is called in Form_Load, and End3d from Form_Unload.
>Using Win 3.10 and VB 3.0 (Standard)
>Many thanks in advance!
>--
>>>Redeye<<
>----------------------------
>Option Explicit
>Declare Function GetModuleHandle Lib "Kernel" (ByVal lpModuleName As
>String) As Integer
>Declare Function Ctl3dRegister Lib "CTL3DV2.DLL" (ByVal hInstance As
>Integer) As Integer
>Declare Function Ctl3dAutoSubClass Lib "CTL3DV2.DLL" (ByVal hInstance As
>Integer) As Integer
>Declare Function Ctl3dUnRegister Lib "CTL3DV2.DLL" (ByVal hInstance As
>Integer) As Integer
>Sub End3D ()
> Dim hInstance As Integer
> Dim nReturn As Integer
> hInstance = GetModuleHandle(App.EXEName)
> nReturn = Ctl3dUnRegister(hInstance)
>End Sub
>Sub Start3D ()
> Dim hInstance As Integer
> Dim nReturn As Integer
> hInstance = GetModuleHandle(App.EXEName)
> nReturn = Ctl3dRegister(hInstance)
> nReturn = Ctl3dAutoSubClass(hInstance)
>End Sub
===========================================================================
====
George R. Torralba xxxxxxxxxxxx Batang Cebu!!!
Seattle, Washington 206.277.0821 MIME mail accepted
===============================================================================