Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Packaged App barfs with LoadPicture

Status
Not open for further replies.

NeilFrank

Programmer
Mar 12, 2000
167
CA
I am in the process of debugging a Packaged and Deployed VB6 MDI App. I used Inno Setup which worked where Microsoft's Package & Deployment Wizard failed.

However, I've discovered a nasty glitch in the resulting packaged App: it crashes when it encounters a LoadPicture command.

I use this to change the MouseIcon, eg
Screen.MouseIcon = LoadPicture(App.Path & "\Icons\HourglassA.ico")

and, more importantly, to populate an ImageBox. eg
strStructure = App.Path & "\Structures\" & foo.gif
imgStructure.Picture = LoadPicture(strStructure)

Why is LoadPicture flubbing?
Is there an alternate method to fill a ImageBox?
 
If it crashes without ever showing you the error, I would suggest the first thing you do is add error handling to your procedures so you can capture the error number and description.


 

No error reported. Problem only seen when I run packaged App. Crashes here (almost) never report errors, in my experience.

The good news is that by replacing the .gif picture with a .bmp, the problem goes away!!
 
Thanks JoeAtWork. I have thought of this. As things stand now, for each of my (1,981) Procedures I do have code that writes out its name as it is opens to a debug file, eg:

If gblnDoApFlowDebug = True Then Print #100, "MedInfoStructure.cboIndex"
If gblnDoClickFlowDebug = True Then gClick = gClick + 1: Print #300, "[" & _
gClick & "] " & "MedInfoStructure.cboIndex"

Unfortunately, it was only recently that I realized that it would be good to add the type of error trapping you suggest. Adding a global error-reporting routine would be trivial, eg:

Private Sub Foo
On Error GoTo CrashLog
{Procedure Body }
Exit Sub
CrashLog:
x = Procedure.Name '*****
Call CrashWrite(Err.Number, Err.Description, x)
End Sub

Public Sub CrashWrite(iE As Integer, sE As String, sR As String)
MsgBox "Error " & iE & " ( " & sE & " ) in Procedure " & sR
End Sub

The problem I face is that I would have to painstakingly add such "On Error" code to each procedure. Moreover, since VB does not offer a Procedure.Name function [this has recently been discussed here - Preserving run-time error messages
thread222-1429411] this job would be even more tedious.

But I may have to do it.
 
Since all your code is available as text files, and you're working with a repeatable pattern, you could probably add all this code programmatically.
 
NeilFrank said:
The good news is that by replacing the .gif picture with a .bmp, the problem goes away!!
Maybe this is a memory issue, since bitmaps tend to be much bigger than Gifs.


 
>The good news is that by replacing the .gif picture with a .bmp, the problem goes away!!

Also be sure to check that the file extension is .bmp and not .BMP I ran into this a while back and discovered that the extensions are case sensitive
 
>and discovered that the extensions are case sensitive

A miracle
 
NeilFrank said:
since VB does not offer a Procedure.Name function....
Well, not directly in the language itself, but there is something like that if you write a program that uses the Visual Basic 6.0 Extensibility library. This is a library that could be used to write your own add-ins to the VB IDE. Years ago, I wrote a "Code Manipulator" program to insert error handling in all procedures of a very large program.

It took me about two days to write, which was less time than it would have taken me to insert all the error handlers in all the procedures.

Anyways, a snippet of code that highlights getting the procedure name
Code:
    For Each tmpMod In gVBInstance.VBProjects(1).VBComponents
                
        'Loop through all procedures in the module
        ProcCount = tmpMod.CodeModule.Members.Count
        
        For Each tmpProc In tmpMod.CodeModule.Members
        
            'Get the name of the procedure
            ProcName = tmpProc.Name

            'LEFT OUT: INSERTING NEW CODE IN THE PROC.....

        Next tmpProc
        
    Next tmpMod

 
>>A miracle

Mainly because Win32 (and hence VB) is case-insensitive ...

 
Yeah, that struck me as strange. Can you explain that, strongm?
 
Yes, I can give one possibility.

This could happen if you have used a non-Win32 subsystem against an NTFS (which IS case-sensitive) volume, e.g. POSIX, CygWin, Windows Services for Unix, etc.

Using any of these you could create

example.bmp

and

example.BMP

which would be recognized as different files.

But Win32 will only give you access to one of the files because it cannot discriminate between them. This may (briefly, since any further investigation would show that you always get the same file no matter what case you use) give the impression that your application is being case-sensitive (because you don't get the file that you expect), whilst what it actually doing is demonstrating the (expected) case-insensitivity.
 
>>That makes sense.

i am sure strongm is correct, i tried to reproduce the behavior when another miracle occured, the realization that it was not a vb project i was working on when this issue was discovered. :-0
 

Correction to what I wrote on Jan 7:

>The good news is that by replacing the .gif picture with a .bmp, the problem goes away!!<

.gifs work fine as well.

 

>> Years ago, I wrote a "Code Manipulator" program to insert error handling in all procedures of a very large program.

Is your program available JoeAtWork?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top