[效果]如何让text控件不出现滚动条,而通过点击特定的图片来实现向上翻页和向下翻页。

PI_2002 2003-08-14 11:30:06
请大家指点!
不甚感激!

如能提供源码可另外加分!
...全文
80 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
QBBKing 2003-08-15
  • 打赏
  • 举报
回复
将文本框的scrollbars属性设置为none。然后通过API函数拦截消息向上向下滚动。
其中要用到的函数sendmessage
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const EM_SCROLL = &HB5
Public Const SB_LINEUP = 0
Public Const SB_LINEDOWN = 1
Public Const SB_PAGEUP = 2
Public Const SB_PAGEDOWN = 3

text1.srollbars=0
sendmessage text1.hwnd,EM_SCROLL,SB_LINEUP,ByVal 0& '上卷1行
sendmessage text1.hwnd,EM_SCROLL,SB_PAGEDOWN,ByVal 0& '下卷1页
叶帆 2003-08-15
  • 打赏
  • 举报
回复
用这个简单,没必要复杂化
text1,要设成多行,没有滚动条

Private Sub Command1_Click()
Text1.SetFocus
SendKeys "{up}" '向上滚(也可以发 pgup)
End Sub
Private Sub Command2_Click()
Text1.SetFocus
SendKeys "{down}" '向下滚(也可以发pgdn)
End Sub
zyl910 2003-08-15
  • 打赏
  • 举报
回复
现将scrollbars设为3

运行时用SetWindowLong去掉WM_HSCROLL、WM_VScroll属性
再手动发送滚动通知消息




WM_HSCROLL
The WM_HSCROLL message is sent to a window when a scroll event occurs in the window's standard horizontal scroll bar. This message is also sent to the owner of a horizontal scroll bar control when a scroll event occurs in the control.

WM_HSCROLL
nScrollCode = (int) LOWORD(wParam); // scroll bar value
nPos = (short int) HIWORD(wParam); // scroll box position
hwndScrollBar = (HWND) lParam; // handle to scroll bar

Parameters
nScrollCode
Value of the low-order word of wParam. Specifies a scroll bar value that indicates the user's scrolling request. This parameter can be one of the following values: Value Meaning
SB_ENDSCROLL Ends scroll.
SB_LEFT Scrolls to the upper left.
SB_RIGHT Scrolls to the lower right.
SB_LINELEFT Scrolls left by one unit.
SB_LINERIGHT Scrolls right by one unit.
SB_PAGELEFT Scrolls left by the width of the window.
SB_PAGERIGHT Scrolls right by the width of the window.
SB_THUMBPOSITION The user has dragged the scroll box (thumb) and released the mouse button. The nPos parameter indicates the position of the scroll box at the end of the drag operation.
SB_THUMBTRACK The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The nPos parameter indicates the position that the scroll box has been dragged to.


nPos
Value of the high-order word of wParam. Specifies the current position of the scroll box if the nScrollCode parameter is SB_THUMBPOSITION or SB_THUMBTRACK; otherwise, nPos is not used.
hwndScrollBar
Value of lParam. If the message is sent by a scroll bar, then hwndScrollBar is the handle to the scroll bar control. If the message is not sent by a scroll bar, hwndScrollBar is NULL.
Return Values
If an application processes this message, it should return zero.

Remarks
The SB_THUMBTRACK notification message is typically used by applications that provide feedback as the user drags the scroll box.

If an application scrolls the content of the window, it must also reset the position of the scroll box by using the SetScrollPos function.

Note that the WM_HSCROLL message carries only 16 bits of scroll box position data. Thus, applications that rely solely on WM_HSCROLL (and WM_VSCROLL) for scroll position data have a practical maximum position value of 65,535.

However, because the SetScrollInfo, SetScrollPos, SetScrollRange, GetScrollInfo, GetScrollPos, and GetScrollRange functions support 32-bit scroll bar position data, there is a way to circumvent the 16-bit barrier of the WM_HSCROLL and WM_VSCROLL messages. See GetScrollInfo for a description of the technique.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.





WM_VSCROLL
The WM_VSCROLL message is sent to a window when a scroll event occurs in the window's standard vertical scroll bar. This message is also sent to the owner of a vertical scroll bar control when a scroll event occurs in the control.

WM_VSCROLL
nScrollCode = (int) LOWORD(wParam); // scroll bar value
nPos = (short int) HIWORD(wParam); // scroll box position
hwndScrollBar = (HWND) lParam; // handle to scroll bar

Parameters
nScrollCode
Value of the low-order word of wParam. Specifies a scroll bar value that indicates the user's scrolling request. This parameter can be one of the following values: Value Meaning
SB_BOTTOM Scrolls to the lower right.
SB_ENDSCROLL Ends scroll.
SB_LINEDOWN Scrolls one line down.
SB_LINEUP Scrolls one line up.
SB_PAGEDOWN Scrolls one page down.
SB_PAGEUP Scrolls one page up.
SB_THUMBPOSITION The user has dragged the scroll box (thumb) and released the mouse button. The nPos parameter indicates the position of the scroll box at the end of the drag operation.
SB_THUMBTRACK The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The nPos parameter indicates the position that the scroll box has been dragged to.
SB_TOP Scrolls to the upper left.


nPos
Value of the high-order word of wParam. Specifies the current position of the scroll box if the nScrollCode parameter is SB_THUMBPOSITION or SB_THUMBTRACK; otherwise, nPos is not used.
hwndScrollBar
Value of lParam. If the message is sent by a scroll bar, then hwndScrollBar is the handle to the scroll bar control. If the message is not sent by a scroll bar, hwndScrollBar is NULL.
Return Values
If an application processes this message, it should return zero.

Remarks
The SB_THUMBTRACK notification message is typically used by applications that provide feedback as the user drags the scroll box.

If an application scrolls the content of the window, it must also reset the position of the scroll box by using the SetScrollPos function.

Note that the WM_VSCROLL message carries only 16 bits of scroll box position data. Thus, applications that rely solely on WM_VSCROLL (and WM_HSCROLL) for scroll position data have a practical maximum position value of 65,535.

However, because the SetScrollInfo, SetScrollPos, SetScrollRange, GetScrollInfo, GetScrollPos, and GetScrollRange functions support 32-bit scroll bar position data, there is a way to circumvent the 16-bit barrier of the WM_HSCROLL and WM_VSCROLL messages. See GetScrollInfo for a description of the technique.

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.

chenkangli 2003-08-14
  • 打赏
  • 举报
回复
设置scrollbars=none就可以了!

7,759

社区成员

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

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