Dim Width
Dim Height

Sub Window_OnInit()

	tabBtn1.visible = False
	tabBtn2.visible = True
	midBtn2.visible = False
	midBtn4.visible = False
	midBtn3.left = 5
    topBtn4.visible = False
	topBtn2.visible = True


End Sub



Sub Window_OnNotify(code ,var)		
  if code = 1001 then
   topTxt1.value = var
  elseif code = 1002 then
   leftBtn1.label = var
  elseif code = 1003 then
   midBtn4.visible = true
   midBtn2.visible = false
   midBtn3.left = 95
  elseif code = 1004 then
   midBtn4.visible = false
   midBtn2.visible = true
   midBtn3.left = 95
  elseif code = 1005 then
   if var = 1 then
    botBtn1.disabled = false
    botBtn3.disabled = false
   else
    botBtn1.disabled = true
    botBtn3.disabled = true
   end if
  elseif code = 1006 then 
   if (topBtn2.visible = True) then
    topBtn4.visible = True
	topBtn2.visible = False
   else
    topBtn4.visible = False
	topBtn2.visible = True
   end if
  end if 

end sub

Sub Window_OnSize(cx,cy)
	Width = cx
	Height = cy

	Window.LockPaint 
	
	'标题栏
	titlebar.width = cx
	topM.width = cx - 31
	topR.left = cx - 7
	topBtn1.left = cx - 68
	topBtn2.left = cx - 48
	topBtn4.left = cx - 48
	topBtn3.left = cx - 28

    '工具栏
	'midbar.width = cx - 3 - 3
	midM.width = cx - 100 - 3 -3 
	midR.left = midM.width + midM.left

    '下部背景
	botM.width = cx - 3 - 3
	botM.height = cy - botM.top - 3
 
	'外圈
    'outSide.width = cx
	'outSide.height = cy - 30
	outLM.height = cy - 3 - 30
	outB.top = cy - 3
	outB.width = cx 
	outRm.left = cx - 3
	outRm.height =  cy - 3 - 30

   AdjustContentSize()





	Window.UnLockPaint
end sub

sub AdjustContentSize()

if (tabBtn1.visible = true) then
    'leftbar
	leftBar.width = Width - 150
	leftM.width = leftBar.width - 14 - 15
	leftR.left = leftM.width + leftM.left
	leftItem.width =  Width - 150
	leftItem.height = Height - 136
	
	'right panel
    rightBar.left = Width - 132
	rightBar.width = 127
	rightItem.width = rightBar.width
	rightPic1.width = 127
	rightPic1.left = Width - 132
	rightTxt1.left = Width - 132 + 8
	'rightTxt1.width = 100
	rightItem.height = Height - 133

	'tabBtn
	tabBtn1.left = leftItem.width + leftItem.left + 8
	tabBtn1.top =  71 + (Height - 71)/2

	'按钮组
	'bot.width = leftBar.width
	botBtn1.top = Height - 32
    botBtn3.top = Height - 32
    botBtn2.top =  Height - 32
    botBtn3.left = leftBar.width + 7 - botBtn3.width
	botBtn2.left = botBtn3.left - 2 - 63



else
    'leftbar
	leftBar.width = Width - 22
	leftM.width = leftBar.width - 14 - 15
	leftR.left = leftM.width + leftM.left
	leftItem.width =  Width - 22
	leftItem.height = Height - 136
	
	'right panel
    rightBar.width = 0
	rightItem.width = 0
	rightPic1.width = 0
	rightTxt1.left = 10000
	rightItem.height = Height - 133

	'tabBtn
	tabBtn2.left = leftItem.width + leftItem.left + 8
	tabBtn2.top =  71 + (Height - 71)/2

	'按钮组
	'bot.width = leftBar.width
	botBtn1.top = Height - 32
    botBtn3.top = Height - 32
    botBtn2.top =  Height - 32
    botBtn3.left = leftBar.width + 7 - botBtn3.width
	botBtn2.left = botBtn3.left - 2 - 63

end if

end sub

sub tabBtn1_onClick()
	tabBtn1.visible = false
	tabBtn2.visible = true 	
    AdjustContentSize()      
	Window.ExeCommand 50,23	
end sub

sub tabBtn2_onClick()
	tabBtn1.visible = true
	tabBtn2.visible = False 	
    AdjustContentSize()
	Window.ExeCommand 50,24
end sub

sub topBtn1_onClick()	'最小化
	Window.ExeCommand 50,1
end sub

sub topBtn2_onClick()	'最大化
	Window.ExeCommand 50,2
end sub

sub topBtn4_onClick()	'最大化
	Window.ExeCommand 50,2
end sub

sub topBtn3_onClick()	'关闭
	Window.ExeCommand 50,3
end sub

sub botBtn1_onClick()
	Window.ExeCommand 50,20		'主菜单
end sub

sub botBtn2_onClick()
	Window.ExeCommand 50,21		' 关闭
end sub

sub botBtn3_onClick()
	Window.ExeCommand 50,22		' 发送
end sub

sub midBtn1_onClick()
	Window.ExeCommand 50,10		' 推荐
end sub

sub midBtn2_onClick()
	Window.ExeCommand 50,11		' 伴侣设置
end sub

sub midBtn3_onClick()
	Window.ExeCommand 50,12		' 问题反馈
end sub

sub midBtn4_onClick()
	Window.ExeCommand 50,13		' 我要开通
end sub

sub leftBtn1_onClick()
	Window.ExeCommand 50,15		' 用户资料
end sub