Solved

Create a transpartent icon with hdc

Posted on 2004-03-25
7
226 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
Comment Utility

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
Comment Utility
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
Comment Utility
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
Comment Utility
Ok, i check this code out,

am on holiday now, give you an answer later.

Guido
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now