-
[RESOLVED] Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
This error is happening, when I start the application, on Windows 7 (x64) PC (not used for programming)
It is happening to 5 of my applications. For example one is a tiny VB6(sp6) test program, using no OCX .
It had been working on any platform. Its only dependency is stdole2.tlb .
I used IcoFx to create an icon using True Colors (24 bits).
I took my tiny NoOCX VB6 program and added a True Colors (24 bits) icon to the main form. (Form Properties - Icon)
I also opened the Project Properties - Make - Application and selected the main form for the icon.
When running on the host PC, the icon appears in the title bar of the form and the icon for the .exe file.
I hope a solution arrived at here can be applied to my primary applications, one of which has icons on some buttons.
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
I have tried, unsuccessfully to attach the 'offending' icon file: NoOCX.ico
I wonder if I can attach an executable (the 123 KB installation package) for this tiny test app ?
This all works on Windows 10 (x64).
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Executables are a no-no. Attach the icon in a zip file. The site will accept zips, not ico files.
Trying to understand. If you run your project compiled or uncompiled on your PC, no problems. But if you compile and pass it to another PC, you get the error? Have you determined exactly which line of code is causing the error? That would be extremely helpful
-
1 Attachment(s)
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Sorry, today has been frustrating - I spend time carefully constructing a response and [Post Quick Reply] to learn that it timed out and I lost the text! I will start again in Notepad.Attachment 151593
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
On my Development Host windows 7 (x64) PC, zNoOCX.exe works:
Icon does appear on zNoOCX.exe main form title bar.
Icon does NOT appear on zNoOCX.exe desktop shortcut.
Icon does appear in zNoOCX.exe shortcut properties.
Icon does appear on zNoOCX.exe.
Icon does appear in zNoOCX.exe properties.
On my test windows 10 (x64) PC, zNoOCX.exe works:
Icon does appear on zNoOCX.exe main form title bar.
Icon does NOT appear on zNoOCX.exe desktop shortcut.
Icon does appear in zNoOCX.exe shortcut properties.
Icon does appear on zNoOCX.exe.
Icon does appear in zNoOCX.exe properties.
On my wife's windows 7 (x64) PC, zNoOCX.exe installs but does not work:
zNoOCX.exe main form will NOT load.
Icon does appear on zNoOCX.exe desktop shortcut.
Icon does appear in zNoOCX.exe shortcut properties.
Icon does appear on zNoOCX.exe.
Icon does appear in zNoOCX.exe properties.
Line of code, at this point, I have to GUESS:
Private Sub Main()
:
:
'... show your main form next (i.e., Form1.Show)
frmNoOCX.Show
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
I can incorporate some of my customary error trapping code (Usually MsgBox and sometimes ErrLog) However, looking at the code, I think probably, not:
Private Type InitCommonControlsExStruct
lngSize As Long
lngICC As Long
End Type
Private Declare Function InitCommonControls Lib "comctl32" () As Long
Private Declare Function LoadLibrary Lib "kernel32.dll" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32.dll" (ByVal hLibModule As Long) As Long
Private Declare Function InitCommonControlsEx Lib "comctl32.dll" (iccex As InitCommonControlsExStruct) As Boolean
Private Sub Main()
Dim iccex As InitCommonControlsExStruct, hMod As Long
Const ICC_ALL_CLASSES As Long = &HFDFF& ' combination of all known values
' constant descriptions: http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
With iccex
.lngSize = LenB(iccex)
.lngICC = ICC_ALL_CLASSES ' you really should customize this value from the available constants
End With
On Error Resume Next ' error? Requires IEv3 or above
hMod = LoadLibrary("shell32.dll")
InitCommonControlsEx iccex
If Err Then
InitCommonControls ' try Win9x version
Err.Clear
End If
On Error GoTo 0
'... show your main form next (i.e., Form1.Show)
frmNoOCX.Show
If hMod Then FreeLibrary hMod
'** Tip 1: Avoid using VB Frames when applying XP/Vista themes
' In place of VB Frames, use pictureboxes instead.
'** Tip 2: Avoid using Graphical Style property of buttons, checkboxes and option buttons
' Doing so will prevent them from being themed.
End Sub
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
I can take a look at your icons in a couple hours when I get home. However, none of what you've said seems to indicate "invalid picture" errors? Are you seeing that error? Of is that the error that appears on your wife's machine just before the exe fails?
Does your compiled exe contain a manifest? What code, if any, do you have in frmNoOCX_Load or frmNoOCX_Resize? At this point without any additional info, leaning towards your app attempting to load an invalid reference (doesn't exist on wife's PC) or writing/reading from a folder that doesn't exist or wife doesn't have permissions to.
-
1 Attachment(s)
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Quote:
Originally Posted by
anderci
Sorry, today has been frustrating - I spend time carefully constructing a response and [Post Quick Reply] to learn that it timed out and I lost the text! I will start again in Notepad.
Attachment 151593
I know this (timeout) is a "side" issue, but let's spend a moment on it ..
What browser are you using?
When composing a reply, about every 60 seconds, an Auto-Saved appears in the lower right corner of the window. If you get "cut off" for some reason, come back to the thread, and the Quick Reply window should look like this,
Attachment 151613
Just click Restore Auto-Saved Comment and you're on your way.
BTW, I started out using IE, but shortly thereafter switched to Chrome.
Spoo
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Be sure to read my reply in post #7 above.
I took your icon file and added it to a form's Icon property, no code whatsoever exists in the project/form. I compiled it and then went to my Vista box and opened the exe. No problems.
P.S. That icon file does contain a PNG-encoded 256x256 icon. Technically, that icon file does NOT contain any 24-bit icons. It does contain:
- 32x32 4-bit
- 16x16 4-bit
- 48x48 8-bit
- 32x32 8-bit
- 16x16 8-bit
- 256x256 PNG-encoded, 32-bit not 24-bit as reported in the icon's Directory Entry structure.
For those that know PNG: 8 bit per channel (color), color type 6 (includes alpha channel)
If you strongly believe it is the icon causing you the problems, suggest this simple test...
1. Start with the last icon in the file and remove it
2. Replace the form's icon with the updated icon file (the one you removed the icon from)
3. Compile and run the exe on your wife's PC
Continue the previous steps until a) the exe runs on your wife's pc or b) you run out of icons to remove
If you are using an embedded manifest. Try a different/new test project and only include the icon file as the form's Icon property. Don't include any res file or anything else. Does that work on your wife's PC?
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Quote:
Originally Posted by
Spooman
I know this (timeout) is a "side" issue, but let's spend a moment on it ..
What browser are you using?
Spoo
I use Firefox 99% of the time and default IE otherwise. I will try to keep my cool and look for [Restore Auto-Saved Content]
-
1 Attachment(s)
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Thinking about the spotty show/no show of the icon makes me wonder if part of that is the selection of sizes avaiable is problematic:
256x256 - 24, 48x48 - 8, 32x32 - 8, 16x16 - 8, 32x32 - 4, 16x16 - 4
My selections were random, without any specific knowledge.
256x256 - 24, 48x48 - 24, 32x32 - 24, 24x24 - 24, 16x16 - 24
256x256 - 8, 48x48 - 8, 32x32 - 8, 24x24 - 8, 16x16 - 8
256x256 - 4, 48x48 - 4, 32x32 - 4, 24x24 - 4, 16x16 - 4
==> ILLEGAL PICTURE when trying to Load Icon into Form.
256x256 - 24, 48x48 - 24, 32x32 - 24, 24x24 - 24, 16x16 - 24
256x256 - 8, 48x48 - 8, 32x32 - 8, 24x24 - 8, 16x16 - 8
48x48 - 4, 32x32 - 4, 24x24 - 4, 16x16 - 4
Attachment 151617
On my Development Host windows 7 (x64) PC, zNoOCX.exe works:
Icon does appear on zNoOCX.exe main form title bar.
Icon does appear on zNoOCX.exe desktop shortcut.
Icon does appear in zNoOCX.exe shortcut properties.
Icon does appear on zNoOCX.exe.
Icon does appear in zNoOCX.exe properties.
On my test windows 10 (x64) PC, zNoOCX.exe works:
Icon does appear on zNoOCX.exe main form title bar.
Icon does appear NOT on zNoOCX.exe desktop shortcut.
Icon does appear in zNoOCX.exe shortcut properties.
Icon does appear on zNoOCX.exe.
Icon does appear in zNoOCX.exe properties.
On my wife's windows 7 (x64) PC, zNoOCX.exe installs but does not work: Error 481 - Invalid picture
zNoOCX.exe main form will NOT load.
Icon does appear on zNoOCX.exe desktop shortcut.
Icon does appear in zNoOCX.exe shortcut properties.
Icon does appear on zNoOCX.exe.
Icon does appear in zNoOCX.exe properties.
In searching web, I found a ?possible? solution :
Providing a proper VB Application Icon, Including Large Icons and 32-Bit Alpha Images
http://www.vbaccelerator.com/home/vb...ly/article.asp
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Note: order of icons is important. Always ensure a 16x16 or 32x32 icon of bit depths 24 or less (no PNG icon either) is the first icon in the file. This can prevent VB from rejecting it outright.
Interested in your tests on your wife's PC.
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Quote:
Originally Posted by
LaVolpe
I can take a look at your icons in a couple hours when I get home. However, none of what you've said seems to indicate "invalid picture" errors? Are you seeing that error? Of is that the error that appears on your wife's machine just before the exe fails?
Does your compiled exe contain a manifest? What code, if any, do you have in frmNoOCX_Load or frmNoOCX_Resize? At this point without any additional info, leaning towards your app attempting to load an invalid reference (doesn't exist on wife's PC) or writing/reading from a folder that doesn't exist or wife doesn't have permissions to.
The 481 error appears When it fails to open the main form.
The compiled exe does contain the manifest (Manifest Creator II)
This is one of my tiny apps for this testing (no OCX file used in this one).
The only icon in the entire application is in the form's icon property (title bar).
Private Sub Form_Load()
sOutputPath = SetgsRWApp_Path() & "\Data"
AssurePathExists sOutputPath
Me.Label1.Caption = sOutputPath
Me.Text1.Text = Me.Text1.Text & " " & Me.Name
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim strOutfile As String, iFileOutputNumber As Integer, bAppend As Boolean, strRecord As String
strOutfile = sOutputPath & "\" & Me.Name & ".txt"
bAppend = True
strRecord = Me.Text1.Text & vbCrLf & Me.Label1.Caption
iFileOutputNumber = OpenFileOutput(strOutfile, bAppend)
WriteFileOutput iFileOutputNumber, strRecord
CloseFileOutput iFileOutputNumber
End Sub
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Ok. It might be the 256x256 icon that is causing the problem. But in Vista, I had no problems so I wouldn't think Win7 would have a problem either. Simple test... remove the 256x256 icon and see if problem goes away.
-
1 Attachment(s)
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Maybe I should drop the 256x256 (-24 and -8) entirely? IcoFx says nothing about any existence of PNG?
I removed both of the 256x256 icons mentioned in post #11 and got the same results on all three PCs
48x48 - 24, 32x32 - 24, 24x24 - 24, 16x16 - 24
48x48 - 8, 32x32 - 8, 24x24 - 8, 16x16 - 8
48x48 - 4, 32x32 - 4, 24x24 - 4, 16x16 - 4
Attachment 151621
I do not understand Post #9 'If you are using an embedded manifest. Try a different/new test project and only include the icon file as the form's Icon property. Don't include any res file or anything else.'
It seems strange that Windows 10 consistently omits the icon from the desktop shortcut?
I wonder if the answer is in the code at:
Providing a proper VB Application Icon, Including Large Icons and 32-Bit Alpha Images
http://www.vbaccelerator.com/home/vb...ly/article.asp
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Embedded manifest requires a res file, unless manifest is later added to a compiled exe. So, just ignore that statement if it doesn't apply.
FYI: The file you included in your zip had only one 256x256 icon. IcoFx probably wouldn't mention PNG, unless in its help file (if it has one). It is common practice to create 256x256, 512x512, and larger icons as PNGs. Creating 256x256 icons based on bitmap can make the icon huge, byte-wise. But based on PNG format allows compression. Vista was the first O/S to allow icons in PNG format.
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
fyi and for what it worth, I have attached 2 more .zip icon files: post #11 NoOCX2484.zip and post #15 NoOCX48-1624-4.zip
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
I see both post #15 & #11 have icons where a 48x48 is first one in file, none are PNG-encoded and there are 24-bit icons. Even though a 48x48 is first in the file, VB didn't complain when I added it as the form's Icon property. I thought it would.
Did removing the 256x256 solve your problem? Curious, because I'd think if it worked on my Vista box then it should work on a Win7 box.
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
No, still no solution. Even any changes in behavior:
Except on my Development Host windows 7 (x64) PC:
Icon does appear on zNoOCX.exe desktop shortcut.
However, on my wife's test windows 10 (x64) PC:
Icon STILL does NOT appear on zNoOCX.exe desktop shortcut.
Curiously, on my wife's test windows 10 (x64) PC, the desktop shortcuts for my primary applications show their icons??
I think that maybe tomorrow, I will try experimenting on a new project, similar to zNoOCX, with the code at:
Providing a proper VB Application Icon, Including Large Icons and 32-Bit Alpha Images
http://www.vbaccelerator.com/home/vb...ly/article.asp
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
I created an icon for each of my tiny OCX test applications and installed an icon in each app:
256x256 - 24, 48x48 - 24, 32x32 - 24, 24x24 - 24, 16x16 - 24
48x48 - 8, 32x32 - 8, 16x16 - 8
On my Development Host windows 7 (x64) PC, z....exe works:
Icon does appear on z....exe main form title bar.
Icon does appear on z....exe desktop shortcut.
Icon does appear in z....exe shortcut properties.
Icon does appear on z....exe.
Icon does appear in z....exe properties.
On my test windows 10 (x64) PC, z....exe works:
Icon does appear on z....exe main form title bar.
* Icon does NOT appear on z....exe desktop shortcut.
Icon does appear in z....exe shortcut properties.
Icon does appear on z....exe.
Icon does appear in z....exe properties.
On my wife's windows 7 (x64) PC, z....exe installs but does not work: Error 481 - Invalid picture
* Icon does NOT appear on z....exe main form title bar: Error 481 - Invalid picture
Icon does appear on z....exe desktop shortcut.
Icon does appear in z....exe shortcut properties.
Icon does appear on z....exe.
Icon does appear in z....exe properties.
OK, I guess, finally, the next step is the vbaccelerator code in a copy of a tiny app.
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
After reading the article about the vbaccelerator (ca 2003), I mimized the options on one of the icons leading to these results:
48x48 - 8, 32x32 - 4, 16x16 - 4
On my Development Host windows 7 (x64) PC, zNoOCX.exe works:
Icon does appear on zNoOCX.exe main form title bar.
Icon does appear on zNoOCX.exe desktop shortcut.
Icon does appear in zNoOCX.exe shortcut properties.
Icon does appear on zNoOCX.exe .
Icon does appear in zNoOCX.exe properties.
On my test windows 10 (x64) PC, zNoOCX.exe works:
Icon does appear on zNoOCX.exe main form title bar.
* Icon does NOT appear on zNoOCX.exe desktop shortcut.
Icon does appear in zNoOCX.exe shortcut properties.
Icon does appear on zNoOCX.exe .
Icon does appear in zNoOCX.exe properties.
On my wife's windows 7 (x64) PC, zNoOCX.exe installs but does not work: Error 481 - Invalid picture
* Icon does NOT appear on zNoOCX.exe main form title bar: Error 481 - Invalid picture
Icon does appear on zNoOCX.exe desktop shortcut.
Icon does appear in zNoOCX.exe shortcut properties.
Icon does appear on zNoOCX.exe
Icon does appear in zNoOCX.exe properties.
I read some more websites about icon sizes... for various windows versions -> clarity??
Therefore another test?
48x48 - 8, 32x32 - 8, 24x24 - 8, 16x16 - 8
48x48 - 4, 32x32 - 4, 24x24 - 4, 16x16 - 4
On my Development Host windows 7 (x64) PC, zRichTx.exe works:
Icon does appear on zRichTx.exe main form title bar.
Icon does appear on zRichTx.exe desktop shortcut.
Icon does appear in zRichTx.exe shortcut properties.
Icon does appear on zRichTx.exe .
Icon does appear in zRichTx.exe properties.
On my test windows 10 (x64) PC, zRichTx.exe works:
Icon does appear on zRichTx.exe main form title bar.
Icon does appear on zRichTx.exe desktop shortcut.
Icon does appear in zRichTx.exe shortcut properties.
Icon does appear on zRichTx.exe .
Icon does appear in zRichTx.exe properties.
On my wife's windows 7 (x64) PC, zRichTx.exe installs but does not work: Error 481 - Invalid picture
* Icon does NOT appear on zRichTx.exe main form title bar: Error 481 - Invalid picture
Icon does appear on zRichTx.exe desktop shortcut.
Icon does appear in zRichTx.exe shortcut properties.
Icon does appear on zRichT.xexe
Icon does appear in zRichT.xexe properties.
I think I am going in circles?
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
I know this doesn't help, but I also encountered a single client Win7 PC which triggers this 481 error when setting the form icon from code.
I also used the SetIcon routine from vbAccelerator by Steve McMahon
I replaced it with a routine written by Bonnie West on this forum:
http://www.vbforums.com/showthread.p...=1#post4395099
I still haven't had any feedback from this particular user whether it works now.
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Arnoutdv, Thank you. Mine is one simple (main) form, not a MDIform. I do not think I have ever used a MDIform.
I did try Bonnie West's code. There were a number of things that were undefined, so I commented a few lines out:
Private Sub Form_Load()
If App.LogMode Then
Set Icon = Nothing
' m_hIcon = LoadImageW(App.hInstance, WINDOWS_ICON, IMAGE_ICON, ICON_JUMBO, ICON_JUMBO)
' SendMessageW hWnd, WM_SETICON, ICON_SMALL, LoadImageW(App.hInstance, WINDOWS_ICON, IMAGE_ICON, 16&, 16&)
' SendMessageW hWnd, WM_SETICON, ICON_BIG, LoadImageW(App.hInstance, WINDOWS_ICON, IMAGE_ICON, , , LR_DEFAULTSIZE)
End If
-----------------------------------
Private Sub Form_Unload(Cancel As Integer)
Set m_picIcon = Nothing
Controls.Remove pbID
If m_hIcon Then
DestroyIcon m_hIcon
' DestroyIcon SendMessageW(hWnd, WM_SETICON, ICON_BIG, 0&)
' DestroyIcon SendMessageW(hWnd, WM_SETICON, ICON_SMALL, 0&)
End If
I do not know if my 'messing in' neutered her code or bypassed something only relevant to MDIforms. Or they part of a control I am not using. On this particular form I only have an SSCheckBox.
My tiny app has its only icon in the form property (Title bar).
My tiny app with this modification still works on my development PC and a test win10 PC, but still fails on the Win7 Test PC
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
If you comment out all crucial lines then nothing will happen.
In the sample project all these elements (API calls, declarations) are there.
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Using both icons NoOCX, I had no problems:
- Windows 7 Pro SP1
- Windows 10 Pro v. 1703 - build 15063.540
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Arnoutdv, Thank you for your patience. 'sample project'?
After pasting in Bonnie West's code, I saved, then tried running in VB6. It was erring on the arguments e.g.: WINDOWS_ICON
I replaced that with me.icon , then next try: WM_SETICON. I had no idea what to do with that?...
Was I, maybe, just supposed to build it and try running the .exe?
I feel like I am missing an elephant in the room?
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Arnoutdv,
Bonnie West stated that adjustments were made to work with the MDIform.
"In the sample project all these elements (API calls, declarations) are there. "
What sample project are you referring to?
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
gibra,
My Windows 7 (x64) PC is 'tainted' with development activity and I have no trouble running all of my primary VB6 applications and all of my tiny test VB6 applications. That is how I fooled myself into believing that my applications could run on anything!
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
I've tested in a 'clean' OS (both 64 bit).
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
gibra here is a zip file containing the zRichTx tiny app. It displays its icon everywhere.
(as reported in post #21)
It opens its form in its WinXP (x32) development virtual PC, my host Win7(x64) host PC and the win10(x64) test PC.
It fails with error 481 on my wife's Win7(x64) (untainted by any development work).
(executable removed by moderator)
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
There is an attachment in post #6
Quote:
256x256 Icons.rar.zip (253.3 KB, 1202 views)
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Quote:
Originally Posted by
anderci
gibra here is a zip file containing the zRichTx tiny app. It displays its icon everywhere.
(executable removed by moderator)
Your zip contains a SETUP.EXE program! WHY?
Sorry, but I don't install nothing.
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Arnoutdv, Thank you. The Module1.bas made the world of difference!
Bonnie West's code adds an image of the icon to the center of the form:
256x256 - 24, 48x48 - 24, 32x32 - 24, 24x24 - 24, 16x16 - 24
48x48 - 8, 32x32 - 8, 16x16 - 8
On my Development Host windows 7 (x64) PC, zThreeD.exe works:
Icon does appear on zThreeD.exe main form title bar and center of form.
Icon does appear on zThreeD.exe desktop shortcut.
Icon does appear in zThreeD.exe shortcut properties.
Icon does appear on zThreeD.exe.
Icon does appear in zThreeD.exe properties.
On my test windows 10 (x64) PC, zThreeD.exe works:
Icon does appear on zThreeD.exe main form title bar and center of form.
Icon does appear on zThreeD.exe desktop shortcut.
Icon does appear in zThreeD.exe shortcut properties.
Icon does appear on zThreeD.exe.
Icon does appear in zThreeD.exe properties.
On my wife's windows 7 (x64) PC, zThreeD.exe installs but does not work: Error 481 - Invalid picture
* Icon does NOT appear on zThreeD.exe main form title bar: Error 481 - Invalid picture
Icon does appear on zThreeD.exe desktop shortcut.
Icon does appear in zThreeD.exe shortcut properties.
Icon does appear on zThreeD.exe.
Icon does appear in zThreeD.exe properties.
I am beginning to think that while my wife's PC is not tainted by Development, I am beginning to wonder if it might be tainted by applications like iTunes, VirtualBox and a variety of games, ...
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
gibra,
OK, even my tiny test applications include a setup. In building the application, I use Manifest Creator II to build the resource file and then NSIS script to gather up the dependency files, e.g.: stdole2.tlb and THREED32.ocx .
The idea is to install the application (reg-free) to be self supporting and not interfere with other applications, in a way so it can be cleanly uninstalled.
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Interesting behavior: I set the zThreeD.exe main form icon value to (none)
On my Development Host windows 7 (x64) PC, zThreeD.exe works:
Default Icon does appear on zThreeD.exe main form title bar and center of form.
Default Icon does appear on zThreeD.exe desktop shortcut (after screen Refresh).
Default Icon does appear in zThreeD.exe shortcut properties.
Default Icon does appear on zThreeD.exe.
Default Icon does appear in zThreeD.exe properties.
On my test windows 10 (x64) PC, zThreeD.exe works:
Default Icon does appear on zThreeD.exe main form title bar and center of form.
* Old Icon does appear on zThreeD.exe desktop shortcut (Unaffected by Refresh or reboot?).
Default Icon does appear in zThreeD.exe shortcut properties.
Default Icon does appear on zThreeD.exe.
Default Icon does appear in zThreeD.exe properties.
On my wife's windows 7 (x64) PC, zThreeD.exe, zThreeD.exe works:
Default Icon does appear on zThreeD.exe main form title bar and center of form.
Default Icon does appear on zThreeD.exe desktop shortcut.
Default Icon does appear in zThreeD.exe shortcut properties.
Default Icon does appear on zThreeD.exe.
Default Icon does appear in zThreeD.exe properties.
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Quote:
Originally Posted by
anderci
OK, even my tiny test applications include a setup.
I have removed your attachment to protect our members, because we have no way of knowing what an executable file actually does - which could include something malicious, such as if there is a virus on your computer.
In addition to that, a compiled program (as opposed to code/pictures/etc) generally does nothing towards helping us to assist you.
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
This is the code for the main form frmThreeD
Code:
'Re:Bonnie West +vvvvvvvvvvvvvvvvvvvvv
Option Explicit 'Don't forget to set the "windows_perfection_logo_v2_d-bliss.ico" icon as the MDIForm's Icon! (Set it via the Properties Window)
Private Const pbID As String = "picIcon"
Private Declare Function DestroyIcon Lib "user32.dll" (ByVal hIcon As Long) As Long
Private Declare Function FindWindowExW Lib "user32.dll" (Optional ByVal hWndParent As Long, Optional ByVal hWndChildAfter As Long, Optional ByVal lpszClass As Long, Optional ByVal lpszWindow As Long) As Long
Private Declare Function InvalidateRect Lib "user32.dll" (ByVal hWnd As Long, Optional ByVal lpRect As Long, Optional ByVal bErase As Long = -True) As Long
Private m_hIcon As Long
Private m_hWndMC As Long
Private m_picIcon As VB.PictureBox
'Re:Bonnie West +^^^^^^^^^^^^^^^^^^^^^
Public sOutputPath As String
Public Function SetgsRWApp_Path() As String '31jul2013
On Error Resume Next
Dim sAppPath0 As String, sAppSubFolder As String, sProgramFiles As String, sProgramFilesx86 As String, sProgramData As String, sPUBLIC As String
'Debug.Print "ProgramFiles: '"; Environ("ProgramFiles"); "'"
'Debug.Print "ProgramFiles(x86): '"; Environ("ProgramFiles(x86)"); "'"
'Debug.Print "ProgramData: '"; Environ("ProgramData"); "'"
'Debug.Print "PUBLIC: '"; Environ("PUBLIC"); "'"
SetgsRWApp_Path = ""
sAppPath0 = App.Path
sProgramFiles = Environ("ProgramFiles")
sProgramFilesx86 = Environ("ProgramFiles(x86)")
sProgramData = Environ("ProgramData")
sPUBLIC = Environ("PUBLIC")
If (Len(Trim(sPUBLIC)) > 0) Then '28aug2017
sPUBLIC = Left(sAppPath0, 3) & Mid(sPUBLIC, 4) '28aug2017
End If '28aug2017
'sProgramFiles = InputBox("sProgramFiles", "SetgsRWApp_Path", sProgramFiles)
'sProgramFilesx86 = InputBox("sProgramFilesx86", "SetgsRWApp_Path", sProgramFilesx86)
'sProgramData = InputBox("sProgramData", "SetgsRWApp_Path", sProgramData)
'sPUBLIC = InputBox("sPUBLIC", "SetgsRWApp_Path", sPUBLIC)
If Len(Trim(sProgramFilesx86)) > 0 Then
sProgramFilesx86 = Left(sAppPath0, 3) & Mid(sProgramFilesx86, 4) '28aug2017
sAppSubFolder = Mid(sAppPath0, InStr(sAppPath0, sProgramFilesx86) + Len(sProgramFilesx86))
If (Len(Trim(sPUBLIC)) > 0) And (InStr(sAppPath0, sProgramFilesx86) > 0) Then
SetgsRWApp_Path = sPUBLIC & sAppSubFolder
ElseIf (Len(Trim(sProgramData)) > 0) And (InStr(sAppPath0, sProgramFilesx86) > 0) Then
SetgsRWApp_Path = sProgramData & sAppSubFolder
Else
MsgBox "Cannot create Read/Write Application Path" & vbCrLf & "sAppPath0='" & sAppPath0 & "'" & vbCrLf & "sProgramFiles='" & sProgramFiles & "'" & vbCrLf & "sProgramFilesx86='" & sProgramFilesx86 & "'" & vbCrLf & "sProgramData='" & sProgramData & "'" & vbCrLf & "sPUBLIC='" & sPUBLIC & "'", vbCritical, "SetgsRWApp_Path"
End If
'MsgBox "sAppPath0='" & sAppPath0 & "' sProgramFiles='" & sProgramFiles & vbCrLf & "' sProgramFilesx86='" & sProgramFilesx86 & vbCrLf & "' sProgramData='" & sProgramData & vbCrLf & "' sPUBLIC='" & sPUBLIC, , "SetgsRWApp_Path"
ElseIf Len(Trim(sProgramFiles)) > 0 Then
sProgramFiles = Left(sAppPath0, 3) & Mid(sProgramFiles, 4) '28aug2017
sAppSubFolder = Mid(sAppPath0, InStr(sAppPath0, sProgramFiles) + Len(sProgramFiles))
If (Len(Trim(sPUBLIC)) > 0) And (InStr(sAppPath0, sProgramFiles) > 0) Then
SetgsRWApp_Path = sPUBLIC & sAppSubFolder
ElseIf (Len(Trim(sProgramData)) > 0) And (InStr(sAppPath0, sProgramFiles) > 0) Then
SetgsRWApp_Path = sProgramData & sAppSubFolder
Else
SetgsRWApp_Path = sAppPath0
End If
Else
MsgBox "Cannot create Read/Write Application Path" & vbCrLf & "sAppPath0='" & sAppPath0 & "'" & vbCrLf & "sProgramFiles='" & sProgramFiles & "'" & vbCrLf & "sProgramFilesx86='" & sProgramFilesx86 & "'" & vbCrLf & "sProgramData='" & sProgramData & "'" & vbCrLf & "sPUBLIC='" & sPUBLIC & "'", vbCritical, "SetgsRWApp_Path"
'MsgBox "sAppPath0='" & sAppPath0 & "' sProgramFiles='" & sProgramFiles & vbCrLf & "' sProgramFilesx86='" & sProgramFilesx86 & vbCrLf & "' sProgramData='" & sProgramData & vbCrLf & "' sPUBLIC='" & sPUBLIC, , "SetgsRWApp_Path"
End If
'MsgBox "SetgsRWApp_Path=" & SetgsRWApp_Path, , "SetgsRWApp_Path"
'26jul2017 TEST for (64bit)
' MsgBox " sProgramFiles=" & sProgramFiles & vbCr & " sProgramFilesx86=" & sProgramFilesx86 & vbCr & " sProgramData=" & sProgramData & vbCr & " sPUBLIC=" & sPUBLIC & vbCr & " SetgsRWApp_Path=" & SetgsRWApp_Path, , "TEST" & " " & "for (64bit)"
End Function
'Function: AssurePathExists
'Purpose: If the complete specified path does not exist, then create it.
'Parms: sPathName - String - The full path to be assured e.g.:
' D:\DIR1\DIR2\DIR3 or D:\DIR1\DIR2\DIR3\
' If the last character is not a "\", it will be supplied.
'Returns: True if the path already exists or was successfully created, False if unsucessful.
'Date: November,09 2000 '29sep2011
'Author: Clark Anderson
Public Function AssurePathExists(ByVal sPathName As String) As Boolean
On Error GoTo Exit_AssurePathExists
Dim sTestPath As String, iPos As Integer
AssurePathExists = False
If IsNumeric(sPathName) Then Exit Function '29sep2011
If Len(sPathName) = 0 Then Exit Function
If Right$(sPathName, 1) <> "\" Then sPathName = sPathName & "\"
If PathExists(sPathName) Then
AssurePathExists = True
Exit Function
End If
iPos = 0
Do Until iPos = Len(sPathName)
iPos = InStr(iPos + 1, sPathName, "\")
sTestPath = Left$(sPathName, iPos)
If Not PathExists(sTestPath) Then MkDir sTestPath
Loop
AssurePathExists = True
Exit_AssurePathExists:
Exit Function
End Function
'
'Function: ExtractPath
'Purpose: extract and return the path part of a full pathname.
'Parms: FullPathName - String containing the full path name of a file.
'Returns: String containing the path part of the specified full path file name.
'Date: June,09 2000
'Author: R.S.Furman
Function ExtractPath(ByVal FullPathName As Variant) As String
Dim i As String
'Preset the returned string to an empty string.
ExtractPath = ""
'Validate input parameter.
If (VarType(FullPathName) <> vbString) Then Exit Function
FullPathName = Trim(FullPathName)
If (Len(FullPathName) = 0) Then Exit Function
If (InStr(FullPathName, "\") = 0) Then Exit Function
'Find the last "\" in the full path name.
'16Jan2005 i = InStrLast(FullPathName, "\")
i = InStrRev(FullPathName, "\") '16Jan2005
'Return the path part of the specified full path name.
ExtractPath = Left$(FullPathName, i - 1)
End Function
Function CloseFileOutput(ByVal iFileNumber As Integer) As Integer
On Error Resume Next
Close #iFileNumber
CloseFileOutput = 0
End Function
Function OpenFileOutput(ByVal sApp_Path_OutFile As String, Optional bAppend As Boolean = False) As Integer '04apr2011
'04apr2011 Function OpenFileOutput(ByVal sApp_Path_OutFile As String) As Integer
On Error GoTo Err_OpenFileOutput
'MsgBox "sApp_Path_OutFile='" & sApp_Path_OutFile & "'", , "OpenFileOutput"
OpenFileOutput = 0
If Not PathExists(ExtractPath(sApp_Path_OutFile)) Then Exit Function '30sep2011
OpenFileOutput = FreeFile
' Open sApp_Path_OutFile For Output As #OpenFileOutput
If bAppend Then
Open sApp_Path_OutFile For Append As #OpenFileOutput
Else
Open sApp_Path_OutFile For Output As #OpenFileOutput
End If
Exit_OpenFileOutput:
Exit Function
Err_OpenFileOutput:
Select Case Err.Number
Case 70
'04nov2012 ErrLog Err.Number & " " & Err.Description & vbCrLf & "Remove Redirection from command line e.g.:" & vbCrLf & "> " & sApp_Path_OutFile & vbCrLf & "Specify Output file path and name in _.INI file", , "OpenFileOutput "
MsgBox Err.Number & " " & Err.Description & vbCrLf & "File: " & sApp_Path_OutFile & " is already open" & vbCrLf & vbCrLf & " OR possibly ..." & vbCrLf & "Remove Redirection from command line e.g.:" & vbCrLf & "> " & sApp_Path_OutFile & vbCrLf & "Specify Output file path and name in _.INI file", , "OpenFileOutput "
OpenFileOutput = 0
Resume Exit_OpenFileOutput
Case Else
MsgBox Err.Number & " " & Err.Description, , "Error in OpenFileOutput() "
OpenFileOutput = 0
Resume Exit_OpenFileOutput
End Select
End Function
'
'Function: PathExists
'Purpose: Determine whether or not a pathname is valid.
'Parm: pathname - String containing a file name or path to be tested.
'Returns: True, if the path is valid.
' False, if path is invalid.
'Date: 9/2/97
'Author: R.S.Furman
'Note: This is probably a good routine to make public, when the proper module
' is identified to hold it.
'Note: RSF 6/17/98 Updated to improve robustness.
Function PathExists(ByVal pathname As String) As Boolean
Dim res As Variant 'RSF 6/17/98 Declared as Variant to accept a NULL value.
PathExists = False
If IsNumeric(pathname) Then Exit Function '29sep2011
'If input pathname is empty, it's not a valid path
If (Len(pathname) = 0) Then Exit Function
'Check for valid path. invalid path causes trappable runtime error
On Error GoTo patherror
res = Dir(pathname, vbDirectory)
'RSF 6/17/98 Dir can return a NULL, check for a string before proceeding.
If (VarType(res) <> vbString) Then Exit Function
'If length of the result is zero, it's not a valid path
If (Len(res) = 0) Then Exit Function
PathExists = True
Exit Function
patherror:
End Function
Sub WriteFileOutput(ByVal iFileNumber As Integer, ByVal strOutput As String)
On Error GoTo Err_WriteFileOutput
If iFileNumber > 0 Then
Print #iFileNumber, strOutput
End If
Exit_WriteFileOutput:
Exit Sub
Err_WriteFileOutput:
Select Case Err.Number
Case Else
MsgBox Err.Number & " " & Err.Description, , "WriteFileOutput"
Resume Exit_WriteFileOutput
End Select
End Sub
Private Sub Form_Load()
sOutputPath = SetgsRWApp_Path() & "\Data"
AssurePathExists sOutputPath
Me.Label1.Caption = Me.Name & " ... " & sOutputPath
'Re:Bonnie West +vvvvvvvvvvvvvvvvvvvvv
m_hWndMC = FindWindowExW(hWnd, , StrPtr("MDIClient"))
If App.LogMode Then
Set Icon = Nothing
m_hIcon = LoadImageW(App.hInstance, WINDOWS_ICON, IMAGE_ICON, ICON_JUMBO, ICON_JUMBO)
SendMessageW hWnd, WM_SETICON, ICON_BIG, LoadImageW(App.hInstance, WINDOWS_ICON, IMAGE_ICON, , , LR_DEFAULTSIZE)
SendMessageW hWnd, WM_SETICON, ICON_SMALL, LoadImageW(App.hInstance, WINDOWS_ICON, IMAGE_ICON, 16&, 16&)
End If
Set m_picIcon = Controls.Add("VB.PictureBox", pbID)
With m_picIcon
.AutoRedraw = True
.BackColor = BackColor
.BorderStyle = 0
.ClipControls = False
.ScaleMode = vbPixels
End With
'Re:Bonnie West +^^^^^^^^^^^^^^^^^^^^^
End Sub
Private Sub Form_Resize()
'Re:Bonnie West +vvvvvvvvvvvvvvvvvvvvv
If WindowState <> vbMinimized Then
With m_picIcon
.Cls
.Move 0!, 0!, ScaleWidth, ScaleHeight
If m_hIcon Then
DrawIconEx .hDC, (.ScaleWidth - ICON_JUMBO) * HALF, _
(.ScaleHeight - ICON_JUMBO) * HALF, m_hIcon, ICON_JUMBO, ICON_JUMBO
ElseIf Not Icon Is Nothing Then
.PaintPicture Icon, (.ScaleWidth - .ScaleX(Icon.Width, vbHimetric, vbPixels)) * HALF, _
(.ScaleHeight - .ScaleY(Icon.Height, vbHimetric, vbPixels)) * HALF
End If
Set Picture = .Image
InvalidateRect m_hWndMC
End With
End If
'Re:Bonnie West +^^^^^^^^^^^^^^^^^^^^^
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim strOutfile As String, iFileOutputNumber As Integer, bAppend As Boolean, strRecord As String
strOutfile = sOutputPath & "\" & Me.Name & ".txt"
bAppend = True
strRecord = Me.Name & " SSCheck1 = " & Me.SSCheck1.Value & " " & App.EXEName & " " & App.Major & "." & Format(App.Minor, "00") & "." & Format(App.Revision, "0000")
iFileOutputNumber = OpenFileOutput(strOutfile, bAppend)
WriteFileOutput iFileOutputNumber, strRecord
CloseFileOutput iFileOutputNumber
'Re:Bonnie West +vvvvvvvvvvvvvvvvvvvvv
Set m_picIcon = Nothing
Controls.Remove pbID
If m_hIcon Then
DestroyIcon m_hIcon
DestroyIcon SendMessageW(hWnd, WM_SETICON, ICON_BIG, 0&)
DestroyIcon SendMessageW(hWnd, WM_SETICON, ICON_SMALL, 0&)
End If
'Re:Bonnie West +^^^^^^^^^^^^^^^^^^^^^
End Sub
This is the Main_zThreeD.bas file:
Code:
Private Type InitCommonControlsExStruct
lngSize As Long
lngICC As Long
End Type
Private Declare Function InitCommonControls Lib "comctl32" () As Long
Private Declare Function LoadLibrary Lib "kernel32.dll" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32.dll" (ByVal hLibModule As Long) As Long
Private Declare Function InitCommonControlsEx Lib "comctl32.dll" (iccex As InitCommonControlsExStruct) As Boolean
Private Sub Main()
Dim iccex As InitCommonControlsExStruct, hMod As Long
Const ICC_ALL_CLASSES As Long = &HFDFF& ' combination of all known values
' constant descriptions: http://msdn.microsoft.com/en-us/library/bb775507%28VS.85%29.aspx
With iccex
.lngSize = LenB(iccex)
.lngICC = ICC_ALL_CLASSES ' you really should customize this value from the available constants
End With
On Error Resume Next ' error? Requires IEv3 or above
hMod = LoadLibrary("shell32.dll")
InitCommonControlsEx iccex
If Err Then
InitCommonControls ' try Win9x version
Err.Clear
End If
On Error GoTo 0
'... show your main form next (i.e., Form1.Show)
frmThreeD.Show
If hMod Then FreeLibrary hMod
'** Tip 1: Avoid using VB Frames when applying XP/Vista themes
' In place of VB Frames, use pictureboxes instead.
'** Tip 2: Avoid using Graphical Style property of buttons, checkboxes and option buttons
' Doing so will prevent them from being themed.
End Sub
'Sub Main()
' frmThreeD.Show
'End Sub
This is the Module1.bas file from Bonnie West:
Code:
Option Explicit
Public Const WINDOWS_ICON As Integer = 1
Public Const CHROME_ICON As Integer = 2
Public Const HALF As Single = 0.5!
Public Const ICON_JUMBO As Long = 256
Public Const ICON_BIG As Long = 1
Public Const ICON_SMALL As Long = 0
Public Const WM_SETICON As Long = &H80
Public Enum E_DrawIconEx_Flags
DI_MASK = &H1
DI_IMAGE = &H2
DI_NORMAL = &H3
DI_COMPAT = &H4
DI_DEFAULTSIZE = &H8
DI_NOMIRROR = &H10
End Enum
#If False Then
Dim DI_MASK, DI_IMAGE, DI_NORMAL, DI_COMPAT, DI_DEFAULTSIZE, DI_NOMIRROR
#End If
Public Enum E_GetWindowLong_Index
GWL_USERDATA = (-21&)
GWL_EXSTYLE = (-20&)
GWL_STYLE = (-16&)
GWL_ID = (-12&)
GWL_HWNDPARENT = (-8&)
GWL_HINSTANCE = (-6&)
GWL_WNDPROC = (-4&)
End Enum
#If False Then
Dim GWL_USERDATA, GWL_EXSTYLE, GWL_STYLE, GWL_ID, GWL_HWNDPARENT, GWL_HINSTANCE, GWL_WNDPROC
#End If
Public Enum E_LoadImage_Type
IMAGE_BITMAP = 0
IMAGE_ICON = 1
IMAGE_CURSOR = 2
End Enum
#If False Then
Dim IMAGE_BITMAP, IMAGE_ICON, IMAGE_CURSOR
#End If
Public Enum E_LoadImage_fuLoad
LR_DEFAULTCOLOR = &H0
LR_MONOCHROME = &H1
LR_LOADFROMFILE = &H10
LR_LOADTRANSPARENT = &H20
LR_DEFAULTSIZE = &H40
LR_VGACOLOR = &H80
LR_LOADMAP3DCOLORS = &H1000
LR_CREATEDIBSECTION = &H2000
LR_SHARED = &H8000&
End Enum
#If False Then
Dim LR_DEFAULTCOLOR, LR_MONOCHROME, LR_LOADFROMFILE, LR_LOADTRANSPARENT, _
LR_DEFAULTSIZE, LR_VGACOLOR, LR_LOADMAP3DCOLORS, LR_CREATEDIBSECTION, LR_SHARED
#End If
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Declare Function AdjustWindowRectEx Lib "user32.dll" ( _
ByRef lpRect As RECT, _
ByVal dwStyle As Long, _
ByVal bMenu As Long, _
ByVal dwExStyle As Long _
) As Long
Public Declare Function DrawIconEx Lib "user32.dll" ( _
ByVal hDC As Long, _
ByVal xLeft As Long, _
ByVal yTop As Long, _
ByVal hIcon As Long, _
Optional ByVal cxWidth As Long, _
Optional ByVal cyWidth As Long, _
Optional ByVal istepIfAniCur As Long, _
Optional ByVal hbrFlickerFreeDraw As Long, _
Optional ByVal diFlags As E_DrawIconEx_Flags = DI_NORMAL _
) As Long
Public Declare Function GetWindowLongW Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByVal nIndex As E_GetWindowLong_Index _
) As Long
Public Declare Function LoadImageW Lib "user32.dll" ( _
ByVal hInst As Long, _
ByVal lpszName As Long, _
Optional ByVal uType As E_LoadImage_Type = IMAGE_BITMAP, _
Optional ByVal cxDesired As Long, _
Optional ByVal cyDesired As Long, _
Optional ByVal fuLoad As E_LoadImage_fuLoad = LR_DEFAULTCOLOR _
) As Long
Public Declare Function SendMessageW Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long _
) As Long
'Private Sub Main()
' MsgBox "Don't forget to set ""windows_perfection_logo_v2_d-bliss.ico"" as Form1's Icon!" & _
' vbNewLine & "(Set it via the Properties Window)", vbInformation
' Form1.Show
' Form2.Show
'End Sub
Missing, of course, is the .res file and the dependency files
Here is an image of the form in use:
Attachment 151725
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Quote:
Originally Posted by
si_the_geek
I have removed your attachment to protect our members, because we have no way of knowing what an executable file actually does - which could include something malicious, such as if there is a virus on your computer.
In addition to that, a compiled program (as opposed to code/pictures/etc) generally does nothing towards helping us to assist you.
Should I, somehow include the .res resource file?
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
I doubt it would be useful, but if somebody asks to see it you could put it in a zip file and attach that.
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
And yet another test:
Omitted STDOLE2.tlb from manifest and dependencies
Bonnie West's code adds an image of the icon to the center of the form:
256x256 - 24, 48x48 - 24, 32x32 - 24, 16x16 - 24
48x48 - 8, 32x32 - 8, 16x16 - 8
32x32 - 4, 16x16 - 4
On my Development Host windows 7 (x64) PC, zThreeD.exe works:
Icon does appear on zThreeD.exe main form title bar and center of form.
Icon does appear on zThreeD.exe desktop shortcut (after screen Refresh).
Icon does appear in zThreeD.exe shortcut properties.
Icon does appear on zThreeD.exe.
Icon does appear in zThreeD.exe properties.
On my test windows 10 (x64) PC, zThreeD.exe works:
Icon does appear on zThreeD.exe main form title bar and center of form.
Old Icon does appear on zThreeD.exe desktop shortcut (Unaffected by Refresh or reboot?).
- - - (This behavior with the Desktop Shortcut icon seems to resolve itself or can be 'fixed' by uninstall > reboot > install)
Icon does appear in zThreeD.exe shortcut properties.
Icon does appear on zThreeD.exe.
Icon does appear in zThreeD.exe properties.
On my wife's windows 7 (x64) PC, zThreeD.exe installs but does not work: Error 481 - Invalid picture
* Icon does NOT appear on zThreeD.exe main form title bar: Error 481 - Invalid picture
Icon does appear on zThreeD.exe desktop shortcut.
Icon does appear in zThreeD.exe shortcut properties.
Icon does appear on zThreeD.exe.
Icon does appear in zThreeD.exe properties.
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
The test results, above, are the same with all of my tiny test apps (zNoOCX, zRichTx, zThreeD and zMSComct)
The zNoOCX installation package no longer contains stdole2.tlb any other dependency files.
I simply copied (from my PC via the USB memory stick) the zNoOCX.exe file to my wife's windows 7 (x64) PC into a D:\Program Files (x86)\Clark_Anderson\zNoOCX folder and ran it:
IT WORKS!
Doggonit, that was a fluke: every thing works in my wife's logon??
Even Administrator logon does not make everything work?? This work/not work in other logons includes the 'copied' zNoOCX.exe file. I may have to take this puzzle back to the NSIS forum or...?
Thank you, Spooman for the instructions...
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Anderci
Congrats.
Lord knows this has been quite the exercise .. ;)
May I make the following suggestion .. mark the thread as RESOLVED.
To do so
- Look just above your 1st post
- Click the Thread Tools button
- Click the Mark as Resolved option
Spoo
-
Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
My guess, at this point, is the 'Error 481 - Invalid picture' was an unusual symptom response to security issues??
I certainly would like a better understanding of this. Does my NSIS installation script need adjusting for it?
-
Re: [RESOLVED] Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
very old thread, but maybe somebody still alive here...
@anderci, in post #42, I do not understand how do you able to solve the issue... so, all you did is just removed stdole2.tlb dependency?
I have this very rare error "Error 481 - Invalid picture" on Windows 11.
I don't have a constant access to that machine to do convenient tests.
Tried to include 24bit images in my ico file, which is loaded in "Icon" form's property. Without success.
Are there tools, allowing to re-order images in ico-file? (tried IcoFX, but it seems does not have such an option)
-
Re: [RESOLVED] Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
GreenFish Icon Editor Pro works for me.
https://www.vbforums.com/images/ieimages/2023/11/13.png
Typically, I save my form icons as 48x48x32 and all my apps work well from 32bit win7 to win11 64bit, I often have a hidden form that is assigned a larger 64x64x32 icon that gives the overall project its icon.
https://www.vbforums.com/images/ieimages/2023/11/14.png
I do ensure that the icon images do not contain multiple icons.
-
Re: [RESOLVED] Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
yereverluvinuncleber, you can't be sure. The error is really very rare. Like 1 of 300 machines, maybe more.
Thanks for suggestion to use GreenFish. It support re-order by drag & drop. It was one of suggestions in this thread to re-order images such as 24-bit images to be on top, it doesn't hurt to try.
As about 256x256 support, I'm usually using IconChanger by anny05 to patch exe by inserting 256x. However, in above case with "Error 481" it isn't used.
-
Re: [RESOLVED] Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
When I previously used multiple icons I had to re-order them to ensure the correct one was used but I now try to avoid any complication so I just use single icons in one ico file with just one size. I get round the need for a bigger icon by assigning it to that hidden form. I think I have used a 128x 128 with some success but I generally use 64x64.
Previously, I had an issue with a previously working icon not operating on Win 10 ( 50003 Error) with the desktop DPI scaled to a figure such as 125% or 175%. Using the 48x 48 icon size seemed to fix that.
-
Re: [RESOLVED] Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Figured out the reason of a such error.
In my case looks like a bug in Windows.
In short: contents of the icon doesn't matter*. The problem is in modified %TEMP%
As you perhaps know(?), if you include your own icon file as a form's "Icon" property, VB runtime calls OleLoadPictureEx() which then firstly write icon on disk in the TEMP folder returned by GetTempPathW().
So, if system has no access to that folder (e.g. missing or permissions issue), or has incorrect %TEMP% environment variable or so, you'll receive "Invalid picture" on app start. Sometimes I saw altered record in the registry - instead of REG_EXPAND_SZ, "Temp" value have a type of REG_SZ preventing the data "%USERPROFILE%\AppData\Local\Temp" from normal expanding.
Well, why I called it a bug. In my case, the problem was deeper.
There is a weird behaviour in Windows where it can assign custom TEMP value overriding current variable by volatile environment variable when you connect to machine via RDP session. So, the final %TEMP% will look like this: %USERPROFILE%\AppData\Local\Temp\2
where the folder "Temp\2" does not exist and does not create automatically by Windows.
Behaviour may be disabled by GPO, as described here.
So, there is a solution: check does %TEMP% exist and accessible.
As automatic solution:
1. You may not use form's "Icon" property at all and load icon manually (by code).
Or
2. You may start app from Main() or load from hidden form having no icon, then check if %TEMP% folder exists (and accessible for write access), if no, create it or modify %TEMP% to point to the correct location. Then, you may safely load other forms having custom ico file in its "Icon" form's property.
*well, there is surely some rules about icon creation, like the presence of 24bit images (of some sizes - sorry, don't remember exactly) which is essential for some unpatched XP.
Here is a minimal set what always worked for me in all OS versions:
32x32 (24 bit)
16x16 (24 bit)
48x48 (32 bit)
32x32 (32 bit)
16x16 (32 bit)
+ 256x256 (32 bit), this one is inserted by patching the exe file (required for good look only).
-
Re: [RESOLVED] Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Another consequence of OleLoadPictureEx persisting to %TEMP% is that main form will fail loading when there is not enough disk space free.
Seen this in the wild w/ our apps so always starting from Sub Main and Load-ing main form inside error handler so cryptic errors can be translated to something human-readable so end users can take action on their own w/o support calls.
cheers,
</wqw>
-
Re: [RESOLVED] Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
That's not good. Is your cause/resolution very different from the others in this thread? Hoping it does not get lost. Worth its own thread? Just a thought.
re: the icon files
32x32 (24 bit)
16x16 (24 bit)
48x48 (32 bit)
32x32 (32 bit)
16x16 (32 bit)
Is your typical icon file a multi icon file with the icons in this order?
-
Re: [RESOLVED] Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Quote:
Originally Posted by
Dragokas
2. You may start app from Main() or load from hidden form having no icon, then check if %TEMP% folder exists (and accessible for write access), if no, create it or modify %TEMP% to point to the correct location. Then, you may safely load other forms having custom ico file in its "Icon" form's property.
When you have some sample code, please provide and I may steal it to use it!
-
Re: [RESOLVED] Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Quote:
Originally Posted by
yereverluvinuncleber
Is your typical icon file a multi icon file with the icons in this order?
I'm using for years this minimal sequence (no complaints as of now among various configs), resource hacker show it goes in such order:
Code:
32x32 (24 bit) - index 1
16x16 (24 bit) - index 2
256x256 (32 bit) - index 3
48x48 (32 bit) - index 4
32x32 (32 bit) - index 5
16x16 (32 bit) - index 6
My .ico loaded in form is the same, but without 256x256.
Then, I'm inserting 256x256 with modified Icon Exe Patcher by anny05, also I'm removing default icons with indices 30001-3000x.
However, for common simple usage, it's enough just to use .ico loaded in form without doing lot of above stuff.
Quote:
Originally Posted by
yereverluvinuncleber
When you have some sample code, please provide and I may steal it to use it!
Well, again that's not something I like to do in simple and trivial way.
For general usage, it's enough to just apply directory exist check => CreateDirectory + SetEnvironmentVariable if that's damaged.
However, I'm doing much more, with access check and unlock.
If you like to see, here is full code, executed on Main() before any form get loaded. If unresolved issues with %temp% found, app just display message explaining the cause to user.
-
Re: [RESOLVED] Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
I know this sounds strange but I have had this error when running vb6 apps on modern versions of windows without ADMIN priv. I never got to the bottom of it as my main project runs on our boxes so admin priv is not an issue.
As a test can you run your app with admin priv?
-
Re: [RESOLVED] Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
vbwins, that may indicate your app had not enough access permissions to the temp folder or its DACL is modified.
I have no problem in running VB6 apps with non-elevated context or through the user of 'users' group e.g. on Win11.
The simplest solution may be just redirect icon unpacking from temp to own app folder:
Code:
Private Declare Function SetEnvironmentVariable Lib "kernel32" Alias "SetEnvironmentVariableW" (ByVal lpName As Long, ByVal lpValue As Long) As Long
Public Sub Main()
SetEnvironmentVariable StrPtr("TMP"), StrPtr(App.Path)
Form1.Show vbModeless
End Sub
If you zip and provide here a minimum project with this issue which possible to be reproduced, we can look.
P.S. And yeah, in above explanations I did a mistake, OleLoadPictureEx => GetTempPathW => is looking for %TMP%, not %Temp%.
-
Re: [RESOLVED] Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
Quote:
Originally Posted by MSDN
The GetTempPath function checks for the existence of environment variables in the following order and uses the first path found:
- The path specified by the TMP environment variable.
- The path specified by the TEMP environment variable.
- The path specified by the USERPROFILE environment variable.
- The Windows directory.
The last bullet perhaps means C:\WINDOWS\Temp (if exists) most probably.
cheers,
</wqw>
-
Re: [RESOLVED] Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II
wqweto, nice to know, good addition!
I also remembered some users complained about user context %TMP% pointing to C:\WINDOWS\Temp (quick googled example).
Potentially, that may be vbwins' issue.
However, if we see the default permission (win11), technically non-admin users aren't restricted from write access: screen
Out of curiosity, I just replaced TMP/Temp with C:\WINDOWS\Temp and icon successfully unpacked there running as non-admin user app.
It does even remove ~icon file, regardless the "Delete" permission is not granted in DACL, hmm.
Although, permissions set on that folder may differ in various OS builds.