Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Type ButtonLocation
Close_Left As Integer
Close_Right As Integer
Min_Left As Integer
Min_Right As Integer
Max_Left As Integer
Max_Right As Integer
End Type
Private skinned As Boolean
Private skinfile As String
Private Bool_Min As Boolean
Private Bool_Max As Boolean
Private frm As Form
Private initok As Boolean
Private locate As ButtonLocation
Public Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Public Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Private inrgn As Boolean
Private Sub Init_PaintSkin() ' Runs Routines which paints the skin
If initok = True Then
UserControl.Cls
DrawTitleBar
Draw_Close_Defaults
Draw_Min_Defaults
Draw_Max_Defaults frm.WindowState
Draw_BackGround
End If
End Sub
Public Sub ChangeSkin(filename As String) ' For changing skin during run time
If initok = False Then Exit Sub
SaveSetting frm.Caption, "skin", "main", filename
On Error Resume Next
If Not filename = "" Then
Skinpic.Picture = LoadPicture(filename)
End If
Init_PaintSkin
End Sub
Private Sub InitAllocate() 'avoiding some redundant code from allocating effort to increase speed
frm.BorderStyle = 0
TitleBar.Top = 0
TitleBar.Left = 0
CapLabel.Top = 75
CapLabel.Caption = frm.Caption
TitleBar.Height = 300
End Sub
Public Sub allocate() ' allocate locations of various buttons depending on settings
Dim level As Integer
UserControl.Width = frm.Width
UserControl.Height = frm.Height
TitleBar.Width = frm.Width
locate.Close_Left = frm.Width - 300
locate.Close_Right = frm.Width - 105
If Bool_Max Then 'allocate Max button if present
locate.Max_Left = frm.Width - 510
locate.Max_Right = frm.Width - 330
level = level + 1
End If
If Bool_Min Then 'allocate min button if present depend on weather maxbutton is present or not
If level = 1 Then
locate.Min_Left = frm.Width - 720
locate.Min_Right = frm.Width - 480
Else
locate.Min_Left = frm.Width - 510
locate.Min_Right = frm.Width - 330
End If
End If
Init_PaintSkin
End Sub
Public Function GetSkinTheme() As Long ' Returns usercontrol's backcolor
GetSkinTheme = UserControl.BackColor
End Function
Private Sub Draw_BackGround()
'This Part has been drastically improved from last version
'iteration techniques are avoided producing faster o/p