Link to home
Start Free TrialLog in
Avatar of GuidoBartels
GuidoBartels

asked on

Create a transpartent icon with hdc

Here i create a icon, i have to set the background to the color white, otherwise it is black!

How can i set bytes or a transparent mode?

1. create an icon with an image hdc
2. set background white

The source code:

    Set m_cIcon_Form = New clsMemDC
    Call m_cIcon_Form.pCreate(16, 16)
    '**** weißen Hintergrund setzen ****
    Call ExtFloodFill(m_cIcon_Form.HDC, 0, 0, 255, 0)

    Call Draw_Picture(cst_Norm_16, _
                      m_cIcon_Form, _
                      par_Action, _
                      par_IconName, _
                      16, _
                      par_Enabled, _
                      par_TotalTag)

    Call GetBitmapBits(m_cIcon_Form.hBmp, bufsize, bitArray(0))
'    For i = 0 To bufSize
'        maskArray(i) = 0
'    Next i
    lkl_IconSmall_hWnd = CreateIcon(par_Form.hwnd, 16, 16, 1, fc_ColorDepth, maskArray(0), bitArray(0))
    Call SendMessageLong(par_Form.hwnd, WM_SETICON, ICON_SMALL, lkl_IconSmall_hWnd)

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Ark
Ark
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GuidoBartels
GuidoBartels

ASKER

Thanks,

but sorry, i don't want to use an ImageList and a PictureBox,
i think my question is clear!

I have a build painted Picture in a hdc and i want it transparent in the forms icon!

Guido
Hi
The mthod I posted is the easiest way to create icon from bmp picture. I donno what clsMemDC class,Draw_Picture function and other variables are. For API way of creating icon see http://www.vb-helper.com/HowTo/bmp2ico.zip
Ok, i check this code out,

am on holiday now, give you an answer later.

Guido