Perlistan 2014年02月09日
关于窗体的优化问题


大家好,这是我无聊写的一个单机游戏某个窗体,麻烦各位能人帮我看看有什么要优化的地方?有一个关键的问题:【窗体unload后是释放了内存,但是重新加载又unload一次后内存竟然增加了,这是怎么回事?(程序占用内存11M{刚开始},然后加载这个窗体卸载后变成了12M,再加载再卸载13M。是代码有问题还是什么?我感觉unload卸载的不完整,用set XXX = nothing也没用)





Dim LoadABC1 As Boolean
Dim LoadABC2 As Boolean
Private Sub Form_Load()
'读取数据库
UserSQL.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "\Data\World\TaikouHero.World" & ";Persist Security Info=False"
UserSQL2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "\Data\World\TaikouHero.World" & ";Persist Security Info=False"
UserSQL.RecordSource = "存档一"
UserSQL2.RecordSource = "存档二"
'窗口居中
Me.Move 0, 0
'读取角色存档
L1.DataField = "角色名"
L2.DataField = "等级"
L3.DataField = "角色名"
L4.DataField = "等级"
'判断名字是否为空
If L1.Caption = "空" Then
L2.Caption = "空"
Else
Load1.Picture = LoadPicture(App.Path & "\Data\Dpc\Load_Yes1.dpc")
LoadABC1 = True
End If
If L3.Caption = "空" Then
L4.Caption = "空"
Else
Load2.Picture = LoadPicture(App.Path & "\Data\Dpc\Load_Yes1.dpc")
LoadABC2 = True
End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'返回按钮鼠标离开
ReturnButton.Picture = LoadPicture(App.Path & "\Data\Dpc\Return1.dpc")
'读取图片特效开关
If LoadABC1 = True Then
Load1.Picture = LoadPicture(App.Path & "\Data\Dpc\Load_Yes1.dpc")
End If
If LoadABC2 = True Then
Load2.Picture = LoadPicture(App.Path & "\Data\Dpc\Load_Yes1.dpc")
End If
End Sub

Private Sub Load1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'存档一鼠标按下
If LoadABC1 = True Then
LoadSE.URL = App.Path & "\Data\Sound\Yes.mp3"
LoadSE.settings.volume = 100
LoadSE.Controls.play
Else
LoadSE.URL = App.Path & "\Data\Sound\Error.mp3"
LoadSE.settings.volume = 100
LoadSE.Controls.play
End If
End Sub

Private Sub Load1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'存档一鼠标经过
If LoadABC1 = True Then
Load1.Picture = LoadPicture(App.Path & "\Data\Dpc\Load_Yes2.dpc")
End If
End Sub

Private Sub Load2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'存档二鼠标按下
If LoadABC2 = True Then
LoadSE.URL = App.Path & "\Data\Sound\Yes.mp3"
LoadSE.settings.volume = 100
LoadSE.Controls.play
Else
LoadSE.URL = App.Path & "\Data\Sound\Error.mp3"
LoadSE.settings.volume = 100
LoadSE.Controls.play
End If
End Sub

Private Sub Load2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'存档二鼠标经过
If LoadABC2 = True Then
Load2.Picture = LoadPicture(App.Path & "\Data\Dpc\Load_Yes2.dpc")
End If
End Sub

Private Sub ReturnButton_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'返回按钮鼠标按下
If Button = 1 Then
Unload Me
End If
End Sub

Private Sub ReturnButton_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'返回按钮经过
ReturnButton.Picture = LoadPicture(App.Path & "\Data\Dpc\Return2.dpc")
End Sub
...全文
163 点赞 收藏 2
写回复
2 条回复

还没有回复,快来抢沙发~

发动态
发帖子
VB基础类
创建于2007-09-28

2739

社区成员

19.7w+

社区内容

VB 基础类
社区公告
暂无公告