Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Invalid Picture When Assigning An Icon

hi, i tried to assign an icon in my form... at first i was able to load some "flat icons" those with 2 colors or less and it worked but now i want assign better looking icons to my app and i get an error message that says: invalid picture... why? it's still the same .ico file! is it because of the size format of the color?

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
[Rizzolved] Assigning Imagelist Icon To Listview Item - Invalid Key?
The listview has an imagelist assigned to it's smallicon property. I load the listview with an icon of a folder. OK great. Now I need to change said icon if a condition is met.

I assign the first image by index:

oListview.ListItems.Add , oTable.Name, oTable.Name, , iIcon ' iIcon=5

Now when I go to change it, I tried:

Set oLVItem = lvSprocs.SelectedItem
oLVItem.SmallIcon = imgListviews.ListImages(5)


Set oLVItem = lvSprocs.SelectedItem
oLVItem.SmallIcon = imgListviews.ListImages("Green_Flag")

And with both, I get error 35603 - Invalid Key

I don't see how this should be an issue... "Green_Flag" is indeed the Key, and 5 is the index.


Dave Applegate
Microsoft VB MVP, ACE [FAQs]
My friend has a trophy wife, but apparently she wasn't in first place.

Edited by - Metallisoft on 10/12/2006 3:53:09 PM

Icon = Invalid Picture?

I have a 64x64 .ico file. It was saved specifically as a .ico file but VB tells me "Invalid picture". Why is that?


Invalid Icon Picture??
I was making a form that I wanted to have an icon different then the default VB 6.0 icon. I have a valid .ico picture that a friend made and I tried to use it and it said it was an "invalid picture". Is there a proper way of setting an icon for a form that I don't know about?

Invalid Picture In Icon
Hi to all:

I had try to insert a icon in a form made by articons format 48*48,and I got a message:"Invalid Picture".

Something wrong with the format of the icon,or something limitation by VB??


Invalid Picture When Adding Icon

I am trying to add an icon to my form and each time I try it I get a error saying "Invalid Picture". The Icon is a valid .ico file (Not just renamed to .ico or anything like that).

Please help!



Assigning An Icon To A .EXE File

I am sure this question has been asked many times in the past but I my search in the forum didnít return the result I was hoping for.

Anyway, what I am interested to know is how to assign or even change the little pretty pictures assigned to the executable files on my desktop. How do I say, assign an icon to one of my VB executables? And what format/size/type should the icon be?

Thanks to all your potential replies in advance!

Assigning An Icon To A Project?
How do i pick the Icon my exe is going to use if i have no forms in the project to choose an icon from?

Assigning An Icon With An Extension
hi there,

first post, be gentle :-)

I was wondering whether it is possible to tell windows to associate an icon with a file with two extensions.

our program creates a 'filename.evi.jar'

is it possible to assicate an icon with all files with this double extension programatically, i suspect not, but hope you can

many thanks


Assigning Icon To Program File.
I am new to VB6 and need a bit of help. I had a simple program made for me. In the program you can alter images, add different effects etc. When you are done working with a picture, you can save the project to your hard drive. In my case, when you save a project to your hard drive, the programmer made it so the file is saved with an .epc extension. Since the .epc extension is one the programmer made up windows does not recongnise it and therefor e, assigns it the icon that windows does when it does not the file type. What I would like to do is have a specific icon assigned to the .epc file type but don't know how to do it. I will be distributing the program to all members in my class and I would like the assigned icon to appear on all computers. Can anyone explain how I would assign a custom icon to my .epc file type in VB?
I hope that made sense.

Assigning An Icon To Your Executable File
How do you assign an icon to an executable file?

Assigning An Icon To Certain File Types?
Many programs give their own icon to certain file types in windows when you install them. As an example of this: When you install Microsoft Word itís that programs icon that is used for files with the *.doc format. Can anybody tell me how I can do this with VB? I have a feeling itís going to be an API call but because Iím not sure Iíve posted in the general section of this forum. Thanks

Assigning A Mouse Icon To An Object During Runtime?
Can you assign a mouseicon to an object at runtime? Say for instance a ListBox? And how would you then unassign a mouseicon during runtime? For instance the mouseicon I want to assign and unassign to my object is c:lock.ico.



Shortcuts - Assigning Icon To New Shortcut(.lnk) Problem. *Not Resolved*
Hey everyone, i got a problem with assigning an icon to a new shorcut,
it woks when assining an icon from an exe file as next;

