Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Create a transpartent icon with hdc

Posted on 2004-03-25
7
Medium Priority
?
234 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 28

Accepted Solution

by:
Ark earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

971 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