Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Icon Chalange

Dim img As New Bitmap(PictureBox1.Image, 32, 32)
img.Save(RichTextBox2.Text & "\" & RichTextBox3.Text & ".ico",
System.Drawing.Imaging.ImageFormat.Bmp)
MsgBox("Image has been converted", MsgBoxStyle.Information, "Done!")

Hi all, I am using Visual Basic 2008. The above code saves
PictureBox1 image into 32 x 32 icon file. The only problem I am facing
that when I chose this icon file from the Properties of my Form as for
Form icon in Visual Basic 2008 I get error message saying "Argument
'picture' must be a picture that can be used as a Icon". If I use same
icon file from the Properties of Active X Control Button which is on
excel Sheet then it works fine. I think if a icon file which can work
on Visual Basic Form and as well as on Active X Control Button on an
excel Sheet is the perfect icon. i tried different methods by
searching on internet to create perfect 16 x 16 or 32 x 32 icon files
which have no lost of colour or quality but only whith above code i
get near to what i want to achive. But i cant use it for my Visual
Basic application Form. I have created icon with below code which
works everywhere but with below code you lose the quality and colors
of the icon. I also studied "IconLib" example which you can find on
internet but its to much for me. So i am kind of stuck. Is there any
friend out there to help me out with some code.

Dim pth As String = "C:\Document\test.gif"
Dim img As New Bitmap(pth)
Dim grh As Graphics = Graphics.FromImage(img)
grh.InterpolationMode =
Drawing2D.InterpolationMode.HighQualityBicubic
grh.DrawImage(img, 0, 0)
Dim Hicon As IntPtr = img.GetHicon
Dim newicon As Icon = System.Drawing.Icon.FromHandle(Hicon)
Dim fpth As New IO.FileStream("C\Document\test.ico",
IO.FileMode.Create)
newicon.Save(fpth)
newicon.Dispose()
MsgBox("Image has been converted", MsgBoxStyle.Information, "Done!")
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Icon Chalange

K wrote :
Dim img As New Bitmap(PictureBox1.Image, 32, 32)
img.Save(RichTextBox2.Text & "\" & RichTextBox3.Text & ".ico",
System.Drawing.Imaging.ImageFormat.Bmp)
MsgBox("Image has been converted", MsgBoxStyle.Information, "Done!")

Hi all, I am using Visual Basic 2008. The above code saves
PictureBox1 image into 32 x 32 icon file. The only problem I am facing
that when I chose this icon file from the Properties of my Form as for
Form icon in Visual Basic 2008 I get error message saying "Argument
'picture' must be a picture that can be used as a Icon". If I use same
icon file from the Properties of Active X Control Button which is on
excel Sheet then it works fine. I think if a icon file which can work
on Visual Basic Form and as well as on Active X Control Button on an
excel Sheet is the perfect icon. i tried different methods by
searching on internet to create perfect 16 x 16 or 32 x 32 icon files
which have no lost of colour or quality but only whith above code i
get near to what i want to achive. But i cant use it for my Visual
Basic application Form. I have created icon with below code which
works everywhere but with below code you lose the quality and colors
of the icon. I also studied "IconLib" example which you can find on
internet but its to much for me. So i am kind of stuck. Is there any
friend out there to help me out with some code.

Dim pth As String = "C:\Document\test.gif"
Dim img As New Bitmap(pth)
Dim grh As Graphics = Graphics.FromImage(img)
grh.InterpolationMode =
Drawing2D.InterpolationMode.HighQualityBicubic
grh.DrawImage(img, 0, 0)
Dim Hicon As IntPtr = img.GetHicon
Dim newicon As Icon = System.Drawing.Icon.FromHandle(Hicon)
Dim fpth As New IO.FileStream("C\Document\test.ico",
IO.FileMode.Create)
newicon.Save(fpth)
newicon.Dispose()
MsgBox("Image has been converted", MsgBoxStyle.Information, "Done!")


Changing the file extension to ".ico" doesn't make the BMP a valid
icon. You need a converter to convert images to icons.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Icon Sets - Display icon in one cell depending upon value in anoth Nolene Excel Worksheet Functions 2 February 26th 10 05:43 AM
Icon Type and Name when Insert File As Icon Joyce Excel Programming 2 October 2nd 09 05:25 PM
Icon on the top Marcelo Rychter[_2_] Excel Programming 1 June 3rd 06 01:47 PM
Chalange: Creating recursive tree from Excel List lenhardturs Excel Programming 0 October 28th 04 07:23 PM
Icon Robin Clay[_3_] Excel Programming 2 December 10th 03 09:36 AM


All times are GMT +1. The time now is 11:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"