.IconLocation = WSHShell.ExpandEnvironmentStrings(TargetPath & "" & TargetName & ".exe, 0")

but i want to assign a custom icon that i get from;
1 - a picturebox, or,
2 - directly from out a Icon Library (.dll)

i tried a few things like next as i get my icon from the dll to the picbox;
.IconLocation = WSHShell.ExpandEnvironmentStrings(Form1.Picture1.Picture)
.IconLocation = Form1.Picture1.Picture

how do i do this?

Here's the reference of a part of the project:

Form Code:
Private Sub Command1_Click()
   IconLibrary 0
   ShortcutSpecLoc "DoDesktop", "c:TestFolder", "TestApp", ".exe", ""
   ShortcutSpecLoc "DoStartMenu", "c:TestFolder", "TestApp", ".exe", ""
End Sub

Module Code:
'Create Shortcuts - Special Locations (Desktop & StartMenu)

Public DirectoryNew As String

Public Sub ShortcutSpecLoc(DTorSM As String, TargetPath As String, TargetName As String, TargetExtension As String, TargetIcon As String)

   Set WSHShell = CreateObject("WScript.Shell")
   Dim NewShortcut
   Dim DTorSMpath
   Select Case DTorSM
          Case "DoDesktop"
               DTorSMpath = WSHShell.SpecialFolders("Desktop")
               DTorSMpath = DTorSMpath & ""
          Case "DoStartMenu"
               DTorSMpath = WSHShell.SpecialFolders("StartMenu")
               DirectoryNew = DTorSMpath & "Programs" & TargetName & ""
               DirectoryCreate '(Funtion To Create New Directory is Not Showing Here)
               DTorSMpath = DirectoryNew
   End Select

   Set NewShortcut = WSHShell.CreateShortcut(DTorSMpath & TargetName & ".lnk")
       With NewShortcut
            .TargetPath = WSHShell.ExpandEnvironmentStrings(TargetPath & "" & TargetName & TargetExtension)
           '.Arguments = WSHShell.ExpandEnvironmentStrings("")
            .WorkingDirectory = WSHShell.ExpandEnvironmentStrings(TargetPath)
            .WindowStyle = 4
'Here is were to assign the custom icon;
            .IconLocation = WSHShell.ExpandEnvironmentStrings(TargetPath & "" & TargetName & ".exe, 0")
       End With

End Sub

Public Sub IconLibrary(IconNumber As String)

   Dim IcoLib As ClassIcoLib
   Set IcoLib = New ClassIcoLib
   Select Case IconNumber
          Case 0
               Form1.Picture1.Picture = IcoLib.GetIcon(0) 'icon for exe Shortcut
          Case 1
               Form1.Picture1.Picture = IcoLib.GetIcon(1)
          Case 2
               Form1.Picture1.Picture = IcoLib.GetIcon(2)
          Case 3
               Form1.Picture1.Picture = IcoLib.GetIcon(3)
   End Select
End Sub


btw, i know it works if i use this;

.IconLocation = WSHShell.ExpandEnvironmentStrings("c:myicon.ico")

but i don't want to include icon files near the application, so this option doesn't solve my problem to.

aka Red2048.

Edited by - T48 - [RedPlanet] on 3/5/2004 1:40:28 AM

Assigning Icon To Custom File Extension Created Using My Program
I had a program created in VB6. This program produces files with an extension of *.xpc. Since this is a custom file type that my program produces, when the file is saved to the harddrive, it is an unknown filetype according to Windows so it is assigned the default Icon Windows uses when it does not know the file type. I would like this to look more professional and would like to use my custom Icon for the .xpc filetype my program creates. I do not need to know how to assign the icon to the programs .exe, I need to assign an icon to the .xpc file type and have it show up on ALL users computers. I do not know how to do this in VB6. Can anyone explain the method in detail? I am pretty new to VB.

Assigning A Picture On A Button
Hi all!

I am new to embedded visual basic, I am juz wondering if any of you can tell me how to put a picture on a button. Your help will be very much appreciated.


Assigning Scroll Bars To A Picture Box.
Basically I want to load an image from file into a picture box and keep the picture box at the same size, but be able to scroll around the image using scroll bars.

I have tried using two scroll bar controls for this, but I can't seem to get it working how I would like.

Anyone got a decent method or tips on how I can do this?


