Wrox Programmer Forums
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 22nd, 2004, 05:07 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default Custom Icon

Hello,

I'm trying to create a custom bitmap for the icon of a windows control, so that when the control is added to the toolbox, it will appear with this new bitmap. What I was told was the image needs to be 16-bit, and be 16x16. I named the control Estimator.vb, and the 16 bit, 16x16 bitmap is named Estimated.bmp. They both are in the same directory, but it's not taking it. When I compile the project, it won't use it; uses standard gear.

I couldn't get this to work in 1.1/2003, and I can't get it to work in 2/2005. Any ideas?

Thanks,

Brian
__________________
Brian
 
Old October 15th, 2004, 09:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Hi Brian,

I don't know if you have found the solution yet, and I haven't used 2005, but here is how you can do it in 2003.

Add a reference to the System.Drawing.dll in project explorer if it isn't already there. Use the Imports statement at the top of your code to add a reference to System.Drawing.

Change the name of your bitmap to the name of your class (NameOfClass.bmp). Change it's "Build Action" property to "Embedded Resource".

Add this line immediately before your class declaration:

<ToolboxBitmap(GetType(NameOfClass))> _

Don't forget to use the line continuation character.

Build the control. You should now have your image on the toolbar.

J
 
Old October 15th, 2004, 10:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

I was using the other constructor by providing the name to the file but it isn't "pulling it in" so to speak. It still uses the old icon. It's 16 color, 16x16 which is the requirements that I found.

I'll try that.

Brian
 
Old October 15th, 2004, 11:05 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Still nothing.

Brian
 
Old October 15th, 2004, 12:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Did you change it to a bitmap? If you want to send me the project, I can take a look at it.

Actually, it would probably be better if you just duplicated the changing of the icon in a 2003 project and sent that because I don't have 2005 installed. It should only take you a minute or so to do it.

J
 
Old October 15th, 2004, 12:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

16 x 16 bitmap.
 
Old October 15th, 2004, 01:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

And did you remove it from the toolbar and re-add it? Sorry if it seems like I am asking the obvious, but I am not really sure why you are having so much trouble.

J
 
Old October 29th, 2004, 01:45 PM
Registered User
 
Join Date: Oct 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm having exactly the same problem. The only way that I've been able to make it work is to use a string that contains the full path name. That's not the way I wanted to do it, but it worked.

 
Old May 11th, 2005, 01:50 AM
Authorized User
 
Join Date: May 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

maybe you can just rename the extension to *.ico
 
Old May 11th, 2005, 07:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I think it's supposed to be a bitmap, though I gave up on this anyway.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Server Control....Custom Property Editor ZArrinPour ASP.NET 1.0 and 1.1 Basics 1 June 15th, 2010 11:30 AM
Web Service, Custom Control, Custom Return Type robzyc ASP.NET 2.0 Basics 6 June 10th, 2008 08:03 AM
First Post! adding an icon to a custom user form Banquo_ws Excel VBA 2 March 6th, 2007 04:36 AM
CREATEING ICON ashraf Java GUI 1 November 30th, 2004 05:50 PM
Custom Icon for ASP.NET Control bmains ASP.NET 2.0 Basics 0 September 22nd, 2004 05:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.