How to scroll the scrollbar in external applicatio

2019-07-27 11:06发布

问题:

Description

I'm trying to test application coded in Delphi (VCL components by DevEx) with TestComplete. Application is built without debug info.

I need to scroll TcxTreeList component. The problem is when I set Position property for this component's scrollbars content is not scrolled but scroll bar position changes. I tried a lot of approaches and suppose that WinAPI can help me.

The Question:

How to scroll the scrollbar in external application via WinAPI?

I found PostMessage function, but I do not know how to synthesize WM_SCROLL message...

回答1:

Scroll one line down (you can see other constants at the page JustBoo mentions);

PostMessage(HWnd, WM_VSCROLL, SB_LINEDOWN, 0)

Scroll to a specific position;

PostMessage(HWnd, WM_VSCROLL, MakeWParam(SB_THUMBPOSITION, 30), 0)


But if you refer to this page on the Devex forums, it is mentioned that "ScrollBar in the cxTreeList it is another control, not standard windows scrollbar". So it might not work. In this case you might want to try ScrollWindowEx coupled with setting the position as you already do.



回答2:

These links should show how to setup the parameters to a PostMessage call for scrolling.

WM_HSCROLL Message

WM_VSCROLL Message



标签: winapi scroll