Assigning A Picture To An Image Object.
I was wondering if it was possible for an image object to obtain it's "picture" (property) from an ImageList instead of an external file?

I have around 4 picture for one Image control and would like to know if it's possible to include the 4 image files in the VB project without having 4 external files following it around like a lost puppy?

+--VB Dot Net
+-- Navman GPS Forums @

Assigning An Imagebox Picture Using A Database Field
I am writing a basic members system and for organisation and reporting issues, I am storing member photos in the access database itself(not just links to filenames)

If someone searches for a member, the system populates a range of textbox controls with relevant member info, and I want it to load the photo stored in the database to an image box control on screen. However you don't seem to beable to use the load picture method in this way e.g. image1.picture loadpicture(adomembers.recordset.fields!Photo) you end up getting a file/path error.

Anyone provide any assistance



Icon: Invalid Property Value?
For a long time I've been wanting to get rid of the annoying VB default icon that always appears on my programs and as the default icon the finished .exe. When I hit the "..." on the icon property of the only form in the program, and choose my 32x32 icon, after I click the 'open' button it refuses the file saying that its an 'invalid property value'. I tried 24-bit, 256 colors, and 16 colors, but the same thing happens. So how am I supposed to get the icon on both the upper-left and the finished .exe?

Invalid Picture
is there a cleaner way to determine if a picture is valid or not other than using the Err object (meaning I want to prevent the Err from ever happening)

I guess I would want a ValidPicture() function that returns true or false or something like that.

Also - it can't just check for the file's existence because some pictures that are loaded are incomplete and give the invalid picture error 481 when i use the LoadPicture() function.

Invalid Picture
Hello reader,

I made a vb application and for the finishing touch I found a really nice icon. But when I want to use this item in the icon property I get the error message "Invalid picture". The icon has got the .ico extension, when I use a picture with a bmp or jpg extension I get the same message. I use vb6 and try to use xp icons, maybee this is the problem??


Invalid Picture
I suppose to put a picture in my form but it give a Invalid Picture error.

Why is that?

Invalid Picture

I am developing one app which needs inbuild FTP support, so i am now developing an FTP Explorer. Everything is done except displaying file's default icons ( i.e. icons displayed in Windows Explorer). I am using the following code to extract the file's default icon

