|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Resource icon issueI have a resource file which contains one 16x16 icon. When I use
LoadResPicture (101, vbResIcon) the picture returned is 32x32. Any reason why, or how I can get it to default back to 16x16? Thanks guys - Kev "Kevin Provance" <ca***@tpasoft.com> wrote in message It would help tremendously if you told us HOW you were using this icon. For news:uvOwTp%23PGHA.3672@TK2MSFTNGP14.phx.gbl... >I have a resource file which contains one 16x16 icon. When I use >LoadResPicture (101, vbResIcon) the picture returned is 32x32. > > Any reason why, or how I can get it to default back to 16x16? example, are you adding it to an ImageList for use in a Treeview or ListView? If so, make sure the ImageList is set for 16x16 by setting its ImageHeight and ImageWidth properties before adding the icon. Personally, I don't think I'd bother with a resource file for ONE icon. Throw an Image or PictureBox control on a form and load the icon to that at design-time. The icon "resource" will still get compiled into your app and you can reference it via the control (for example, you may want to assign it to a StdPicture object, add it to an ImageList control, or whatever). If I'm not mistaken, VB "defaults" to 32x32 icons because downsizing is usually more accurate than upsizing. IOW, a better 16x16 icon can be produced from a 32x32 source than a 32x32 icon can be produced from a 16x16 source. -- Mike Microsoft MVP Visual Basic Sorry, I should have been more specific.
I am still working on my titlebar replacement ActiveX control. Event icon can be assigned to it (icons next to the control icons). When adding an icon, a "default" icon is assigned to it until the user specifies the icon. I am not using an image list because of the overhead involved. The ActiveX prop bag and a class module handle everything nicely. I added the default icon, a 16x16 16 color icon (the icon used for DOS programs) to a resource file as the default icon (I guess I could always use the system image list, for that, huh?) but like I said, it defaults to a 32x32 image, even tho the drawn icon is clipped at 16x16...it looks like a 32x32 icon cliped at 16x16. ::sigh:: So, would you think that adding a picture box to the control with the proper image would work just as well as a resouce file? I'm always hearing about the overhead a picture box adds to an ActiveX control and so far my control is all owner drawn. No controls. I think I will tinker with the system image list for a bit and see how that works out...otherwise please feel free to offer any advice you might have. Thanks Mike. - Kev Show quoteHide quote "MikeD" <nob***@nowhere.edu> wrote in message news:%230jjiIAQGHA.3192@TK2MSFTNGP09.phx.gbl... > > "Kevin Provance" <ca***@tpasoft.com> wrote in message > news:uvOwTp%23PGHA.3672@TK2MSFTNGP14.phx.gbl... >>I have a resource file which contains one 16x16 icon. When I use >>LoadResPicture (101, vbResIcon) the picture returned is 32x32. >> >> Any reason why, or how I can get it to default back to 16x16? > > > It would help tremendously if you told us HOW you were using this icon. > For example, are you adding it to an ImageList for use in a Treeview or > ListView? If so, make sure the ImageList is set for 16x16 by setting its > ImageHeight and ImageWidth properties before adding the icon. > > Personally, I don't think I'd bother with a resource file for ONE icon. > Throw an Image or PictureBox control on a form and load the icon to that > at design-time. The icon "resource" will still get compiled into your app > and you can reference it via the control (for example, you may want to > assign it to a StdPicture object, add it to an ImageList control, or > whatever). > > If I'm not mistaken, VB "defaults" to 32x32 icons because downsizing is > usually more accurate than upsizing. IOW, a better 16x16 icon can be > produced from a 32x32 source than a 32x32 icon can be produced from a > 16x16 source. > > -- > Mike > Microsoft MVP Visual Basic > >
Show quote
Hide quote
"Kevin Provance" <ca***@tpasoft.com> wrote in message I really couldn't tell you for sure. I'm hardly an expert on graphics. news:OGPiHUAQGHA.5856@TK2MSFTNGP10.phx.gbl... > Sorry, I should have been more specific. > > I am still working on my titlebar replacement ActiveX control. Event icon > can be assigned to it (icons next to the control icons). When adding an > icon, a "default" icon is assigned to it until the user specifies the > icon. I am not using an image list because of the overhead involved. The > ActiveX prop bag and a class module handle everything nicely. I added the > default icon, a 16x16 16 color icon (the icon used for DOS programs) to a > resource file as the default icon (I guess I could always use the system > image list, for that, huh?) but like I said, it defaults to a 32x32 image, > even tho the drawn icon is clipped at 16x16...it looks like a 32x32 icon > cliped at 16x16. ::sigh:: > > So, would you think that adding a picture box to the control with the > proper image would work just as well as a resouce file? I'm always > hearing about the overhead a picture box adds to an ActiveX control and so > far my control is all owner drawn. No controls. > > I think I will tinker with the system image list for a bit and see how > that works out...otherwise please feel free to offer any advice you might > have. > Hopefully, Mike D Sutton will see this and reply. I'm sure he can provide better insight and information than I can. -- Mike Microsoft MVP Visual Basic On Sat, 4 Mar 2006 22:29:34 -0500, "Kevin Provance"
<ca***@tpasoft.com> wrote: >Sorry, I should have been more specific. Yeah, that's been problem with VB or OLE (I'm not sure which) for as> >I am still working on my titlebar replacement ActiveX control. Event icon >can be assigned to it (icons next to the control icons). When adding an >icon, a "default" icon is assigned to it until the user specifies the icon. >I am not using an image list because of the overhead involved. The ActiveX >prop bag and a class module handle everything nicely. I added the default >icon, a 16x16 16 color icon (the icon used for DOS programs) to a resource >file as the default icon (I guess I could always use the system image list, >for that, huh?) but like I said, it defaults to a 32x32 image, even tho the >drawn icon is clipped at 16x16...it looks like a 32x32 icon cliped at 16x16. >::sigh:: long as I can remember. When I've encountered it usually go with Api methods directly, like LoadImage, DrawIcon. -Tom MVP - Visual Basic (please post replies to the newsgroup) Kevin Provance schrieb:
> I have a resource file which contains one 16x16 icon. When I use Solution:> LoadResPicture (101, vbResIcon) the picture returned is 32x32. > > Any reason why, or how I can get it to default back to 16x16? http://www.vb-hellfire.de/knowlib/usericons.php Thorsten Doerfler That works fine, but must be compiled, else hIcon is zero.
Also, HandleToPicture is in the download, but not on that page. Show quoteHide quote "Thorsten Doerfler" <t.doerfler_nospam@bdsw.de> wrote in message news:dueipb.3gc.1@news.bdsw.de... > Kevin Provance schrieb: > > I have a resource file which contains one 16x16 icon. When I use > > LoadResPicture (101, vbResIcon) the picture returned is 32x32. > > > > Any reason why, or how I can get it to default back to 16x16? > > Solution: > http://www.vb-hellfire.de/knowlib/usericons.php > > Thorsten Doerfler > -- > http://www.vb-hellfire.de/ Norm Cook schrieb:
>> http://www.vb-hellfire.de/knowlib/usericons.php Right. It's mentioned in the article but in german. Sorry.> That works fine, but must be compiled, else hIcon is zero. > Also, HandleToPicture is in the download, but not on that page. Follow the link 'GDI Handle im Picture Gewand' and you will get here:http://www.vb-hellfire.de/knowlib/handletopicture.php Thorsten Doerfler Not a problem, I can read German fairly well. :-)
- Kev Show quoteHide quote "Thorsten Doerfler" <t.doerfler_nospam@bdsw.de> wrote in message news:dufact.2qc.1@news.bdsw.de... > Norm Cook schrieb: >>> http://www.vb-hellfire.de/knowlib/usericons.php >> That works fine, but must be compiled, else hIcon is zero. > > Right. It's mentioned in the article but in german. Sorry. > >> Also, HandleToPicture is in the download, but not on that page. > > Follow the link 'GDI Handle im Picture Gewand' and you will get here: > http://www.vb-hellfire.de/knowlib/handletopicture.php > > Thorsten Doerfler > -- > http://www.vb-hellfire.de/ Thorston -
I decided to use the example you provided, which works perfectly. I modified the code a bit to work in and out of the IDE by compiling a "development" resource DLL that lets me use the same icons in the IDE as out. Thanks for the great code, I appreciate you telliong me about it. :-) - Kev Show quoteHide quote "Thorsten Doerfler" <t.doerfler_nospam@bdsw.de> wrote in message news:dueipb.3gc.1@news.bdsw.de... > Kevin Provance schrieb: >> I have a resource file which contains one 16x16 icon. When I use >> LoadResPicture (101, vbResIcon) the picture returned is 32x32. >> >> Any reason why, or how I can get it to default back to 16x16? > > Solution: > http://www.vb-hellfire.de/knowlib/usericons.php > > Thorsten Doerfler > -- > http://www.vb-hellfire.de/ "Kevin Provance" <ca***@tpasoft.com> wrote in message I've never used LoadResPicture myself and I don't know much about it, but I news:uvOwTp%23PGHA.3672@TK2MSFTNGP14.phx.gbl... > I have a resource file which contains one 16x16 icon. When > I use LoadResPicture (101, vbResIcon) the picture returned > is 32x32. Any reason why . . . notice that it doesn't allow you to specify which size icon you require if your icon file contains more than one size, as many do. Perhaps you might be better off doing what Tom Esh has suggested and use LoadImage instead. Here's a link I've just found to a class that was written to manage tray icons from VB, but it contains a module (Mpic.bas) that seems to wrap up the LoadImage API nicely so as to provide a simple alternative to LoadResPicture. You can simply pass it the resource file and the icon number and the desired icon size. It's worth checking out. The download you want from the link is CShellTrayIcon.cls http://www.vbinfozine.com/downloads.shtml Mike I picked that one up off Google last night. Thanks. :-)
- Kev Show quoteHide quote "Mike Williams" <M***@WhiskyAndCoke.com> wrote in message news:eTr%23DSEQGHA.2888@tk2msftngp13.phx.gbl... > "Kevin Provance" <ca***@tpasoft.com> wrote in message > news:uvOwTp%23PGHA.3672@TK2MSFTNGP14.phx.gbl... > >> I have a resource file which contains one 16x16 icon. When >> I use LoadResPicture (101, vbResIcon) the picture returned >> is 32x32. Any reason why . . . > > I've never used LoadResPicture myself and I don't know much about it, but > I notice that it doesn't allow you to specify which size icon you require > if your icon file contains more than one size, as many do. Perhaps you > might be better off doing what Tom Esh has suggested and use LoadImage > instead. Here's a link I've just found to a class that was written to > manage tray icons from VB, but it contains a module (Mpic.bas) that seems > to wrap up the LoadImage API nicely so as to provide a simple alternative > to LoadResPicture. You can simply pass it the resource file and the icon > number and the desired icon size. It's worth checking out. The download > you want from the link is CShellTrayIcon.cls > > http://www.vbinfozine.com/downloads.shtml > > Mike > > Kevin Provance wrote:
> I have a resource file which contains one 16x16 icon. When I use You might find this useful...> LoadResPicture (101, vbResIcon) the picture returned is 32x32. > > Any reason why, or how I can get it to default back to 16x16? Repair Distorted, Shrunken Icons http://vb.mvps.org/articles/ap199904.pdf |
|||||||||||||||||||||||