windows GDI and creating an icon from bitmap

An application i'm currently working on is a 'system-tray' app. That is, it doesn't show a main window, only the tray icon and dialogs when the user chooses certain menu options on the icon.

The Problem:
I would like to be able to dynamically create an icon for the system tray based on certain states of the application. these states may be something like the number of loaded modules, and so creating a static icon resource for each state is not necessarily a viable option. I have the following code that will load a base bitmap resource and create an icon from it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
HICON CreateAppIcon( HINSTANCE hmod )
{
    // create a memory device context
    HDC memdc = ::CreateCompatibleDC( NULL );
    
    // create compatible bitmaps
    HBITMAP mask = ::CreateCompatibleBitmap( memdc, 32, 32 );
    HBITMAP bmp = ::LoadBitmap( hmod, MAKEINTRESOURCE(PIBMP) );
    
    // create the icon
    ICONINFO ii;
    ii.fIcon = TRUE;
    ii.hbmMask = mask;
    ii.hbmColor = bmp;
    HICON icon = ::CreateIconIndirect( &ii );
    
    // free resources
    ::DeleteDC( memdc );
    ::DeleteObject( mask );
    ::DeleteObject( bmp );
    
    // return the resulting icon
    return icon;
}


In that function, or another, I can select the loaded bitmap into the device context and draw onto it there... that's fine. My problem is that I would like to be able to use alpha channels in drawing in the bitmap. I have tried selecting the loaded bitmap into the device context and using AlphaBlend(), and TransparentBlt(), but once i show the icon in the system tray, it just shows up as a solid icon... no alpha. I have searched google and looked through many MSDN pages, but still haven't had any luck figuring out how to do this solely from a device context. Any help would be greatly appreciated!
Topic archived. No new replies allowed.