Solved

Create a transpartent icon with hdc

Posted on 2004-03-25
7
228 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:GuidoBartels
  • 2
  • 2
7 Comments
 
LVL 27

Accepted Solution

by:
Ark earned 500 total points
ID: 10683029

Private Sub Form_Load()
    With ImageList1
         .ListImages.Clear
'========Optional===========
         .BackColor = vbWhite
         .ImageHeight = 16
         .ImageWidth = 16
         .MaskColor = vbBlack
         .UseMaskColor = True
'========================
'You can use any Picture object (Picture1.Picture,Picture1.Image etc.)
'Or use ImageList_ API functions with hBitmap
         .ListImages.Add , , LoadPicture("spiral.bmp")
         Set Icon = .ListImages(1).ExtractIcon
    End With
End Sub
0
 

Author Comment

by:GuidoBartels
ID: 10702174
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
0
 
LVL 27

Expert Comment

by:Ark
ID: 10709011
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
0
 

Author Comment

by:GuidoBartels
ID: 10714010
Ok, i check this code out,

am on holiday now, give you an answer later.

Guido
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question