Solved

Create a transpartent icon with hdc

Posted on 2004-03-25
7
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
7 Comments
 
LVL 28

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 28

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month6 days, 6 hours left to enroll

627 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