标题:TXT阅读器
取消只看楼主
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4912
专家分:29900
注 册:2008-10-15
结帖率:100%
 问题点数:0 回复次数:2 
TXT阅读器
TXT阅读器
支持OLE拖文件进去打开,支持把文件拖到图标上,运行自动打开。
使用了通用对话框 控件 CommonDialog
支持鼠标滚轮。
因为滚动条不符合要求,所以放弃了使用滚动条。
内容是用图像形式打印出来的,所以可以支持任意大的TXT文件。

缺点,因为文件是一次性读入内存,所以打开文件时,大文件时稍有点偏慢,这是VB的问题,无法克服。用FSO组件,感觉也差不多。

警告:如果你想调试这个程序,请把鼠标滚轮支持那条命令注释掉,否则VB IDE 会挂掉,不是有可能,而是100%的挂掉。

TXT.rar (7.39 KB)
收到的鲜花
  • 永夜的极光2008-10-17 07:30 送鲜花  49朵   附言:谢谢分享
搜索更多相关主题的帖子: TXT 阅读 
2008-10-16 22:27
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4912
专家分:29900
注 册:2008-10-15
得分:0 
Module2.bas 需要修改。
错误的地方是一API函数理解错误造成的。
新的内容如下:

Option Explicit

'本函数是抄的网上的,再自己修改

  Public Type POINTL
          x   As Long
          y   As Long
  End Type
  Declare Function CallWindowProc _
          Lib "USER32" Alias "CallWindowProcA" _
                  (ByVal lpPrevWndFunc As Long, _
                  ByVal hWnd As Long, _
                  ByVal Msg As Long, _
                  ByVal wParam As Long, _
                  ByVal lParam As Long) As Long
   
  Declare Function SetWindowLong _
          Lib "USER32" Alias "SetWindowLongA" _
                  (ByVal hWnd As Long, _
                  ByVal nIndex As Long, _
                  ByVal dwNewLong As Long) As Long
   
  Declare Function SystemParametersInfo _
          Lib "USER32" Alias "SystemParametersInfoA" _
                  (ByVal uAction As Long, _
                  ByVal uParam As Long, _
                  lpvParam As Any, _
                  ByVal fuWinIni As Long) As Long
            
  Declare Function ScreenToClient Lib "USER32" _
  (ByVal hWnd As Long, xyPoint As POINTL) As Long
   
  Public Const GWL_WNDPROC = -4
  Public Const SPI_GETWHEELSCROLLLINES = 104
  Public Const WM_MOUSEWHEEL = &H20A
  Public WHEEL_SCROLL_LINES     As Long
               
  Global lpPrevWndProc     As Long
   
  Public Sub Hook(ByVal hWnd As Long)
lpPrevWndProc = SetWindowLong(hWnd, GWL_WNDPROC, _
AddressOf WindowProc)
''获取"控制面板"中的滚动行数值
'Call SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, WHEEL_SCROLL_LINES, 0)
Call SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, WHEEL_SCROLL_LINES, 0)

If WHEEL_SCROLL_LINES < 3 Then WHEEL_SCROLL_LINES = 3       '防止读取失败,我测试时是读取失败

End Sub
   
  Public Sub UnHook(ByVal hWnd As Long)
          Dim lngReturnValue     As Long
          lngReturnValue = SetWindowLong(hWnd, GWL_WNDPROC, lpPrevWndProc)
  End Sub
   
    '此函数自己修改了
  Function WindowProc(ByVal hw As Long, _
                  ByVal uMsg As Long, _
                  ByVal wParam As Long, _
                  ByVal lParam As Long) As Long
          Dim pt     As POINTL
          Select Case uMsg
                  Case WM_MOUSEWHEEL            '传入的鼠标滚动消息
                    With Form1
                        If wParam = -7864320 Then       '向下滚
                              .wz = .wz + WHEEL_SCROLL_LINES
                        ElseIf wParam = 7864320 Then    '向上滚
                              .wz = .wz - WHEEL_SCROLL_LINES
                        End If
                            '处理完滚动消息后,就去显示
                            Call .显示
                    End With
                Case Else
                    WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
          End Select
  End Function
   
  Public Function HIWORD(LongIn As Long) As Integer
      HIWORD = (LongIn And &HFFFF0000) \ &H10000
  End Function
   
  Public Function LOWORD(LongIn As Long) As Integer
              LOWORD = LongIn And &HFFFF&
  End Function

授人于鱼,不如授人于渔
早已停用QQ了
2008-10-17 00:18
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4912
专家分:29900
注 册:2008-10-15
得分:0 
如果发生错误,非正常退出,按停止退出的时候,就挂掉.

正常退出是不会挂掉.
中断时退出就会挂掉的.

授人于鱼,不如授人于渔
早已停用QQ了
2008-10-17 13:39



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-238737-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.091062 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved