|
楼主 |
发表于 2019-1-24 19:51
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
我也有给MSChart添加滚动条的代码,但是想想要自己写滚动条事件,
太麻烦,就懒得用滚动条了,直接借用窗体或框架的滚动条也够用了。
- Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
- Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
- Private Const GWL_STYLE = (-16)
- Private Const WS_HSCROLL = &H100000
- Private Const WS_VSCROLL = &H200000
- Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As
- Long, ByVal wFlags As Long) As Long
- Private Const SWP_NOSIZE = &H1
- Private Const SWP_NOZORDER = &H4
- Private Const SWP_FRAMECHANGED = &H20
- Private Const SWP_NOMOVE = &H2
- Private Sub ModifyStyle()
- Dim lStyle As Long
- lStyle = GetWindowLong(MSChart1.hwnd, GWL_STYLE)
- SetWindowLong MSChart1.hwnd, GWL_STYLE, lStyle Or WS_HSCROLL Or WS_VSCROLL
- SetWindowPos MSChart1.hwnd, 0&, 0&, 0&, 0&, 0&, SWP_NOSIZE Or SWP_NOZORDER Or SWP_FRAMECHANGED Or SWP_NOMOVE
- End Sub
- Private Sub UserForm_Initialize()
- ModifyStyle
- End Sub
复制代码
|
|