Results 1 to 9 of 9

Thread: wait() procedure in forms

  1. #1
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default wait() procedure in forms

    My script is working perfectly, but when i call a procedure that has this
    SCAR Code:
    Memo1.Text := 'YEAH I WIN';
    wait(2000);
    Memo1.Text := '...or do i?';
    wait(2000);
    resetgame;
    The script just freezes for like 4 seconds and skips to the resetgame procedure.
    How can i make the Memo text change, then wait a few secs, then change again, and then wait again?

  2. #2
    Join Date
    Feb 2009
    Location
    RP
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I'm not sure, but maybe your loading a text file with high bytes.

  3. #3
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Memo1.Repaint, call it when you call each text.

  4. #4
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    T := GetTickCount;
    While GetSystemTime - T < 2000 Do
    Begin
    GetApplication.ProcessMessages;
    Wait(1);
    End;

    Like that if I recall correctly.... You probably don't even need the Wait.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  5. #5
    Join Date
    Aug 2006
    Location
    London
    Posts
    2,021
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    use a TTimer, have it invoke a function which sets the memo text to what you want

    NaumanAkhlaQ's way will not solve the problem of the form being unresponsive

    Wizzup's way will work, but uses more cpu, since ProcessMessages often just yields control if theres nothing to do.

    source of knowledge
    Join the Official SRL IRC channel. Learn how to Here.

  6. #6
    Join Date
    Feb 2009
    Location
    Nebraska
    Posts
    68
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    T := GetTickCount;
    While GetSystemTime - T < 2000 Do
    Begin
    GetApplication.ProcessMessages;
    Wait(1);
    End;
    Be aware that while ProcessMessages allows the form to paint, it also makes buttons and such on the form responsive to user clicks. If you aren't expecting that it can sometimes cause problems.

    If you need to there are several ways to block the user input, the most straightforward of which is to just disable user controls so that they don't generate OnClick events.

    In general you should try to avoid blocking or spinning in the UI thread and instead use a technique like in Yakman's post, or create a new thread to handle the process (though that would be a lot of overhead for simple tasks like this. For more complicated tasks it can make the code easier to deal with).

  7. #7
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    I tried a timer, but didnt rly get it, so i made it the Wizzup way, but to prevent buttonclicks i disabled them, and after waiting enabled them again Now it's cool. Thanks alot fellas'!

    And oh,
    How to make my form unresizeable? Damn i looked hard but could not find the way!

  8. #8
    Join Date
    Feb 2009
    Location
    Nebraska
    Posts
    68
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by marpis View Post
    How to make my form unresizeable? Damn i looked hard but could not find the way!
    Go to Tools, Form Editor. Click on the blank form that comes up. Look in the Object Inspector to find 'Border Style'.


    (WTF, no images?)

    See the values in the combo box? bsSizeable is the default. bsSingle means that it won't allow resizing. bsDialog will also make it non-sizeable, For most purposes you can use whichever you perfer (there are some differences, but probably nothing that will affect you).

    So, go back to your code where you set the form up and put in a new line to set the BorderStyle.

    Remember, BorderStyle is a member of the form variable, so it'll either be something like

    Code:
    frmDesign.BorderStyle := bsSingle;
    or
    Code:
    with frmDesign do
    begin
       BorderStyle := bsSingle;
    end;

  9. #9
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    heh, thanks alot dude just
    "frmDesign.BorderStyle := bsSingle;"
    would have been great. I appreciate you obviously used time to help me
    rep + to you

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Wait Until Something.....
    By FortAsh in forum OSR Help
    Replies: 5
    Last Post: 01-29-2009, 05:09 PM
  2. I can't wait =D
    By Eugeniu in forum News and General
    Replies: 18
    Last Post: 09-28-2007, 12:59 AM
  3. Wait Until?
    By drnewheart in forum OSR Help
    Replies: 2
    Last Post: 09-23-2007, 02:49 AM
  4. wait()?
    By omgh4x0rz in forum Java Help and Tutorials
    Replies: 3
    Last Post: 04-28-2007, 02:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •