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\\Coral2007\\"
	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 Window_OnSize(cx,cy)
	Window.LockPaint()
	CurrentWidth = cx
	CurrentHeight = cy
	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 
	
	GameButton.left = MobileMsgButton.left + 24
	ChatRoomButton.left = GameButton.left + 24
	petOpenBtn.left = ChatRoomButton.left + 24
	QQMusic.left = petOpenBtn.left + 24
	QQTV.left = QQMusic.left + 24
	
	MsgManagerButton.left = MenuButton.left + MenuButton.width + 6
	SearchButton.left = MsgManagerButton.left + MsgManagerButton.width + 6
	
	foldbottom = 42
	PlugMngHeight = 4

	ntopdistance = 0

	QQPushMsgPlug.AdjustHeight(cx - 4)
	
	If ntopdistance > 0 Then
		QQPushMsgPlug.width = cx - 4
		QQPushMsgPlug.Height = ntopdistance
		QQPushMsgPic.width = cx - 6
		QQPushMsgPic.Visible = TRUE
	Else
		QQPushMsgPic.Visible = FALSE
	End If
	
	If (ntopdistance > 0) Then
		FolderBackgroundLT.top = 81 + ntopdistance
		FolderBackgroundRT.top = 81 + ntopdistance
		FolderBackgroundT.top = 81 + ntopdistance		
	Else
		FolderBackgroundLT.top = 79 + ntopdistance
		FolderBackgroundRT.top = 79 + ntopdistance
		FolderBackgroundT.top = 79 + ntopdistance
	End If
		
	
	If (ntopdistance > 0) Then
		FolderBackgroundL.top = 82 + ntopdistance
		FolderBackgroundR.top = 82 + ntopdistance
		FolderBackgroundC.top = 82 + ntopdistance		
	Else
		FolderBackgroundL.top = 80 + ntopdistance
		FolderBackgroundR.top = 80 + ntopdistance
		FolderBackgroundC.top = 80 + ntopdistance
	End If
	
	NewPanels.visible = false
	
	If (ntopdistance > 0) Then 
		Bar1.top = 83 + ntopdistance
	Else
		Bar1.top = 81 + ntopdistance
	End If



	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
	If(PetState = 1) Then
		petOpenBtn.Visible = TRUE
		petCloseBtn.Visible = FALSE
	Else
		petCloseBtn.Visible = TRUE
		petOpenBtn.Visible = FALSE
	End If
	
If(PlugCloseState = 0) Then
		FolderBackgroundRB.left  = cx - 5 
		FolderBackgroundRB.top = cy - foldbottom - PlugMngHeight
		FolderBackgroundLB.top = cy - foldbottom - PlugMngHeight
		FolderBackgroundRT.left  = cx - 5 
		FolderBackgroundL.height = cy - 112 - ntopdistance - PlugMngHeight
		FolderBackgroundR.left  = cx - 5 
		FolderBackgroundR.height = cy - 121 - ntopdistance - PlugMngHeight
		FolderBackgroundT.width = cx - 35 
		FolderBackgroundB.top = cy - foldbottom -PlugMngHeight
		FolderBackgroundB.width = cx - 6 
		FolderBackgroundC.width = cx - 6 
		FolderBackgroundC.height = cy - 139 - ntopdistance - PlugMngHeight
Else'全部关闭
		FolderBackgroundRB.left  = cx - 5 
		FolderBackgroundRB.top = cy - foldbottom 
		FolderBackgroundLB.top = cy - foldbottom 
		FolderBackgroundRT.left  = cx - 5 
		FolderBackgroundL.height = cy - 112 - ntopdistance 
		FolderBackgroundR.left  = cx - 5 
		FolderBackgroundR.height = cy - 121 - ntopdistance 
		FolderBackgroundT.width = cx - 35 
		FolderBackgroundB.top = cy - foldbottom 
		FolderBackgroundB.width = cx - 6 
		FolderBackgroundC.width = cx - 6 
		FolderBackgroundC.height = cy - 139 - ntopdistance 

End If
	
	If MainSearchDlg.bInside = TRUE Then

		FolderBackgroundRB.top = FolderBackgroundRB.top - MainSearchDlg.height
		FolderBackgroundLB.top = FolderBackgroundLB.top - MainSearchDlg.height
		FolderBackgroundB.top = FolderBackgroundB.top - MainSearchDlg.height
		FolderBackgroundL.height = FolderBackgroundL.height - MainSearchDlg.height
		FolderBackgroundR.height = FolderBackgroundR.height - MainSearchDlg.height
		FolderBackgroundC.height = FolderBackgroundC.height - MainSearchDlg.height

	End if
	
	
	ToolBarBackgroundC.top = cy - 63
	ToolBarBackgroundC.width = cx - 30 
	ToolBarBackgroundL.top = ToolBarBackgroundC.top 
	ToolBarBackgroundR.left = cx - 15 
	ToolBarBackgroundR.top = ToolBarBackgroundC.top 


	CloseButton.left = cx - 21 
	MinButton.left = cx - 55 

	QQCaption.width = MinButton.left - 65
	ColorButton.left = cx - 38 

	MobileMsgButton.top = cy - 57 
	GameButton.top = cy - 57 
	ChatRoomButton.top = cy - 57 
	petCloseBtn.top = cy - 57 
	petOpenBtn.top = cy - 57 
	QQTV.top = cy - 57
	QQMusic.top = cy - 57
	
	MenuButton.top = cy - 31 
	MsgManagerButton.top = cy - 29 
	SearchButton.top = cy - 29 

	IF bShowDNA = 1 Then
		DNAButton.visible = true
		QQNumber.width = QQNumber.textlength
		DNAButton.left = QQNumber.left + QQNumber.width
		QQStatus.left  = DNAButton.left + DNAButton.width
		QQStatus.width = QQStatus.textlength
	Else
		DNAButton.visible = false
		QQNumber.width = QQNumber.textlength
		QQStatus.left  = QQNumber.left + QQNumber.width
		QQStatus.width = QQStatus.textlength
	End If

	Bar1.width = cx - 8 
	
	Bar1.LockPaint()
	MainSearchDlg.LockPaint()

	

		If PlugCloseState = 1 Then
		Bar1.height = cy - 142 - ntopdistance
		Else
		Bar1.height = cy - 142 - ntopdistance - PlugMngHeight
		End If

	
	
	If MainSearchDlg.bInside = TRUE Then	
		Bar1.height = Bar1.height - MainSearchDlg.height
		
			If PlugCloseState = 1 Then
			MainSearchDlg.top = FolderBackgroundB.top + FolderBackgroundB.height+1
			Else
			MainSearchDlg.top = FolderBackgroundB.top  + PlugMngHeight
			End If
		
		MainSearchDlg.width = cx	
	End if


	NewPanels.height = Bar1.height

  Bar1.UnLockPaint()
	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 PanelButton_onClick()
	Window.ExeCommand 4,9
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 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 MailButton_onClick()
	Window.ExeCommand 7,1	
End Sub

Sub DNAButton_onClick()
	Window.ExeCommand 27,1
End Sub

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

'下面的按钮组 
Sub MobileMsgButton_onClick()
	Window.ExeCommand 4,2
End Sub

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

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

Sub MenuButton_onClick()
	'Dim a As Integer
	'a = MenuButton.Left - 3
	's = CStr(Left)&"."&CStr(MenuButton.Top)
	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
Sub QQMusic_OnClick()
	Window.ExeCommand 25,1
End Sub
Sub QQTV_onClick()
	Window.ExeCommand 26,1
End Sub

sub petOpenBtn_onClick()
	Window.ExeCommand 40,12
end Sub

Sub petCloseBtn_onClick()
	Window.ExeCommand 40,13
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 
			QQStatus.value = 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 = "StatusPic.ico"
		elseif var = 20 Then
			UserStatus = "(离线)"			
			StatusIco = "StatusPic1.ico"
		elseif var = 30 Then	
			UserStatus = "(离开)"		
			StatusIco = "StatusPic2.ico"
		elseif var = 40 Then	
			UserStatus = "(隐身)"		
			StatusIco = "StatusPic3.ico"			
		end If
		StatusPic.ico = StatusIco
		If 0 = ShowStatus Then
			QQNumber.value = UserNum 
		Else
		   	QQNumber.value = UserNum 
			QQStatus.value = 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
		if( var = 0 ) Then
	            'HostingButton.label = "(" + "0" + ")"
	        else	              
		    'HostingButton.label = "(" + CStr(var) + ")"
		end if
	ElseIf code = 10 then
		if(var = 1) then
			PaymentButton.SetLighting(true)
		else
			PaymentButton.SetLighting(false)
		end If
	ElseIf code = 15 Then
		If(Var = 1) Then
			SecurityButton.SetLighting(true)
		Else    
		        SecurityButton.SetLighting(false)
		End If
	ElseIf code = 17 Then
		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 = 19 Then
		If(Var = 1) Then
		   PaymentButton.left = 119
		   PanelButton.left = 138
		   PaymentButton.width = 16
		   SecurityButton.visible = true
		ElseIf(Var = 0)Then
		   PaymentButton.left = SecurityButton.left
		   PaymentButton.width = 16
		   SecurityButton.visible = False
		   PanelButton.left = PaymentButton.left + 20
		End If
	ElseIf code = 20 Then
		If(Var = 1) Then
			QQStatus.left  = QQNumber.left + QQNumber.width + DNAButton.width
			QQStatus.width = QQStatus.textlength
			DNAButton.visible = true
			bShowDNA = 1			
		ElseIf(Var = 0) Then
			QQStatus.left  = QQNumber.left + QQNumber.width
			QQStatus.width = QQStatus.textlength
			DNAButton.visible = false
			bShowDNA = 0
		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 = 40 then
		if var = 12 then
			PetState = 1
			petCloseBtn.visible = false
			petOpenBtn.visible = true
		else
			PetState = 0
			petCloseBtn.visible = true
			petOpenBtn.visible = false
		end If
	ElseIf code = 51 Then
		StrCaption = var
		QQCaption.value = StrCaption	
	ElseIf code = 500 Then
		ntopdistance = Var
	End If	
End Sub