Solved

Holes in Windows - How do I do it?

Posted on 1998-10-20
3
217 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
ID: 1440902
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
ID: 1440903
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
ID: 1440904
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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 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…

837 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