VB Code:
Option Explicit 'For looking at registry keys 'To: Open key ready to look at Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long 'To: Look at key Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As Any, lpcbData As Long) As Long 'To: Close the key when it's finished with Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long  Private Const HKEY_CLASSES_ROOT = &H80000000 Private Const KEY_READ = &H20019 'To allow us to READ the registry keys  'For Drawing the icon 'To: Retrieve the icon from the .EXE, .DLL or .ICO Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long   'To: Draw the icon into our picture box  Private Declare Function DrawIcon Lib "user32.dll" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal hIcon As Long) As Long 'To: Clean up after our selves (destroy the icon that "ExtractIcon" created) Private Declare Function DestroyIcon Lib "user32.dll" (ByVal hIcon As Long) As Long  'For Finding the System folder Private Declare Function GetSystemDirectory Lib "kernel32.dll" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long  Private Sub GetDefaultIcon(FileName As String, Picture_hDC As Long )     Dim TempFileName As String 'Never manipulate an input unless it doubles as an output     Dim lngError As Long 'For receiving error numbers     Dim lngRegKeyHandle As Long 'Stores the "handle" of the registry key that is currently open     Dim strProgramName As String 'Stores the contents of the first registry key     Dim strDefaultIcon As String 'Stores the contents of the second registry key       Dim lngStringLength As Long 'Sets / Returns the length of the output string       Dim lngIconNumber As Long 'Stores the icon number within a file      Dim lngIcon As Long 'Stores the "Icon Handle" for the default icon       Dim intN As Integer 'For any temporary numbers       TempFileName = Right(FileName, Len(FileName) - InStrRev(FileName, ".") + 1)       If LCase(TempFileName) = ".exe" Then           strDefaultIcon = Space(260)          lngStringLength = GetSystemDirectory(strDefaultIcon, 260)          strDefaultIcon = Left(strDefaultIcon, lngStringLength) & "SHELL32.DLL"          lngIconNumber = 2          GoTo Draw_Icon      End If        lngError = RegOpenKey(HKEY_CLASSES_ROOT, TempFileName, lngRegKeyHandle)      If lngError Then GoTo No_Icon 'we do not even have a valid extension so lets NOT try to find an icon!       lngStringLength = 260      strProgramName = Space$(260) 'Make space for the incoming string       'Get the key value:       lngError = RegQueryValueEx(lngRegKeyHandle, vbNullString, 0, 0, strProgramName, lngStringLength)      If lngError Then 'if there's an error then BIG TROUBLE so lets use the normal "windows" icon           lngError = RegCloseKey(lngRegKeyHandle) 'the world may be about to end (or just an error) but we'll clean up anyway           GoTo No_Icon      End If       lngError = RegCloseKey(lngRegKeyHandle) 'if this generates an error then we can't do anything about it anyway     strProgramName = Left(strProgramName, lngStringLength - 1) 'Cut the name down to size       'Use the value of the last key in the name of the next one (strProgramName)       lngError = RegOpenKey(HKEY_CLASSES_ROOT, strProgramName & "DefaultIcon", lngRegKeyHandle)      If lngError Then GoTo No_Icon 'there is no icon for this extension so lets NOT try to load what doesn't exist!       'The rest is just the same as before       lngStringLength = 260      strDefaultIcon = Space$(260)      lngError = RegQueryValueEx(lngRegKeyHandle, vbNullString, 0, 0, strDefaultIcon, lngStringLength)      If lngError Then           lngError = RegCloseKey(lngRegKeyHandle)          GoTo No_Icon      End If       lngError = RegCloseKey(lngRegKeyHandle)      strDefaultIcon = Trim$(Left(strDefaultIcon, lngStringLength - 1))       intN = InStrRev(strDefaultIcon, ",") 'Find the commer       If intN < 1 Then GoTo No_Icon 'We MUST have an icon number and it will be after the ",": NO COMMA NO DEFAULT ICON      lngIconNumber = Trim$(Right(strDefaultIcon, Len(strDefaultIcon) - intN)) 'What number is after the comma       strDefaultIcon = Trim$(Left(strDefaultIcon, intN - 1)) 'We only want what's before the comma in the file name    Draw_Icon:      lngIcon = ExtractIcon(App.hInstance, strDefaultIcon, lngIconNumber) 'Extract the Icon       If lngIcon = 1 Or lngIcon = 0 Then GoTo No_Icon 'if 1 or 0 then after all that the Icon Could not be retrieved        lngError = DrawIcon(Picture_hDC, 0, 0, lngIcon) 'Draw the icon in the box      'If that was unsucessful then we can't do anything about it now!       lngError = DestroyIcon(lngIcon)      'Again we can't correct any errors now       Exit Sub No_Icon:      'No icon could be found so we use the normal windows icon      'This icon is held in shell32.dll in the system directory, Icon 0       strDefaultIcon = Space(260)      lngStringLength = GetSystemDirectory(strDefaultIcon, 260)      strDefaultIcon = Left(strDefaultIcon, lngStringLength) & "SHELL32.DLL"      lngIconNumber = 0      GoTo Draw_Icon End Sub

