Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Using CreatePicture to Set Form Icons in VB6
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Using CreatePicture to Set Form Icons in VB6

 Post Reply Post Reply
Author
Message
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post Topic: Using CreatePicture to Set Form Icons in VB6
    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.
 
Back to Top
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post 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
 
Back to Top
younicke View Drop Down
Senior Member
Senior Member
Avatar

Joined: 11 March 2005
Status: Offline
Points: 107
Post Options Post Options   Thanks (0) Thanks(0)   Quote younicke Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
DDJJ View Drop Down
Senior Member
Senior Member


Joined: 13 December 2004
Status: Offline
Points: 143
Post Options Post Options   Thanks (0) Thanks(0)   Quote DDJJ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.