Processing Messages

This is a discussion on Processing Messages within the Windows Programming forums, part of the Platform Specific Boards category; If I have some code that is executing that takes a while to complete is there any way to process ...

  1. #1
    Anal comment spacer DominicTrix's Avatar
    Join Date
    Apr 2002
    Posts
    120

    Question Processing Messages

    If I have some code that is executing that takes a while to complete is there any way to process messages at the same time??

    i.e. if I have some code like this (below), where the program is stuck in a loop for 100000 milliseconds, is there anyway to process say a mouseclick while it is running?

    -------------------------------
    timeInterval = 100000
    lastCount = GetTickCount;

    do{
    Count = GetTickCount;
    } while(Count < (LastCount+timInterval))
    -------------------------------

    Alternatively, is there any way to switch off certain inputs while code is running. e.g. if a user was to click a mouse button while the above code was running the mouse click message would be ignored completely so that it doesn't get processed even after the code has completed.

    This may sound the opposite, but my problem is that I have some code similar to the above and I want to disable mouse clicking whilst it is running. I tried using conditions to test if the code was running or not in the mouse click message handler but by the time the message was processed these conditions would always show that it wasn't (because the mouse click message obviously wouldnt be processed till the code was finished).

    So I thought that the solution would either be to process the mouse click instantly (and test to see if the code is running), or to disable mouse clicking messages whilst the code was running.

    Hope this makes sense! (?)

    thanks in advance

    dt

  2. #2
    Nor
    Nor is offline
    h ֆhr s Nor's Avatar
    Join Date
    Nov 2001
    Posts
    299
    If I have some code that is executing that takes a while to complete is there any way to process messages at the same time??
    I have no idea of what you are asking.

    if I have some code like this (below), where the program is stuck in a loop for 100000 milliseconds, is there anyway to process say a mouseclick while it is running?
    This is a question in which you need to be more specific.
    If you set up a thread then yes. But your loop needs to be inside of that thread.
    If you do it inside the message loop of a windows application, then I believe you will freeze the computer for a period of time.
    I could me wrong, so you will have to try it to find out for sure.
    Try to help all less knowledgeable than yourself, within
    the limits provided by time, complexity and tolerance.
    - Nor

  3. #3
    Nor
    Nor is offline
    h ֆhr s Nor's Avatar
    Join Date
    Nov 2001
    Posts
    299
    Sorry didn't read all the why throught it the first time.

    So I thought that the solution would either be to process the mouse click instantly (and test to see if the code is running), or to disable mouse clicking messages whilst the code was running.
    You can setup a system hook to catch the mouse clicks and stop anything else from processing them. But why would you want to do that?
    Search for "system hook" on the board and it should show you what you want to know.
    Try to help all less knowledgeable than yourself, within
    the limits provided by time, complexity and tolerance.
    - Nor

  4. #4
    Anal comment spacer DominicTrix's Avatar
    Join Date
    Apr 2002
    Posts
    120
    Thanks, what I've done is created custom buttons that are simply RECT structures which I paint the button graphics to. I repaint the buttons and/or execute other code when the window receives a mouse message with the co-ordinates within the button RECT.

    So basically I wanted to be able to disable these buttons while certain stuff was going on. (why didn't I ask that before, hmm??!).
    I realise that I could use buttons with BS_BITMAP and simply disable them, but the windows buttons do stuff that I dont want and I cant seem to get rid of the horrible grey border of the button around my bitmap.

    Anyways, thanks again, I'll look it up

  5. #5
    Anal comment spacer DominicTrix's Avatar
    Join Date
    Apr 2002
    Posts
    120
    If you set up a thread then yes

    AAAaaaaahhhhhhh I've just discovered threads and everything makes sense :-)))))))

    Basically the 'code' wasn't a thread but simply a function that was called after a particular message was recieved. Therefor, while the function was running, no other messages could be processed. I've made it a thread now and everything is fabby!

    thnx
    Last edited by DominicTrix; 04-23-2002 at 07:00 PM.
    "The most important thing about acting is honesty. If you can fake that you've got it made" - George Burns

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. processing window messages w/out DispatchMessage ()
    By xixpsychoxix in forum Windows Programming
    Replies: 10
    Last Post: 01-18-2009, 09:07 PM
  2. Spy++ view messages posted/sent to a control, or from it?
    By hanhao in forum Windows Programming
    Replies: 2
    Last Post: 06-24-2007, 11:07 PM
  3. Sending windows messages
    By Ideswa in forum Windows Programming
    Replies: 2
    Last Post: 03-02-2006, 12:27 PM
  4. file writing crashes
    By test in forum C Programming
    Replies: 25
    Last Post: 08-13-2002, 08:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21