?
Solved

ScrollBar....

Posted on 2003-02-21
10
Medium Priority
?
238 Views
Last Modified: 2010-04-04
Hi experts.

I would like som code that could scroll in aonther program, by just having the main windows handle.

So i want a procedure like:
Procedure ScroolUp(handle:thandle);
...
Procedure ScroolDown(handle:thandle);

Hope you understand what i mean.

ps. i dont want an easy solution where the mouse gets moved or something like that...
0
Comment
Question by:Dennis9
9 Comments
 
LVL 6

Accepted Solution

by:
DaFox earned 100 total points
ID: 7997236
Hi Dennis.

That depends on what window (control) you want to scroll.
E.g. this scrolls the notepad (vertical) scrollbar:

procedure ScrollDown(WndHandle: THandle);
var
  ChildHandle: hWnd;
begin
  ChildHandle := GetWindow(WndHandle, GW_CHILD);
  PostMessage(ChildHandle, EM_SCROLL, SB_LINEDOWN, 0);
end;

procedure ScrollUp(WndHandle: THandle);
var
  ChildHandle: hWnd;
begin
  ChildHandle := GetWindow(WndHandle, GW_CHILD);
  PostMessage(ChildHandle, EM_SCROLL, SB_LINEUP, 0);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ScrollDown(FindWindow('Notepad', nil));
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  ScrollUp(FindWindow('Notepad', nil));
end;

Markus
0
 
LVL 3

Assisted Solution

by:LukA_YJK
LukA_YJK earned 100 total points
ID: 7998038
I think the standard TWinControl has such a method: ScrollBy. So you can use this method in every descendand including TForm.
0
 
LVL 1

Author Comment

by:Dennis9
ID: 8000247
LukA_YJK -> can u tell me more about it?

DaFox -> yeah it works in notepad, but why not other places?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:LukA_YJK
ID: 8006577
Seems ScrollBy is not what you need. Sorry, I did not notice it in a hurry. Because it is working only with an Object, not with a Handle.
Anyhow, you can probably write Form1.ScrolBy(50,50); it scrolls the contents of a windowed control, look at the VCL Help: procedure ScrollBy(DeltaX, DeltaY: Integer);
Maybe its source will help you somehow:

procedure TWinControl.ScrollBy(DeltaX, DeltaY: Integer);
var
  IsVisible: Boolean;
  I: Integer;
  Control: TControl;
begin
  IsVisible := (FHandle <> 0) and IsWindowVisible(FHandle);
  if IsVisible then ScrollWindow(FHandle, DeltaX, DeltaY, nil, nil);
  for I := 0 to ControlCount - 1 do
  begin
    Control := Controls[I];
    if not (Control is TWinControl) or (TWinControl(Control).FHandle = 0) then
    begin
      Inc(Control.FLeft, DeltaX);
      Inc(Control.FTop, DeltaY);
    end else
      if not IsVisible then
        with TWinControl(Control) do
          SetWindowPos(FHandle, 0, FLeft + DeltaX, FTop + DeltaY,
            FWidth, FHeight, SWP_NOZORDER + SWP_NOACTIVATE);
  end;
  Realign;
end;
0
 
LVL 1

Author Comment

by:Dennis9
ID: 8291516
Ok it seems like it all went a bit dead here.

It dont seems like it can be done the smart way then.

So what if i want to use the not cool version like:

pt:tpoint;
begin
getcursorpos(pt);

//Get the posistion of the scrollbar and click with mouse

setcursorpos(pt);
end;


any ideas?
0
 
LVL 1

Author Comment

by:Dennis9
ID: 8291519
what about sending the message that the mousewheel use?
0
 

Expert Comment

by:CleanupPing
ID: 9317130
Dennis9:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 1

Author Comment

by:Dennis9
ID: 9317741
Anybody have and idea on how this could be done?
The most comon way i know is getting cordinates to scroll arrow, then simulate mouse clicks. Maybe thats the only way?
0
 
LVL 10

Expert Comment

by:kacor
ID: 9948089
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       the answers contains useful information, it would be mistake to delete,
       but the original question is not solved
       to split points between DaFox and LukA_YJK
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Some days and here is the Christmas Time. I wish good luck and good health for you all and for your loved ones

kacor
EE Cleanup Volunteer
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Suggested Courses
Course of the Month8 days, 13 hours left to enroll

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question