Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Making white area's of Bitmaps see-through

Posted on 1998-12-09
3
Medium Priority
?
175 Views
Last Modified: 2010-05-03
Is it possible to make the white parts of a bitmap (or other image) see through, so that I can see things behind them. Is it possible with the standard controls in Visual Basic 5, or is a new control needed?
0
Comment
Question by:Tree120998
[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
3 Comments
 
LVL 2

Accepted Solution

by:
kswinney earned 150 total points
ID: 1449027
You can do this with a combination of several lengthy API calls.

If you have access to the owner's area of the Visual Basic site at microsoft.com, there's a sample called "pnttools" which shows exactly how to do what you're after.

If you don't have access to the site, I can send you the sample (if you're a registered user of VB).

Cheers!

0
 
LVL 14

Expert Comment

by:waty
ID: 1449028
Here is a complete sample :

' #VBIDEUtils#************************************************************
' * Programmer Name  : Thomas Detoux
' * Web Site         : http://www.vbasic.org/
' * E-Mail           : Detoux@hol.Fr
' * Date             : 8/12/98
' * Time             : 14:41
' * Module Name      : WingWang_Module
' * Module Filename  : YingYang.bas
' **********************************************************************
' * Comments         : CREATION DE FEUILLES EN FORME DE YING ET DE YANG
' *  Sample of call
' *    Call YingYang(Me)
' *
' *
' **********************************************************************

Option Explicit

'Créé une region en forme de rectangle entre les points (X1,Y1) et (X2,Y2)
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

'Créé une région en forme d'éllipse entre les points (X1,Y1) et (X2,Y2)
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

'Combine deux régions pour en créer unr troisième selon le mode nCombineMode
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long

'Supprime un objet et libère de la mémoire
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long

'Créé une feuille ayant la forme d'une région
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long

'Constantes pour CombineRgn
Private Const RGN_AND = 1        'Intersection des deux régions
Private Const RGN_OR = 2         'Addition des deux régions
Private Const RGN_XOR = 3        'Difficile à décrire ... essayez
'En fait, c'est un XOR : l'addition des 2 régions
'en retirant les parties communes aux 2 régions
Private Const RGN_DIFF = 4       'Soustraction de la région 2 à la région 1
Private Const RGN_COPY = 5       'Copie la région 1

Private YY As Long

Public Sub YingYang(obj As Form)
   
   'Déclaration des différents "handles" des différentes "régions" de la feuille, qui, réunies, formeront le Ying Yang
   Dim Cercle        As Long
   Dim Rect          As Long
   Dim PCercleH      As Long
   Dim PCercleB      As Long
   Dim HCercle       As Long
   Dim Cadre         As Long
   Dim TrouB         As Long
   Dim TrouH         As Long
   Dim CercleBis     As Long
   Dim HCercleBis    As Long
   Dim CercleBisBis  As Long
   Dim Ying_Yang     As Long
   Dim YYang         As Long
   
   Dim H             As Long
   Dim L             As Long
   Dim HBord         As Long
   Dim LBord         As Long
   Dim HT            As Long
   Dim LT            As Long
   
   H = obj.Height / Screen.TwipsPerPixelY
   L = obj.Width / Screen.TwipsPerPixelX
   
   HBord = Int(H / 100)
   LBord = Int(L / 100)
   
   HT = Int(H / 10)
   LT = Int(L / 10)
   
   'Création des différentes "régions", et combinaisons entre elles
   'Attention : pour réaliser une combinaison, la variable-région de destination
   'doit déjà avoir été intialisée en lui affectant une région auparavant.
   
   HCercle = CreateEllipticRgn(((L - (2 * LBord)) / 4) + LBord, ((H - (2 * HBord)) / 2) + HBord, 3 * (((L - (2 * LBord)) / 4) + LBord), (H - HBord))
   Cercle = CreateEllipticRgn(LBord, HBord, L - LBord, H - HBord)
   Rect = CreateRectRgn(L / 2, 0, L, H)
   CombineRgn HCercle, Cercle, Rect, RGN_DIFF
   
   HCercleBis = CreateEllipticRgn(LBord, HBord, L - LBord, H - HBord)
   PCercleB = CreateEllipticRgn(((L - (2 * LBord)) / 4) + LBord, ((H - (2 * HBord)) / 2) + HBord, 3 * (((L - (2 * LBord)) / 4) + LBord), (H - HBord))
   CombineRgn HCercleBis, HCercle, PCercleB, RGN_DIFF
   
   CercleBis = CreateEllipticRgn(LBord, HBord, L - LBord, H - HBord)
   PCercleH = CreateEllipticRgn(((L - (2 * LBord)) / 4) + LBord, HBord, 3 * (((L - (2 * LBord)) / 4) + LBord), ((H - (2 * HBord)) / 2) + HBord)
   CombineRgn CercleBis, Cercle, PCercleH, RGN_DIFF
   
   CercleBisBis = CreateEllipticRgn(LBord, HBord, L - LBord, H - HBord)
   HCercle = CreateEllipticRgn(0, 0, L, H)
   CombineRgn CercleBisBis, CercleBis, HCercleBis, RGN_DIFF
   
   Ying_Yang = CreateEllipticRgn(0, 0, L, H)
   Cadre = CreateEllipticRgn(0, 0, L, H)
   CombineRgn Ying_Yang, Cadre, CercleBisBis, RGN_DIFF
   
   YYang = CreateEllipticRgn(0, 0, L, H)
   TrouB = CreateEllipticRgn(((L - (2 * LBord)) / 2) + LBord - (LT / 2), ((3 * (H - (2 * HBord)) / 4)) + HBord - (HT / 2), ((L - (2 * LBord)) / 2) + LBord + (LT / 2), ((3 * (H - (2 * HBord)) / 4)) + HBord + (HT / 2))
   CombineRgn YYang, Ying_Yang, TrouB, RGN_OR
   
   YY = CreateEllipticRgn(0, 0, L, H)
   TrouH = CreateEllipticRgn(((L - (2 * LBord)) / 2) + LBord - (LT / 2), ((H - (2 * HBord)) / 4) + HBord - (HT / 2), ((L - (2 * LBord)) / 2) + LBord + (LT / 2), ((H - (2 * HBord)) / 4) + HBord + (HT / 2))
   CombineRgn YY, YYang, TrouH, RGN_DIFF
   
   SetWindowRgn obj.hwnd, YY, True 'Applique la région finale à la feuille
   
   'Suppression des régions
   DeleteObject Cercle
   DeleteObject Rect
   DeleteObject PCercleH
   DeleteObject PCercleB
   DeleteObject HCercle
   DeleteObject Cadre
   DeleteObject TrouB
   DeleteObject TrouH
   DeleteObject CercleBis
   DeleteObject HCercleBis
   DeleteObject CercleBisBis
   DeleteObject Ying_Yang
   DeleteObject YYang

End Sub

0
 
LVL 14

Expert Comment

by:waty
ID: 1449029
Did you tried my solution?
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…
Suggested Courses

618 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