哪位高手帮忙解决一下.文本显示问题.

fuwenbo 2005-03-18 12:12:57
第一次调用文本时显示正常,退出后,再次进入时便显示不了,得按下一页才可显示.
代码如下:

Public Function filegeter(file_path As String) As String
Dim lstr As String, lstrall As String
Open file_path For Input As #1
While Not EOF(1)
Line Input #1, lstr
lstrall = lstrall + lstr + Chr(13)
Wend
Close #1
filegeter = lstrall
If Len(lstrall) < 3 Then filegeter = Space(20)
End Function

Private Sub Form_Load()
'Me.Picture = LoadPicture(App.Path & "\pic\textshow.bmp") '在此添入背景图路径
Me.Height = Screen.Height
Me.Width = Screen.Width
Me.Left = 0
Me.Top = 0
'Flash1.Movie = App.Path & "\fla\logo2.swf"
Call textshow.PaintPicture(Me.Picture, 0, 0, textshow.Width, textshow.Height, textshow.Left, textshow.Top, textshow.Width, textshow.Height, vbSrcCopy)
mstr_total = filegeter(gstrpath) '显示的文本
textshowtemp.Picture = textshow.Image
textshowcls.Picture = textshow.Image
textshow.AutoRedraw = False
mint_now_pst = 1
mint_max_pst = 0
mint_charinfile_counted = 0
End Sub

Private Sub getpst()
Dim now_countcharcopy As Long '用来保存当前的mint_max_pst,以便确定当前的数组中的字符个数
Dim strtemp_in_group As String '当前用来显示的字符集合
Dim exit_thiswhile As Boolean '确定是否换行了,若换了就退出当前循环以便判断是否文本越界
Dim strtemp_in_grouptemp As String '保存当前strtemp_in_group,以便strtemp_in_group更改后可以确定当前数组的字符个数
exit_thiswhile = False
If mint_now_pst <= mint_max_pst Then
strtemp_in_group = mpagegroup(mint_now_pst)
Else
If mint_charinfile_counted < Len(mstr_total) Then
strtemp_in_group = Right(mstr_total, Len(mstr_total) - mint_charinfile_counted)
strtemp_in_grouptemp = strtemp_in_group
now_countcharcopy = mint_charinfile_counted
Else
strtemp_in_group = mpagegroup(mint_max_pst)
mint_now_pst = mint_max_pst
End If
End If
textshowtemp.Cls
While Len(strtemp_in_group) > 0 And (textshowtemp.CurrentY + 600 < textshowtemp.Height)
If Not exit_thiswhile Then
textshowtemp.Print
textshowtemp.CurrentX = textshowtemp.CurrentX + 200
textshowtemp.CurrentY = textshowtemp.CurrentY + 100
End If
exit_thiswhile = False
While ((Len(strtemp_in_group) > 0) And (textshowtemp.CurrentX + 400 < textshowtemp.Width) And (Not (exit_thiswhile)))
textshowtemp.Print Left(strtemp_in_group, 1);
If mint_now_pst > mint_max_pst Then mint_charinfile_counted = mint_charinfile_counted + 1
If textshowtemp.Width - textshowtemp.CurrentX > textshowtemp.Width - 2 Then
textshowtemp.CurrentX = textshowtemp.CurrentX + 200
textshowtemp.CurrentY = textshowtemp.CurrentY + 100
exit_thiswhile = True
End If
If Len(strtemp_in_group) > 0 Then
strtemp_in_group = Right(strtemp_in_group, Len(strtemp_in_group) - 1)
End If
Wend
Wend
If mint_now_pst > mint_max_pst Then
mint_max_pst = mint_max_pst + 1
mpagegroup(mint_max_pst) = Left(strtemp_in_grouptemp, mint_charinfile_counted - now_countcharcopy)
End If
textshowtemp.Refresh
'textshowtemp.Picture = textshowtemp.Image
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set Form2 = Nothing
End Sub

Private Sub Label1_Click(Index As Integer)
Dim pid As Long
Select Case Index
Case 0
If mint_now_pst > 1 Then
mint_now_pst = mint_now_pst - 1
Call getpst
Call textshowmode
End If
Case 1
If mint_charinfile_counted < Len(mstr_total) Then
mint_now_pst = mint_now_pst + 1
Call getpst
Call textshowmode
Else
If mint_now_pst < mint_max_pst Then mint_now_pst = mint_now_pst + 1
Call getpst
Call textshowmode
End If
Case 2

Unload Me
Form1.Show

End Select
End Sub



Private Sub textshow_Click()

End Sub

Private Sub Timer1_Timer()
Call getpst
Call textshowmode
Timer1.Enabled = False
End Sub


...全文
105 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
韧恒 2005-03-18
  • 打赏
  • 举报
回复
再说了,这种代码还在试下才知道的,你的窗口上有什么控件?每个控件叫什么?
还要浪费时间去弄好这些,真是晕。
lc_mtt 2005-03-18
  • 打赏
  • 举报
回复
一下子扔出那么多代码,又谁愿意看啊,把问题所涉及的代码精练出来啊~
homezj 2005-03-18
  • 打赏
  • 举报
回复
你的Form2可能在退出时没有被卸载,或提前被隐性加载,造成Print的内容没有被保存。
把Form_load中的textshow.AutoRedraw = False去掉
textshow.AutoRedraw要设为True,应该可以

不过,你还是要找到Form2没有被卸载,或提前被隐性加载的原因,这样不好!

附:你的代码很低效。

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