I'll get you started:
How to make a really cool shaped window
Put this into a module:
VB Code:
Public Function GetTransparencyRgn(ByVal TheForm As Form) As Long Dim hrgn As Long, hrgn2 As Long Dim Temp As Long Dim I As Integer, J As Integer Dim BeginX As Integer Dim PrevX As Integer Dim PrevEX As Integer Dim Rows As Integer Dim Flag As Boolean Dim BeginRow As Integer Dim H As Long Dim ht As Integer, wd As Integer hrgn = CreateRectRgn(0, 0, 0, 0) BeginX = -1 PrevX = -1 PrevEX = -2 Rows = 1 With TheForm.PicMask H = .hdc ht = .ScaleHeight wd = .ScaleWidth End With For J = 0 To ht Flag = False For I = 0 To wd ' change the RGB numbers here to change the transparent color If GetPixel(H, I, J) <> RGB(255, 255, 0) Then If BeginX = -1 Then If PrevX <> I Then Temp = CreateRectRgn(PrevX, J, PrevEX, J) BeginX = -1 CombineRgn hrgn, hrgn, Temp, RGN_OR DeleteObject Temp Rows = 1 End If BeginX = I If PrevX = I Then If Not Flag Then BeginRow = J Flag = True Rows = Rows + 1 End If PrevX = BeginX End If Else If BeginX <> -1 Then If Flag Then Rows = Rows + 1 Else BeginRow = J Rows = 1 Temp = CreateRectRgn(BeginX, BeginRow, I, J + Rows) BeginX = -1 CombineRgn hrgn, hrgn, Temp, RGN_OR DeleteObject Temp End If PrevEX = I End If End If Next I If BeginX >= (I - 1) Then BeginRow = J Rows = 1 Temp = CreateRectRgn(BeginX, BeginRow, I, J + Rows) BeginX = -1 CombineRgn hrgn, hrgn, Temp, RGN_OR DeleteObject Temp PrevEX = I End If Next J GetTransparencyRgn = hrgn End Function
And in the form:
VB Code:
Private Sub Form_Load() Dim hrgn As Long hrgn = GetTransparencyRgn(Me) SetWindowRgn hwnd, hrgn, 1 End Sub
Put a PictureBox onto the form that is named PicMask. Set its Visible property to false, AutoRedraw to True, and ScaleMode to 3 - vbPixels.
Next, make a BMP file that has the shape you want. The transparent color is yellow (RGB 255, 255, 0) but you can change it easily (see the code for details). Everything that is yellow (or whatever color you set) will be see-through.
Note also that the form's ScaleMode property must be 3-vbPixels.




Reply With Quote