Print Page | Close Window

Using CreatePicture to Set Form Icons in VB6

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=5230
Printed Date: 30 April 2025 at 7:39am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Using CreatePicture to Set Form Icons in VB6
Posted By: DDJJ
Subject: Using CreatePicture to Set Form Icons in VB6
Date Posted: 05 October 2006 at 4:22pm
Anyboody here having any luck using the ImageManager to load form icons in VB6?  I'm using the following code without success (see picture below).
 
Dim i As ImageManagerIcon
Dim p As StdPicture
    
Set i = ImageManager1.Icons.GetImage(101, 16)
    
Set p = i.CreatePicture(xtpImageNormal)
    
Me.Icon = p
 
 
 
I assume the reason the transparent areas of the icon show up as black has something to do with VB6 limitations, correct?
 
Thanks.
 



Replies:
Posted By: DDJJ
Date Posted: 05 October 2006 at 5:40pm
Figured how to get it to work the first time I load the form, but it won't load the icon the second time I load the form (???), using the following:
 
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" ( _
      ByVal hWnd As Long, ByVal wMsg As Long, _
      ByVal wParam As Long, ByVal lParam As Long _
   ) As Long
 
 
Dim lIconHandle As Long
Dim lResult As Long
    
lIconHandle = frmMain.ImageManager2.Icons.GetImage(101, 16).Handle
        
lResult = SendMessageLong(Me.hWnd, WM_SETICON, ICON_SMALL, lIconHandle)
 
I guess you can say this is progress
 


Posted By: younicke
Date Posted: 08 October 2006 at 9:51am
hi!

i do this trick whenever i want to use alpha icons in my forms in vb6.

1. in my main form i use icons with 48x48 to 16x16 alpha icons and 48x48 to 16x16 256 colors.  just load the icon in the form and you will notice that the form will use the alpha icons. i do this so that when i compile my project i will have a bigger icon in the explorer using the tile view or the thumbnail view.

2. in my other forms i use icons with 16x16 alpha icon and 16x16 256 icon. again im just loading the icon in my form and the form will use the alpha icon.

hope this helps!

attached is a sample project and the icons used.

uploads/20061008_095038_alpha_icons_in_.zip - uploads/20061008_095038_alpha_icons_in_.zip


Posted By: DDJJ
Date Posted: 08 October 2006 at 11:31am
Thanks for your response, younicke.  I tried what you describe and it seems to work fine.
 
Your approach works great where the related form uses only one icon.  Out problem relates to a "multiple use" form we employ in our app.  It is used for many different types of messages and prompts, and we've been adding a different icon depending on the context of the message.
 
We were previously using a special toolbar created from a cj CommandBar as the title bar/control box of this multiple use form.  Changing the icon was a breeze.  Now we're thinking of changing this because we want to use a theme (office 2007) with our updated app, but don't like how the toolbar looks that comes with the theme.
 
One easy solution is to just add the cj CommandBar to the form, then set the EnableOffice2007Frame property to True.  This paints the themes title bar on our multiple use app (which we DO like), but we're having problems changing icons.
 
Using the SendMessageLong API (see earlier post above), we're able to get the correct icon to display the first time we open the form, but that same icon will not display the next time we open the form.  If, on the other hand, we open the form using a different icon, we will get the new icon, but again only the first time we open the form. ???
 
We're doing something wrong with our API call, but can't figure it out just yet.  I'm hoping someone reading this thread might have an idea.  If so, your help will be appreciated!
 
Dan



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net