The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Javer on September 17, 2007, 12:58:29 PM

Title: Scrolling another app
Post by: Javer on September 17, 2007, 12:58:29 PM
Hi all
I need to scroll third party app. But I have a problem. When I scroll scrollBar, the scroll bar is scrolled but the window is not.
When I click, on the scroll pointer, window is immediately scrolled.
This is my code:

    mov ebx,7152   ;identifier of control
    invoke GetDlgItem,ADD_HANDLE, ebx
    mov ScrollHandle,eax
    invoke SetScrollPos,ScrollHandle,SB_CTL,28,TRUE


When I scroll it normally, I mean by clicking with mouse, not by this code, everything is ok.
Any Idea ?

Javer
Ps: sorry for my english
Title: Re: Scrolling another app
Post by: evlncrn8 on September 17, 2007, 01:41:53 PM
setfocus required maybe?
Title: Re: Scrolling another app
Post by: Javer on September 17, 2007, 02:45:54 PM
thanks for reply.
I'm not able to make setfocus work. It still ends with the NULL.
Any other solution ?
Title: Re: Scrolling another app
Post by: Javer on September 18, 2007, 08:33:36 AM
I can make it work when I set the cursor to the current position X and Y and click


invoke  SetCursorPos,950,300
Invoke mouse_event,MOUSEEVENTF_LEFTDOWN,950,300,0,0
Invoke mouse_event,MOUSEEVENTF_LEFTUP ,950,300,0,0


But I don't like this solution becouse, the user can move the window and then the position x = 950 and y = 300 is useless.
Is there any other way how to send Scroll bar pointer click ?
Please if somebody know help me.

Javer
Title: Re: Scrolling another app
Post by: zooba on September 18, 2007, 09:18:07 AM
Try calling UpdateWindow on the parent window after setting the scroll bar position. Also, if the scroll bar is an automatically provided one (ie. the window was created with WS_HSCROLL or WS_VSCROLL) you will need to pass SB_HORZ or SB_VERT instead of SB_CTL.

Cheers,

Zooba :U
Title: Re: Scrolling another app
Post by: Javer on September 18, 2007, 10:24:33 AM
No UpdateWindow doesn't work  :(   With SB_HORZ or SB_VERT it did nothing. The SB_CTL is correct. Actually it doesn't scroll anything. It just moves scroll pointer (thumb) to the position. But window isn't scrolled.
It looks like this :
(http://img398.imageshack.us/img398/1579/31144833lw7.th.jpg) (http://img398.imageshack.us/my.php?image=31144833lw7.jpg)

and it should be :
(http://img398.imageshack.us/img398/5029/56665741pq8.th.jpg) (http://img398.imageshack.us/my.php?image=56665741pq8.jpg)

thanks
Title: Re: Scrolling another app
Post by: hutch-- on September 18, 2007, 10:57:55 AM
Javer,

The technique you posted above is probably your best bet.


invoke  SetCursorPos,950,300
Invoke mouse_event,MOUSEEVENTF_LEFTDOWN,950,300,0,0
Invoke mouse_event,MOUSEEVENTF_LEFTUP ,950,300,0,0


Much of the API code you have access at is not designed to work across two different threads so you may nopt have the correct access to make many of them work. With the code you have above you should properly calculate the windows location every time you run the code and you will not have the problem you mentioned of the user moving the window.
Title: Re: Scrolling another app
Post by: Javer on September 18, 2007, 11:56:33 AM
Ok so i try to use GetWindowRect and calculate it.
Thank everybody for effort
Title: Re: Scrolling another app
Post by: MichaelW on September 18, 2007, 06:52:33 PM
Javer,

I can't tell from the image exactly what you are attempting to scroll, but if it is a control, you may be able to force a scroll by sending it an appropriate message, and let it handle the scroll bar, etc. I have tested this on a list-view control, the MASM32 example by Ewayne Wagner, and the message is  LVM_SCROLL (http://msdn2.microsoft.com/en-us/library/aa929191.aspx). I also tried scrolling an Explorer window, and even though the class name is the same, SysListView32, Send Message always returns ERROR (under Windows 2000 SP4).
Title: Re: Scrolling another app
Post by: Javer on September 19, 2007, 08:24:30 AM
It's scroll bar. Class Name is ScrollBar.
I tried to send various messages like LVM_SCROLL or WM_VSCROLL but with no success
Title: Re: Scrolling another app
Post by: MichaelW on September 19, 2007, 06:25:02 PM
The images show what appears to be a list of some sort, with a scroll bar that I think is probably a child of the control that contains the list. It is this control that I think you should target. Determine what it is, and then determine if there is a documented method of scrolling it. I posted an app  here (http://www.masm32.com/board/index.php?topic=6906.msg51199#msg51199) that may help you to identify the control(s).