Solved

Holes in Windows - How do I do it?

Posted on 1998-10-20
3
213 Views
Last Modified: 2010-04-30
This is the second of my really dumb questions:

I would like to make holes in my forms such that the
desktop can be seen through them. You know, like some one
shot holes through the form.
Or, perhaps it could be made to look as if the form
is rotting away and you can see through some of it.

It should show whatever is behind the form (other windows,
the desktop, whatever).

Is there any way to make holes in forms?
0
Comment
Question by:jgore
3 Comments
 
LVL 14

Accepted Solution

by:
waty earned 100 total points
Comment Utility
You have several possibilities, one of them is creating some "transparent hole" in your form, adapt the code below, to make "hole", and not take the whole form.
One other, is making you form completely transparent, and draw on it some picture (not transparent). I have a sample doing that. I can send it to you (if you give me your e-mail)
BTW, here is the code to make a form transparent

' *** Make form transparent
Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Public Const RGN_AND = 1
Public Const RGN_COPY = 5
Public Const RGN_DIFF = 4
Public Const RGN_OR = 2
Public Const RGN_XOR = 3

Public Sub MakeFormTransparent(frm As Control)
   ' *** Make a form transparent
   
   Dim rctClient As RECT, rctFrame As RECT
   Dim hClient As Long, hFrame As Long
   
   ' *** Grab client area and frame area
   GetWindowRect frm.hwnd, rctFrame
   GetClientRect frm.hwnd, rctClient
   
   ' *** Convert client coordinates to screen coordinates
   Dim lpTL As POINTAPI, lpBR As POINTAPI
   lpTL.x = rctFrame.Left
   lpTL.y = rctFrame.Top
   lpBR.x = rctFrame.Right
   lpBR.y = rctFrame.Bottom
   ScreenToClient frm.hwnd, lpTL
   ScreenToClient frm.hwnd, lpBR
   rctFrame.Left = lpTL.x
   rctFrame.Top = lpTL.y
   rctFrame.Right = lpBR.x
   rctFrame.Bottom = lpBR.y
   rctClient.Left = Abs(rctFrame.Left)
   rctClient.Top = Abs(rctFrame.Top)
   rctClient.Right = rctClient.Right + Abs(rctFrame.Left)
   rctClient.Bottom = rctClient.Bottom + Abs(rctFrame.Top)
   rctFrame.Right = rctFrame.Right + Abs(rctFrame.Left)
   rctFrame.Bottom = rctFrame.Bottom + Abs(rctFrame.Top)
   rctFrame.Top = 0
   rctFrame.Left = 0
   
   ' *** Convert RECT structures to region handles
   hClient = CreateRectRgn(rctClient.Left, rctClient.Top, rctClient.Right, rctClient.Bottom)
   hFrame = CreateRectRgn(rctFrame.Left, rctFrame.Top, rctFrame.Right, rctFrame.Bottom)
   
   ' *** Create the new "Transparent" region
   CombineRgn hFrame, hClient, hFrame, RGN_XOR
   
   ' *** Now lock the window's area to this created region
   SetWindowRgn frm.hwnd, hFrame, True

End Sub

0
 

Author Comment

by:jgore
Comment Utility
Thanks Waty!

My e-mail is jgore@ticnet.com if got anything else to send me.
Your other code for crooked windows works great also!
Whatever their paying you.....it's not enough!
0
 

Expert Comment

by:AlexV
Comment Utility
This code works as it is, but it can be difficult to visualize and write the code to make the shape you want.  For a program which will do all this for you in a graphical environment, try http://www.comports.com/AlexV/VBSFC.html for details.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

771 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

11 Experts available now in Live!

Get 1:1 Help Now