Results 1 to 8 of 8

Thread: Pausing a function

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2002
    Posts
    20

    Pausing a function

    You know, if you create a message box by AfxMessageBox(...)
    function, you might aware of that, the function do not return until user clicks the appropriate button e.g. Cancel, OK, Yes, No... etc.
    It seems the function waits until user presses a button instead of returning a value. A function completes execution usually in a few miliseconds. But its unusual for a function to wait for an unlimited time.
    I have thought about it, but got no idea on how to do that.

    Would you please share, if you have any idea.

  2. #2
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    psudocode:

    function
    {
    show messagebox
    if(yes)
    return yes;
    else if(no)
    return no;
    }

  3. #3
    Fanatic Member Mushroom Realm's Avatar
    Join Date
    Mar 2002
    Location
    Murrieta, California
    Posts
    650
    int main()
    {
    short paused;
    //set it to be paused
    paused=1;
    while(paused==1)
    code;
    code;
    code;
    code;

    //make sure u can unpause it
    paused=0;
    loop;
    }

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Sleep(time);

    or the Wait* family

    WaitForSingleObject(hEvent);
    will wait until another thread fires the event referenced by hEvent.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2002
    Posts
    20
    Thank you very much SteveCRM, Mushroom Realm and CornedBee.
    The thing I want to do is to avoid a function from returning a value untill the user clicks on the defined coordinates. I think CornedBee`s reply is the solution of my problem.
    Would you please give some details on how to adaptate WaitForSingleObject(...) function to my code.

    Again, thank you all for your replies.

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Show me your code and I'll tell you how to implement it.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Apr 2002
    Posts
    20
    I don`t know how to write write that code, exactly. But when the function is called, it handles mouse-down messages and checks if the mouse-down point is in the specified area; if it is, the function returns true, if not, it continues handling messages and checking if the expression is true.

    My limited knowledge in C++ doesn`t seem to be enough to code that function, but I need it very badly, to complete my project.

    Would you please help.
    Thanks in advance.

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I don't think I really understand what you're trying to do, since the way I interpret your explanation it would be a completly senseless thing to do.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width