johnborg
August 22nd, 2001, 11:09 AM
How do I tie scrollbars with keypress events? I'm working on this project that recieves instructions via the serial port (using MSCommControl) and tied the values that control the robot to scrollbars, now my problem is tying the scrollbars to keypress events. i.e. press the page up key and the gripper closes, page down and it opens. I've tried several times in the span of a week and a half, I'm already spent, I've seen someone do it but the programmer won't respond to my e-mails. Please help and restore my sanity. . .
hoa01206
August 22nd, 2001, 05:07 PM
1- You need this API function put in a module
Private Declare Function SendMessageByVal Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_VSCROLL = &H115
2- also this method
Sub GridScroll(tb As MSFlexGrid, ByVal HorizScroll As Long, ByVal VertScroll As Long)
SendMessageByVal tb.hwnd, WM_VSCROLL, HorizScroll, VertScroll
End Sub
3- In key press if you want to scroll
A- up GridScroll Grid2, 0, 0 'up
B- down GridScroll Grid2, 1, 0 'down
Here I am using a grid control, in your case subtitute for the grid with whatever control you have.
Good Luck!
Thanks
Hisham