Page 1 of 2 12 LastLast
Results 1 to 40 of 57

Thread: [RESOLVED] Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    Resolved [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.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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).

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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.NoOCX.zip

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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
    Last edited by anderci; Sep 8th, 2017 at 01:37 PM.

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    868

    Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II

    Quote Originally Posted by anderci View Post
    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.NoOCX.zip
    I know this (timeout) is a "side" issue, but let's spend a moment on it ..

    What browser are you using?
    • IE
    • Chrome
    • Other


    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,

    Name:  autosave1.jpg
Views: 9327
Size:  17.5 KB

    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

  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #10

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II

    Quote Originally Posted by Spooman View Post
    I know this (timeout) is a "side" issue, but let's spend a moment on it ..

    What browser are you using?
    • IE
    • Chrome
    • Other



    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]

  11. #11

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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
    NoOCX2484.zip
    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
    Last edited by anderci; Sep 8th, 2017 at 04:54 PM.

  12. #12
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  13. #13

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II

    Quote Originally Posted by LaVolpe View Post
    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

  14. #14
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  15. #15

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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

    NoOCX48-1624-4.zip

    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
    Last edited by anderci; Sep 8th, 2017 at 05:54 PM.

  16. #16
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  17. #17

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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

  18. #18
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  19. #19

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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
    Last edited by anderci; Sep 8th, 2017 at 10:00 PM.

  20. #20

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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.
    Last edited by anderci; Sep 10th, 2017 at 05:17 PM.

  21. #21

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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?
    Last edited by si_the_geek; Sep 13th, 2017 at 01:39 PM.

  22. #22
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    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.

  23. #23

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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
    Last edited by anderci; Sep 11th, 2017 at 09:34 AM.

  24. #24
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    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.

  25. #25
    gibra
    Guest

    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

  26. #26

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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?

  27. #27

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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?
    Last edited by anderci; Sep 11th, 2017 at 02:41 PM.

  28. #28

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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!

  29. #29
    gibra
    Guest

    Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II

    I've tested in a 'clean' OS (both 64 bit).

  30. #30

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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)
    Last edited by si_the_geek; Sep 12th, 2017 at 05:29 PM.

  31. #31
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II

    There is an attachment in post #6
    256x256 Icons.rar.zip (253.3 KB, 1202 views)

  32. #32
    gibra
    Guest

    Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II

    Quote Originally Posted by anderci View Post
    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.
    Last edited by si_the_geek; Sep 12th, 2017 at 05:30 PM.

  33. #33

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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, ...
    Last edited by anderci; Sep 12th, 2017 at 10:00 AM.

  34. #34

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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.

  35. #35

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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.

  36. #36
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II

    Quote Originally Posted by anderci View Post
    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.

  37. #37

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    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
    Last edited by anderci; Sep 12th, 2017 at 06:01 PM.

  38. #38

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II

    Quote Originally Posted by si_the_geek View Post
    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?

  39. #39
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    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.

  40. #40

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    99

    Re: Error 481 - Invalid picture in compiled exe (vb6 sp6) in Win7 II

    Thank you.

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width