Проблема:
Требуется с помощью SendMessage в чужой программе устанавливать ползунок в нужное положение. Вот код:
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
Private Const WM_USER As Long = &H400
Private Const TBM_GETRANGEMAX As Long = (WM_USER + 2)
Private Const TBM_GETRANGEMIN As Long = (WM_USER + 1)
Private Const TBM_GETPOS As Long = (WM_USER)
Private Const TBM_SETPOS As Long = (WM_USER + 5)
Private Sub Command1_Click()
Dim Result As Long
Dim min As Long
Dim Max As Long
Dim i As Long
min = SendMessage(132798, TBM_GETRANGEMIN, 0, 0)
MsgBox "Ìèíèìóì = " & min
Max = SendMessage(132798, TBM_GETRANGEMAX, 0, 0)
MsgBox "Ìàêñèìóì = " & Max
Result = SendMessage(132798, TBM_GETPOS, 0, 0)
MsgBox "Òåêóùåå çíà÷åíèå = " & Result
For i = min To Max
Result = SendMessage(132798, TBM_SETPOS, True, i)
'MsgBox "Óñòàíàâëèâàåì íîâîå çíà÷åíèå = " & Result
Result = SendMessage(132798, TBM_GETPOS, 0, 0)
Print "Òåêóùåå çíà÷åíèå = " & Result
Next i
End Sub
Min, Max и текущее значение ползунка отрабатываются нормально, но при установке с помощью SendMassage нового значения - ползунок улетает в максинальную позицию. 132798 - это hWnd ползунка. Замените на свой