Hereís how to use this subroutine (remember that picture box's ďAutoRedrawĒ property is set to True!:

This subroutine displays icon in the picture box but when i try to add this icon in the Imagelist control it gives the error 'Invalid Picture' ( I am using Treeview & Listview to display folders and files so i am trying add icons to imagelist)

Please help

Invalid Picture...?
I have a little vb program that uses the ImgEdit control. Every once in a while the program will load and display 'Invalid Picture' and bomb out. Any idea what causes this and how to fix it?


Invalid Picture
I get an error message "invalid picture" when I try to insert an icon on
a form or a picture in a picture box
Chilangisha B Changwe

-- - IMAP accessible web-mail

Invalid Picture
I'm using this code to create an image file from the data in SQL Server:
Dim RS As ADODB.Recordset
Dim mstream As ADODB.Stream
Set RS = New ADODB.Recordset
RS.Open "Select HighLogo from CompanyData WHere CompanyID = " & lngCompanyID, objConn, adOpenKeyset, adLockOptimistic

Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Write RS.Fields("HighLogo").Value

mstream.SaveToFile "c:publogo.bmp", adSaveCreateOverWrite
I get an error "Invalid Picture"

File is created, but I cannot open it with Paint or Photoshop.
I link to the table in SQL Server from Access (I don't know any other way to see the picture in SQL Server field) and I can see the image there. So, SQL Server contains an image.
I tried to insert different format images into the table (BMP, JPG, GIF). All of them I can see via Access.
But when I retrieve the image and save as a disk file (tried with different extentions too), the file cannot be opened.

What's wrong?
Thank you

Invalid Picture - Error 481

I'm trying to print a picture with two charts in it.
But when I try to print the picture I get and error: invalid picture error 481
I can't seem to find an answer in the forum
I have AutoRedraw set to true

Her's my code:
Private Sub cmdPreview_Click()
Dim obj As Object
Set obj = Printer

obj.Orientation = vbPRORLandscape

obj.PaintPicture Me.pctChart.Picture, pctChart.Left, pctChart.Top

End SubI'm I doing something wrong?
Is there property settings to change?

Thanks in Advance

Invalid Picture With ImageBox
I have a .jpg file that cannot be loaded with the ImageBox Control in VB (I get a "Invalid Picture" error). The file loads fine in MSPaint. If i open the .jpg file in MSPaint and save it again as Blah.jpg, the ImageBox will now let me load it in VB.

Is there a way to fix this without having to open it in MSPaint and saving it again as a .jpg file?

The only thing I think is happening is VB6.0 is old and this type of .jpg file is newer and it's not supported. Is there any way around this?

ImageList ... Invalid Picture!!!!!
How come i get the Error... Invalid Picture, when adding an Image to the Image List??? I tried everything

Run Time Error 481- Invalid Picture
Hello All,

Our Netowrk admin denied access to the C: drive and since then the users get run time error 481- invalid picture while running a VB applications. Any ideas on how to resolve this. Our Network admin is adamant on not giving Access to the servers C: drive

Picture(Icon) -&gt; Picture(Bitmap) How?
How do I convert a Picture object containing an Icon (from a file) to a Picture object containg a Bitmap with a certain color (pink!) for the transparent portions of the icon?

I have gotten to the point where I have a HBITMAP but how do I create a Picture object that encapsulates this handle?


Picture Box Object Returns An Invalid Point Value
I need a help about a picture box object. The object is parameterized as shown below (paste & copy from imediate window).

Although, returns the call below -1:
Picspec.Point(test, 10)
for test = -56,01186

The object returns for any coordinates the same value: -1.

Please, help!
Thanks in advance.

?Picspec.Point(test, 10)

Invalid Picture When Image Not Selected In File List Box
When I click through the directory and file list boxes and find an image, it displays in an imagebox I have setup.

But if I click anything other than an image it comes up the error 'Invalid picture' how can I put in a message box saying 'not an image' instead of this VB error?

My code is: -

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub File1_Click()
Image1.Picture = LoadPicture(File1.Path & "" & File1.FileName)
End Sub

Picture Box To Icon
I am working on a program that i would like to have a dynamic systray icon.
i have the systray part working i can make the image in a picturebox. the only thing i cant seem to do is out put the file to a .ico file. I looked at planet source code and found an icon editor but was unable to understand the code at all.

can any one point me to a small guide or some good info?

Thank you

Icon - Picture

I would like to know how i can put a picture as the icon of a compiled program.
Ive heard that i have to put a picture in the "Icon" properties menu (.ico) in the form that the program starts off with.
Is this the way to go about the problem? If so how do i do it...cause i tried inserting a picture that i created in Paint , by saving it as a 16 colour file and it still doesnt work.

Thanks for your help!

Icon - Picture

I would like to know how i can put a picture as the icon of a compiled program.
Ive heard that i have to put a picture in the "Icon" properties menu (.ico) in the form that the program starts off with.
Is this the way to go about the problem? If so how do i do it...cause i tried inserting a picture that i created in Paint , by saving it as a 16 colour file and it still doesnt work.

Thanks for your help!

In the Form at the top, where you are suppose to have a image, how can I change this image to my own custom image?-thanks

Checking If A Picture Is An Icon

As is the theme of my posts tonight, I'm making a class module which adds/modifies/removes icons in the system tray. It is all working very well but there are a couple of nagging things which I'd really like to clear up, one of which is this:

One of the properties of my class is the Icon property where I pass an icon in a variable of type STDPicture:

Property Let TrayIcon(picIcon as STDPicture)
'now some gubbins to place picIcon in the system tray
End Property

How would I check that picIcon is always an icon, and not a Bitmap or GIF etc...? You see, I know to always pass an icon but potentially there could be other coders who get to use my class who may not know. Is there a specific ICON variable type or is there a
TypeOf(picIcon) = vbIcon
sort of thing?

Listview Icon Or Picture
I'm currently trying to make a listview during runtime that adds in values, etc. I want the first item to be an icon or picture based on what it is and I can't seem to find a way to get a column to have an icon at all. I've tried just about everything I can think of. Can someone help me out?

One of my failed attempts to give you a better idea of what I mean.
Set itmListItem = ListView1.ListItems.Add(, , "")
itmListItem.SubItems(1) = ""
itmListItem.SubItems(2) = strFrom
itmListItem.SubItems(3) = strSubject
itmListItem.SubItems(4) = strTime
ListView1.ListItems.Item(lngIndex).key = strFilePointer
ListView1.ListItems.Item(1).Icon = imgList.ListImages(3).Picture
What i'm trying to do is something like Outlook does when you have an unread mail it shows the little envelope and after you read it it goes away. Thanks in advance.

How Do I Make My Own Icon Out Of A Picture?
I have a little picture I want to use for my program but how do I make it an Icon file? I have photoshop and that isn't one of the extention.

Convert Picture To Icon
How do I convert a picture in a picturebox to an icon type without using the imagelist control. I want a function like the extract icon function on the imagelist control.


Editing An Icon Picture
How do you edit an Icon Picture? With what program can you use?

ListView, Icon And A Picture
I have an icon in a picturebox and want it as the icon in a listview. i have tried using ImageLists but i got nowhere. ANy help?

Icon Picture Questions
Is is possible to add a picture of an icon beside the menu editor? Let say I have "Help" as one of my caption in the menu editor and want to add a picture icon of a "?" infront of it, can I do that?

Creating An Icon From An Existing Picture
I dont know how to create an Icon, (picture.ico, picture.cur)
from an existing picture.

Can anybody help?

Every help appreciated


Change .exe Program Icon Picture
may i know how to change my .exe program image(appearance? i dun want it to appear as a form, i had a global picture and wish to make my .exe program icon with the picture

How To Change Setup Icon(picture)
Hi everyone

I wanted to make setup of my application. I got it but i want to change the setup icon(picture) . it gives by default as like our vb form. I want to change that icon to new my selected icon(picture)

Please help me how to do so?

waiting for reply.

Thanx and regards,

How Can I Set A Dinamic Picture In The Form's Icon ??
How can I set a dinamic picture in the form's Icon ??

This is the test code I'm trying to do this:

VB Code:
Option Explicit Private Sub Form_Load()    Picture1.AutoRedraw = True        Timer1.Interval = 10    Timer2.Interval = 1000        Me.ScaleMode = vbPixels    Picture1.ScaleMode = vbPixels        Picture1.Move 0, 0, 16, 16End Sub Private Sub Timer1_Timer()    Picture1.Line (16 * Rnd, 16 * Rnd)-(16 * Rnd, 16 * Rnd), RGB(255 * Rnd, 255 * Rnd, 255 * Rnd)End Sub Private Sub Timer2_Timer()    Set Picture1.Picture = Picture1.Image        Set Me.Icon = Picture1.Picture  ' < - I get error hereEnd Sub

How Can I Put This Icon In Image (image1.picture)?
I can get icon for any filse whit this code and draw that on form.
How I can put that icon in Image (image1.picture)?

VB Code:
'Create a new project, and add this code to Form1Const DI_MASK = &H1Const DI_IMAGE = &H2Const DI_NORMAL = DI_MASK Or DI_IMAGEPrivate Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias "ExtractAssociatedIconA" (ByVal hInst As Long, ByVal lpIconPath As String, lpiIcon As Long) As LongPrivate Declare Function DrawIconEx Lib "user32" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As LongPrivate Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As LongPrivate Sub Form_Paint()    'KPD-Team 1999    'URL: [url][/url]    'E-Mail: [email][/email]    Dim mIcon As Long    'Extract the associated icon    mIcon = ExtractAssociatedIcon(App.hInstance, "C:Program FilesMSN Messengerlicense.rtf", 2)    'Draw the icon on the form    DrawIconEx Me.hdc, 0, 0, mIcon, 0, 0, 0, 0, DI_NORMAL    'remove the icon from the memory    DestroyIcon mIcon    End Sub


Copyright © 2005-08, All rights reserved