 |
|
|
|
| Author |
Message |
Thomas Wieczorek
Joined: 22 Jan 2008 Posts: 2
|
Posted: Tue Jan 22, 2008 6:26 am Post subject: Sending scroll messages to external applications |
|
|
Hello!
I am opening documents(*.txt, *.doc, etc.) in external
applications(Notepad, Word Viewer, Excel Viewer) and I have to scroll
automatically those external applications.
I've looked so far in GetScrollInfo, GetScrollRange, ScrollWindow and
SetScrollPos on www.pinvoke.net, but I am not sure how to use those
methods to control scrolling of external apps.
Do you have any ideas or experience how to realize that?
Kindly, Thomas
Archived from group: microsoft>public>vb>winapi |
|
| Back to top |
|
 |
Thomas Wieczorek
Joined: 22 Jan 2008 Posts: 2
|
Posted: Tue Jan 22, 2008 8:58 am Post subject: Re: Sending scroll messages to external applications |
|
|
All right.
I found some interesting information in the MSDN, but I still don't
know how to get the handle to a scroll bar.
I am using GetScrollInfo() to get information on the scroll bar in a
window. It works only with SB_CTL with notepad.exe and the Microsoft
Word Viewer(returns 1). SB_VERT returns 0(i am just interested in the
vertical scroll bar so far).
Public Function Scroll() As Boolean
Dim retValue As Boolean
Dim si As SCROLLINFO
Dim lRet As Integer
si = New SCROLLINFO
With si
.cbSize = Len(si)
.fMask = ScrollInfoMask.SIF_ALL
End With
lRet = GetScrollInfo(New
IntPtr(_current_file.pInfo.dwThreadId), ScrollBarDirection.SB_CTL, si)
If 0 = lRet Then
lRet =
System.Runtime.InteropServices.Marshal.GetLastWin32Error()
MsgBox("Last Win32-Errorcode: " & lRet.ToString)
End If
Return retValue
End Function
"_current_file" is a simple object which stores a file path and the
process information about the application which opened it with
CreateProcess:
Public Structure PROCESS_INFORMATION
Public hProcess As IntPtr
Public hThread As IntPtr
Public dwProcessId As Integer
Public dwThreadId As Integer
End Structure
Is there a way to get to the scroll bar control of the process or
window?
Regards,
Thomas |
|
| Back to top |
|
 |
Thorsten Albers
Joined: 04 Oct 2007 Posts: 756
|
Posted: Tue Jan 22, 2008 10:35 am Post subject: Re: Sending scroll messages to external applications |
|
|
Thomas Wieczorek schrieb im Beitrag
...
>
> ...
> si = New SCROLLINFO
>
> ...
> Is there a way to get to the scroll bar control of the process or
> window?
You are using VB.NET, but this newsgroup is dealing with VB <= 6.0 which
has not much more in common with VB.NET but the name. So you should ask
your question in an appropriate newsgroup - look out for newsgroups with
"dotnet" in their names.
Just a hint:
There have to be four types of scroll bars taken into account:
Type 1: Scroll bar control
This is a 'real' window of the standard window class "SCROLLBAR". Scroll
bar messages and functions of the Windows API for scroll bar controls are
supported.
Type 2: Standard scroll bar
This isn't a window but part of the non-client area of a window with the
window style WS_HSCROLL and/or WS_VSCROLL. Scroll bar messages and
functions of the Windows API for standard scroll bars are supported, if the
window procedure of the window with the standard scroll bar(s) doesn't
prevent support.
Type 3: Custom scroll bar controls
This is a 'real' window either based on the standard window class
"SCROLLBAR" or another registered window class (which may have been
registered for use by any application or by its 'owner' application only).
Support of Windows API scroll bar messages and functions for scroll bar
controls depends on the implementation of the window class - they may be
supported or not. Usually the documentation of the custom control informs
you about this.
Type 4: Application specific scroll bar implementation.
This is a scroll bar completely handled and drawn by the application,
usually without a window of its own. Support of Windows API scroll bar
messages and functions depends on the application - but is very unlikely.
For type 1 search for a child window of the main window which is of the
window class "SCROLLBAR". Then use the retrieved window handle, if any,
with Windows API scroll bar messages and functions.
For type 2 send/call Windows API scroll bar messages and functions with the
window handle of the window in question which has the WS_HSCROLL/WS_VSCROLL
window style.
For type 3 you have to know the window class name of the custom scroll bar
control. Then find the window and call GetScrollInfo() with the retrieved
window handle. If this failes, the control doesn't support the Windows API
scroll bar functions for scroll bar controls. Then send the found window a
SBM_GETSCROLLINFO message. If this failes, the control doesn't support
Windows API scroll bar messages for scroll bar controls either. If neither
functions nor messages are supported, the only other possible ways are a)
using an API for this provided by the control, if any, or b) synthesizing
mouse events (see SendInput()).
The same is valid for type 4 except that you have to use the handle of the
window with the application specific scroll bar implementation.
--
----------------------------------------------------------------------
THORSTEN ALBERS Universität Freiburg
albers@
uni-freiburg.de
----------------------------------------------------------------------
|
|
| Back to top |
|
 |
|
|
| Related Topics: | Calling functions vs Sending Messages This is something that has always bugged me about windows programming. Maybe it belongs in a Windows Programming group, but here goes, in case someone wants to answer. Why does windows sometimes force me to use a function, and sometimes to send a message?
VB, sending messages to another app using SendMessage / Post Hello, could someone more fluent than I in VB please examine the following and help me understand where the problem may lie? Basically I begin by grabbing the handle to an "edit" control within the main program (a game, Jedi Academy), and try to input tex
Sending Text to a specific control in an external app using I am trying to send to a specific external app from within a VBA application. I have already programmed the steps to find the external app via Findwindow & Calls, but I am having trouble finding the necessary steps of finding a specifi
Sending text to a specific textbox control on an external ap I have this vb program that I am developing, where I need to enter text into a specific textbox control on an external program(the ext. app is not an inhouse app,so I no specifics for the program).I have already utilized the WinAPI calls to implement the
Linking mouse scroll button to Scroll bar Hello, Is it possible to associate the mouse scroll button to Scroll bar of Ms Flex Grid Thanks in advance Regards Mahalakshmi |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|