473,756 Members | 2,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Icon to Image

Hi,
I have simple needs but I don't know how to implement it.
I have application that create Dynamic Button. I need to set the image
on this button, getting the icon from a form.

So pratically I need to convert dinamically a Form.Icon to
Button.Image runtime, but i don't know how.
Any help would be appreciated.

Many Thanks

Marco
Feb 28 '08 #1
4 5033
On Feb 28, 5:15 am, Marcolino <marco.pozzu... @gmail.comwrote :
Hi,
I have simple needs but I don't know how to implement it.
I have application that create Dynamic Button. I need to set the image
on this button, getting the icon from a form.

So pratically I need to convert dinamically a Form.Icon to
Button.Image runtime, but i don't know how.
Any help would be appreciated.

Many Thanks

Marco
Marco,
IIUC correctly you want to synronize form's icon to a button, you can
do this with the following:

' First save form's icon to somewhere (eg: C: drive)
Me.Icon.ToBitma p.Save("c:\icon .ico",
System.Drawing. Imaging.ImageFo rmat.Icon)

'Then call this icon image as button's image
Button1.Image = Button1.Image.F romFile("c:\ico n.ico")

'
-------------------------------------------------------------------------------

If you button is present and you want to create a new one on runtime:

'Set button properties as you wish (optional)
Me.Icon.ToBitma p.Save("c:\icon .ico",
System.Drawing. Imaging.ImageFo rmat.Icon)
Dim button As New Button
Me.Controls.Add (button)
button.Name = "button1"
button.Image = button.Image.Fr omFile("c:\icon .ico")

Hope this helps!
Feb 28 '08 #2
On Feb 28, 10:55 am, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
On Feb 28, 5:15 am, Marcolino <marco.pozzu... @gmail.comwrote :
Hi,
I have simple needs but I don't know how to implement it.
I have application that create Dynamic Button. I need to set the image
on this button, getting the icon from a form.
So pratically I need to convert dinamically a Form.Icon to
Button.Image runtime, but i don't know how.
Any help would be appreciated.
Many Thanks
Marco

Marco,
IIUC correctly you want to synronize form's icon to a button, you can
do this with the following:

' First save form's icon to somewhere (eg: C: drive)
Me.Icon.ToBitma p.Save("c:\icon .ico",
System.Drawing. Imaging.ImageFo rmat.Icon)

'Then call this icon image as button's image
Button1.Image = Button1.Image.F romFile("c:\ico n.ico")

'
-------------------------------------------------------------------------------

If you button is present and you want to create a new one on runtime:

'Set button properties as you wish (optional)
Me.Icon.ToBitma p.Save("c:\icon .ico",
System.Drawing. Imaging.ImageFo rmat.Icon)
Dim button As New Button
Me.Controls.Add (button)
button.Name = "button1"
button.Image = button.Image.Fr omFile("c:\icon .ico")

Hope this helps
Sorry, some grammer mistakes :-)
(I meant if your button is "not" present);

If i understood your issue correctly, you want to syncronize form's
icon to a button, you can
do this with the following:

' First save form's icon to somewhere (eg: C: drive)
Me.Icon.ToBitma p.Save("c:\icon .ico",
System.Drawing. Imaging.ImageFo rmat.Icon)

'Then call this icon image as button's image
Button1.Image = Button1.Image.F romFile("c:\ico n.ico")

'
-------------------------------------------------------------------------------

If your button is NOT present and you want to create a new one on
runtime:

'Set button properties as you wish (optional)
Me.Icon.ToBitma p.Save("c:\icon .ico",
System.Drawing. Imaging.ImageFo rmat.Icon)
Dim button As New Button
Me.Controls.Add (button)
button.Name = "button1"
button.Image = button.Image.Fr omFile("c:\icon .ico")

Hope this helps!
Feb 28 '08 #3
Marcolino schrieb:
I have simple needs but I don't know how to implement it.
I have application that create Dynamic Button. I need to set the image
on this button, getting the icon from a form.

So pratically I need to convert dinamically a Form.Icon to
Button.Image runtime, but i don't know how.
Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s _
) Handles Button1.Click
Using lIcon As New Icon(Me.Icon, 16, 16)
Button1.Image = lIcon.ToBitmap
End Using
End Sub

