Advertisement
2002C Windows API Call/ Explanation #8965

SetTransparent

This code makes the form Tranparent but keep the OBJECTS visible. Orignally Written by Kalani COM Modified by Satin Katiyar

AI

Résumé par IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Code source
original-source
Public Sub SetTransparent(frm As Form, obj() As Object)
 'This code was takin from a AOL Visual Basic
 'Message Board. It was submited by: SOOPRcow
 'Modified By Satin Katiyar
 Dim rctClient As RECT, rctFrame As RECT
 Dim hClient As Long, hFrame As Long, hObj As Long
 Dim Start As Integer, Finish As Integer, I As Integer
 
 '// 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)
 '//Set the Scale mode of form to pixels
 Dim mode As Integer
 mode = frm.ScaleMode
 frm.ScaleMode = 3
 '// Create the new "Transparent" boundry & Add the control regions to it
 CombineRgn hFrame, hClient, hFrame, RGN_XOR
 Start = LBound(obj)
 Finish = UBound(obj)
 For I = Start To Finish
 hObj = CreateRectRgn(obj(I).Left + 4, obj(I).Top + 23, obj(I).Left + obj(I).Width + 4, obj(I).Top + obj(I).Height + 23)
 CombineRgn hFrame, hObj, hFrame, RGN_OR
 Next
 '// Now lock the window's area to this created region
 SetWindowRgn frm.hWnd, hFrame, True
 '//Restores the scale mode
 frm.ScaleMode = mode
End Sub
Commentaires originaux (3)
Récupéré via Wayback Machine