?
Solved

ScrollBar....

Posted on 2003-02-21
10
Medium Priority
?
236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 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
Industry Leaders: 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

766 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