[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

How do I gain Control when Win API call is running?

The application has 2 Forms, The 1st form is a menu and text editor,etc., the Second form scrolls form1 memo's text using ScrollWindowEx in a "for loop". Using buttons on the form2 or any control on form2 will not break out of, or stop the "for loop". I'm trying to pause the loop, then adjust the ScrollWindowEx params and resume. The loop starts when the form is activated.

I'm still learning, please help.  
0
sz3905
Asked:
sz3905
  • 2
1 Solution
 
erajojCommented:
Hi again Steve,
You could, for instance, use "Application.ProcessMessages"
inside the "for"-loop or...:

  procedure TSecondForm.BreakBtnClick(Sender: TObject);
  begin
    Discontinue := False;        // Break for loop
  end;
  ...
  ...
  ...
  procedure TSecondForm.ScrollFirstForm;
  { Tight loop, allowing processing of messages }
  begin
    Discontinue := False;          // Initially
    for Index := 0 to Whatever do begin
      ScrollSecondWindows;         // Lots and lots of scrolling
      Application.ProcessMessages; // Take care of buttons
      if Discontinue then Break;   // Exit for loop  
    end;
  end;

Or put the scrolling inside a "TTimer.OnTimer" event.

  procedure TSecondForm.BreakBtnClick(Sender: TObject);
  { Slow loop, processing of messages externally }
  begin
    ScrollTimer.Enabled := False;        // Stop scrolling
  end;
  ...
  ...
  ...
  procedure TSecondForm.ScrollTimerTimer(Sender: TObject);
  begin
    ScrollSecondWindows;         // Timed scrolling
  end;
 
Hope this helps!

/// John
0
 
sz3905Author Commented:
John, You truly are an expert!
Any Ideas where a novice can find an effective tutorial?
thx/steve/sbsullivan@ucdavis.edu
0
 
erajojCommented:
There are several books and lots and lots of examples on the Web.
A book is recommended (talk to your local retailer, probably a
better selection where you live).
I haven't found any tutorials on the Web, but send me your
address and I will provide you with what I have found and what
I will find in the near future.
john.johansson@era.ericsson.se

/// John

0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now