![]() |
Using CreatePicture to Set Form Icons in VB6 |
Post Reply ![]() |
Author | |
DDJJ ![]() Senior Member ![]() Joined: 13 December 2004 Status: Offline Points: 143 |
![]() ![]() ![]() ![]() ![]() 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.
|
|
![]() |
|
DDJJ ![]() Senior Member ![]() Joined: 13 December 2004 Status: Offline Points: 143 |
![]() ![]() ![]() ![]() ![]() |
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
![]() |
|
![]() |
|
younicke ![]() Senior Member ![]() ![]() Joined: 11 March 2005 Status: Offline Points: 107 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
DDJJ ![]() Senior Member ![]() Joined: 13 December 2004 Status: Offline Points: 143 |
![]() ![]() ![]() ![]() ![]() |
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
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |