Dim UserNum
Dim UserStatus
Dim Path
Dim strQQMailTip
Dim ShowStatus
Dim foldbottom
Dim bMsgInside
Dim CurrentWidth
Dim CurrentHeight
Dim PlugMngHeight
Dim PlugCloseState
Dim PetState
Dim ntopdistance
Dim bShowDNA

'注释
Sub Window_OnInit()	
	Window.GetScriptVersion "1.0" 	
	UserStatus = "(离线)"
	Path = "NewSkins\\2007\\"
	ShowStatus = 1
	UserNum = "0"
	If 1 = ShowStatus Then
		 UserNum = UserNum + UserStatus
	End If
	strQQMailTip = ""
	bMsginside = 0
	PlugCloseState = 0
	PetState = 1
	bShowDNA = 0
End Sub

Sub AdjustStatuePanelSize()
	QZoneMsgCenterButton.width = 16 + QZoneMsgCenterButton.textlength + 6
	
	MailButton.left = QZoneMsgCenterButton.left + QZoneMsgCenterButton.width
	MailButton.width = 16 + MailButton.textlength + 6
	
	PaymentButton.left = MailButton.left + MailButton.width
	If  PaymentButton.textlength > 0 Then 
		PaymentButton.width = 16 + PaymentButton.textlength + 6
	else 
		PaymentButton.width = 16 + 12
	End If
	
End Sub
Sub Window_OnSize(cx,cy)
	Window.LockPaint()
	CurrentWidth = cx
	CurrentHeight = cy
	
	'皮肤锁定	
     FixPanel.left = cx - 72
     UnFixPanel.left = cx - 72


	'背景	
	BackgroundRB.left  = cx - 12 
	BackgroundRB.top = cy - 110 
	BackgroundLB.top = cy - 110 
	BackgroundRT.left  = cx - 79 
	BackgroundRT2.left  = cx - 151 
	BackgroundL.height = cy - 141
	BackgroundR.left  = cx - 35 
	BackgroundR.height = cy - 84
	BackgroundT.width = cx - 143
	BackgroundT2.width = cx - 209 
	BackgroundB.top = cy - 110 
	BackgroundB.width = cx - 35 
	BackgroundC.width = cx - 19 
	BackgroundC.height = cy - 141 
	
	'好友列表中间空白部分
	FolderBackgroundLT.top = 81
	FolderBackgroundRT.top = 81 
	FolderBackgroundT.top = 81 
	FolderBackgroundL.top = 81
	FolderBackgroundR.top = 81
    FolderBackgroundT.width = cx - 35 	
    FolderBackgroundB.width = cx - 35 
	'好友列表中间空白部分宽度
	FolderBackgroundC.left=4 
	FolderBackgroundC.top=82
	FolderBackgroundC.width = cx - 37 
	FolderBackgroundC.height = cy - 142
	'标题栏
	ToolBarBackgroundC.top = cy - 62 
	ToolBarBackgroundC.width = cx - 30 
	ToolBarBackgroundL.top = ToolBarBackgroundC.top 
	ToolBarBackgroundR.left = cx - 15 
	ToolBarBackgroundR.top = ToolBarBackgroundC.top 		
	'主面板顶部的三个功能按钮
	CloseButton.left = cx - 21 
    ColorButton.left = cx - 38 
	MinButton.left = cx - 55 
	'标题
	QQCaption.width = MinButton.left - 65
	'主面板底部按钮的顶部坐标
	MenuButton.top = cy - 29
	PanelButton.top = cy - 25
	MsgManagerButton.top = cy - 25 
	MobileMsgButton.top = cy - 25
	SearchButton.top = cy - 25 
	'主面板底部按钮的相对位置关系	
	PanelButton.left=MenuButton.left+66
	MobileMsgButton.LEFT=PanelButton.left+24
	MsgManagerButton.LEFT=MobileMsgButton.left+21
	SearchButton.LEFT=MsgManagerButton.LEFT+22

	Bar1.LockPaint()
	Bar1.top = 80
	Bar1.width = cx - 8
	Bar1.height = cy - 114
	Bar1.left=4
	Bar1.UnLockPaint()

	'侧边栏项
	NewPanels.left=3
	NewPanels.top = 0
	NewPanels.width=0 
	NewPanels.height=0
 	StatusWeather.left = cx - 43
	Container_Up.top = 25
	Container_Up.left = StatusButton.left + StatusButton.width
	Container_Up.width = cx - Container_Up.left - StatusWeather.width - 10
	Container_Up.height = 68
	Container_Down.top = cy - 65
	Container_Down.left = 0
	Container_Down.width = cx
	Container_Down.height = 65
	FolderBackgroundRB.left  = cx - 5 
	FolderBackgroundRB.top = cy - foldbottom 
	FolderBackgroundLB.top = cy - foldbottom 
	FolderBackgroundRT.left  = cx - 5 
	FolderBackgroundL.height = cy - 132 
	FolderBackgroundR.left  = cx - 5 
	FolderBackgroundR.height = cy - 141 
	FolderBackgroundB.top = cy - foldbottom 
	QQNumber.width = QQNumber.textlength
	QQStatus.left  = QQNumber.left + QQNumber.width
	QQStatus.width = QQStatus.textlength
	MainSearchDlg.UnLockPaint()
	MailButton.label = strQQMailTip
    Window.UnLockPaint()
End Sub

Sub MinButton_onClick()
	Window.ExeCommand 1,2
End Sub
Sub CloseButton_onClick()
	Window.ExeCommand 1,3
End Sub
Sub ColorButton_onClick()
     Window.ExeCommand 4,7
End Sub

'六个Bar按钮
Sub Window_onClick(code, Name)
	Window.LockPaint()
	Window.DisableBar CStr(Name)
	Window.ExeCommand code,CStr(Name)
	Window.UnLockPaint()
End Sub

Sub QQStatus_onClick()
	s = QQStatus.left
	Window.ExeCommand 63,s
End Sub
'顶部的按钮组 
Sub StatusButton_onClick()
	s = CStr(StatusButton.Left + StatusButton.width - 10)&"."&CStr(StatusButton.Top + StatusButton.height - 8)
	Window.ExeCommand 6,s
End Sub

sub StatusPic_onMouseMove(nX,nY)
	s = CStr(StatusPic.Left) & "." & CStr(StatusPic.Top) & "." & CStr(StatusPic.width) & "." & CStr(StatusPic.height)
	Window.ExeCommand 20,s
end Sub

sub StatusPic_onMouseLeave()
	s = CStr(StatusPic.Left) & "." & CStr(StatusPic.Top) & "." & CStr(StatusPic.width) & "." & CStr(StatusPic.height)
	Window.ExeCommand 21,s
end Sub

Sub StatusPic_onClick()
	Window.ExeCommand 60,2
End Sub

Sub MailButton_onClick()
	Window.ExeCommand 7,1
End Sub
sub StatusWeather_onMouseMove(nX,nY)
	s = CStr(StatusWeather.Left) & "." & CStr(StatusWeather.Top) & "." & CStr(StatusWeather.width) & "." & CStr(StatusWeather.height)
	Window.ExeCommand 31,s
end Sub

sub StatusWeather_onMouseLeave()
	s = CStr(StatusWeather.Left) & "." & CStr(StatusWeather.Top) & "." & CStr(StatusWeather.width) & "." & CStr(StatusWeather.height)
	Window.ExeCommand 30,s
end Sub

Sub StatusWeather_onClick()
	Window.ExeCommand 61,0
End Sub

sub PaymentButton_onClick()
	Window.ExeCommand 4,8
end Sub

Sub QZoneMsgCenterButton_onClick()
	QZoneMsgCenterButton.label = "0"
	Window.ExeCommand 66,0
End Sub	

Sub SecurityButton_onClick()
	Window.ExeCommand 15,1	
End Sub

'下面的按钮组 

'Sub GameButton_onClick()
'	Window.ExeCommand 4,5
'End Sub

'Sub ChatRoomButton_onClick()
'	Window.ExeCommand 4,1
'End Sub

Sub PanelButton_onClick()
	Window.ExeCommand 4,9
End Sub
Sub MobileMsgButton_onClick()
	Window.ExeCommand 4,2
End Sub
Sub MenuButton_onClick()
	s = CStr(Int(MenuButton.Left - 3))&"."&CStr(MenuButton.Top)
	Window.ExeCommand 5,s
End Sub
Sub MsgManagerButton_onClick()
	Window.ExeCommand 4,6
End Sub
Sub SearchButton_onClick()
	Window.ExeCommand 4,3
End Sub
Sub ScrollUpButton_OnClick()
        Window.ExeCommand 17,1
End Sub
Sub ScrollDownButton_OnClick()
        Window.ExeCommand 18,1
End Sub
Sub PanelMngButton_OnClick()
	Window.ExeCommand 19,1
End Sub

'处理QQ程序发来的事件
Sub Window_OnNotify(code ,var)
	If code = 1 Then
		'设置当前的Uin
		UserNum = var
		If 0 = ShowStatus Then
			QQNumber.value = UserNum 
		Else
		   	QQNumber.value = UserNum 
			QQStatusText.value = UserStatus
			QQStatus.label = UserStatus
		End If			
	ElseIf code = 2 Then
		'闪系统消息按钮 var 为1是开始闪。为2是停止
		If(var = 1) Then
			MsgManagerButton.StopFlash
			MsgManagerButton.Flash 30
		Else
			MsgManagerButton.StopFlash
		End If
	ElseIf code = 3 then
		'闪状态按钮 var 为0,1,2,3是对应的ico。为4表示停止
		if var = 0 then
			StatusPic.ico = "Online.ico"		
		elseif var = 1 Then
			StatusPic.ico = "leave.ico"		
		elseif var = 2 Then
			StatusPic.ico = "invisible.ico"		
		elseif var = 3 Then
			StatusPic.ico = "Offline.ico"		
		elseif var = 4 then
			StatusPic.Ico = StatusIco	
		end if
	ElseIf code = 4 Then
		'设置那个Bar在最前
		Window_onClick 2,Var
	ElseIf code = 5 Then
		'设置当前的状态。
		If var = 10 Then	
			UserStatus = "[在线]"		
			StatusIco = "online.ico"
		ElseIf var = 20 Then
			UserStatus = "[离线]"			
			StatusIco = "exit.ico"
		ElseIf var = 30 Then	
			UserStatus = "[离开]"		
			StatusIco = "leave.ico"
		ElseIf var = 40 Then	
			UserStatus = "[隐身]"		
			StatusIco = "hide.ico"
		ElseIf var = 50 Then
			UserStatus = "[忙碌]"
			StatusIco = "busy.ico"
		ElseIf var = 60 Then
			UserStatus = "[Q我吧]"
			StatusIco = "qme.ico"
		ElseIf var = 70 Then
			UserStatus = "[静音]"
			StatusIco = "nobother.ico"
		End If
		StatusButton.ico = StatusIco
		If 0 = ShowStatus Then
			QQNumber.value = UserNum 
		Else
		   	QQNumber.value = UserNum 
			QQStatusText.value = UserStatus
			QQStatus.label = UserStatus
		End If
	ElseIf code  = 6 Then
		'设置Skin的起始路径
		Path = Var
'	ElseIf code = 100 Then
'		'改变QQMail的提示
'		if( var = 0 ) then
'		    strQQMailTip = "(" + "0" + ")"
'		else
'		    strQQMailTip = "(" + CStr(var) + ")"
'		end if
'		MailButton.label = strQQMailTip		

'	ElseIf code = 101 Then
'		'改变QQ安全中心的显示图片
'		If(Var = 1) Then
'		   SecurityButton.ico = "security_alert.ico"
'		ElseIf (Var = 2) Then
'		   SecurityButton.ico = "security_import.ico"
'		ElseIf (Var = 3) Then
'		   SecurityButton.ico = "security_infor.ico"
'		ElseIf (Var = 4) Then
'		   SecurityButton.ico = "security_help.ico"
'		ElseIf (Var = 5) Then
'		   SecurityButton.ico = "security_normal.ico"
'		Else
'		   SecurityButton.ico = "security_normal.ico"		
'		End If
	ElseIf code = 102 Then
	    '改变QQMail的提示，QQ2007Beta2后使用102
		strQQMailTip = CStr(var)
		MailButton.label = strQQMailTip			
		AdjustStatuePanelSize()		
	ElseIf code = 103 then
		if(var > 0) then
			MailButton.StartGif(var)			
		Else
			MailButton.EndGif()						
		End If
	ElseIf code = 104 Then
		If(Var = 1) Then
			MailButton.ico = "MailButtonGray.ico"
		Else
			MailButton.ico = "MailButton.ico"	
		End If		
	ElseIf code = 105 Then
		MailButton.toolTip = CStr(var)

	ElseIf code = 10 then
		if(var = 1) then
			PaymentButton.SetLighting(true)
		else
			PaymentButton.SetLighting(false)
		end If
	ElseIf code = 20 Then
			QQStatus.left  = QQNumber.left + QQNumber.width
			QQStatus.width = QQStatus.textlength
	ElseIf code = 114 then
		If (var = -1) Then
			QZoneMsgCenterButton.label = ""
		Else
			QZoneMsgCenterButton.label = CStr(var)
		end If
	ElseIf code = 108 then
		if(var = 1) then
			StatusEdit.bInside = TRUE
		else
			StatusEdit.bInside = FALSE
		end If		
			
	ElseIf code = 25 Then
		' 皮肤推送
		if(var = 1) then
			ColorButton.SetLighting(true)
		else
			ColorButton.SetLighting(false)
		end If
	ElseIf code = 31 then
		if(var = 1) then
			MainSearchDlg.bInside = TRUE
		else
			MainSearchDlg.bInside = FALSE
		end If	
	ElseIf code = 51 Then
		StrCaption = var
		QQCaption.value = StrCaption	
	
	End If	
End Sub

'皮肤锁定函数
Sub FixPanel_onClick()
        Window.LockPaint()
        FixFlag=1
        Parameter1 = CurrentWidth
        Parameter2 = CurrentHeight
        FixPanel.visible = false
        UnFixPanel.visible = true
		Window.minWidth = Parameter1
		Window.maxWidth = Parameter1
		Window.minHeight = Parameter2
		Window.maxHeight = Parameter2
		Window.UnLockPaint()
End Sub

Sub UnFixPanel_onClick()
        Window.LockPaint()
        FixFlag=0
        FixPanel.visible = true
        UnFixPanel.visible = false
		Window.width = Parameter1
		Window.height = Parameter2
		Window.maxHeight = 1024
		Window.minHeight = 214
		Window.maxWidth = 1280
		Window.minWidth = 80
		Window.UnLockPaint()
End Sub

Sub MailButton_onGifStop()
	Window.ExeCommand 62,0
End Sub
'怡水若寒(YSRH)于2007年11月22日 第5次修改
'怡水若寒(YSRH)的Blog：http://www.ysrh.com/