Thorsten Dörfler
--
Microsoft MVP Visual Basic

vb-hellfire visual basic faq | vb-hellfire - einfach anders
http://vb-faq.de/ | http://www.vb-hellfire.de/
Feb 28 '08 #4
On 28 Feb, 10:47, Thorsten Doerfler <t.doerfler_nos ...@bdsw.dewrot e:
Marcolino schrieb:
I have simple needs but I don't know how to implement it.
I have application that create Dynamic Button. I need to set the image
on this button, getting the icon from a form.
So pratically I need to convert dinamically a Form.Icon to
Button.Image runtime, but i don't know how.

* Private Sub Button1_Click(B yVal sender As System.Object, _
* * * * * * * * * * * * ByVal e As System.EventArg s _
* * * * * * * * * * * * * * * * ) Handles Button1.Click
* * Using lIcon As New Icon(Me.Icon, 16, 16)
* * * Button1.Image = lIcon.ToBitmap
* * End Using
* End Sub

Thorsten Dörfler
--
Microsoft MVP Visual Basic

vb-hellfire visual basic faq *| vb-hellfire - einfach andershttp://vb-faq.de/* * * * * * |http://www.vb-hellfire.de/
Thanks to all, it works.
Bye

Marco
Feb 29 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
63189
by: arenaTR | last post by:
I'd like to put a logo in the titlebar of my webpage. The one I'm talking about is the one that's next to the URL in the address bar in both netscape and IE. Just so I'm clear, for example, on google's pages, next to the url in the address bar, there is their logo of a blue "G" in a box. Does anyone know how to do this? Thank you in advance.
3
3437
by: Hai Ly Hoang [MT00KSTN] | last post by:
I have written an WindowApplication (in C# with VS7) . It target file is MyApp.exe. It's default icon (display in Windows Explorer) is not pretty. I replaced file app.ico in project directory with my icon. However, the default icon is not changed . Can anyone help me to change the icon of my appication. Thanks in advance
1
2065
by: jack xu | last post by:
just like outlook when you insert a attachment ,a icon image of the file you selected will show in a textbox. Thanks.
0
1311
by: - HAL9000 | last post by:
Reference the visual basic power pack: http://msdn.microsoft.com/library/en-us/dv_vstechart/html/vbpowerpack.asp I have been using win32 SHGetFileInfoW to get icons for my "FileViewer" & "FolderViewer" as is done in the power pack code. What is unusual is that the icons are much darker than normal. You can see this in the folder icons of figure 7 on the web page - sort of a black lining.
6
11007
by: Udi | last post by:
Hi, I have an imagelist initialized in design time with several icons files (.ico). However, when I need to extract an icon (Image) from the Imagelist, I can't convert it back to an icon: statusBarPanel1.Icon = imageList1.Images; // cast/as don't work // Cannot convert type 'System.Drawing.Image' to 'System.Drawing.Icon' What am I mising here?
7
1767
by: ozzy66 | last post by:
Heya NG, I've got a little confusing configuration scenario: I've created a simple windows form in c# with Visual Studio 2003.NET and simultaneously with VS 2005. I've designed an Icon as well in both Studios and attached it to the forms via the properties window. I've changed the project properties as well and set the icon as application icon. By the way the icon is
1
18026
by: flaerpen | last post by:
Hi, I'm trying to use the function paste() to paste a image into another image but I can't get it work! Is it the right function to use or is there any other function that's better? Here's my very simple code: from PIL import Image import ImageDraw im = Image.new("RGB", (500,500), "white") draw = ImageDraw.Draw(im)
1
4936
by: =?Utf-8?B?QWRhbQ==?= | last post by:
I'm having a problem loading an Icon into an ImageList. When I load the icon directly it works fine, like this: Icon sourceIcon = << Get an icon from somewhere... >>; treeViewImageList.Images.Add("abc", sourceIcon); But when I first save the original icon to a stream and then try loading the
1
2594
by: John | last post by:
I have a switchboard and wish to add an image to the buttons via the switchboard table. I have added an extra column in the switchboard table with the names of embedded ico images corresponding to each item and was hoping to read these and add the image on to transparent buttons along with the switchboard text items next to the buttons at runtime. The switchboard form has the ico images embedded elsewhere on the form to avoid having to...
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.