Message loop?

This is a discussion on Message loop? within the Windows Programming forums, part of the Platform Specific Boards category; I am having a bit of trouble understanding why the message loop is important. So lets say the user types ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    51

    Message loop?

    I am having a bit of trouble understanding why the message loop is important. So lets say the user types in A which goes into the message queue. THEN the message loop takes it and then sends it back? This is the part I don't understand. Why does it send it back to windows. Wouldn't it be simpler just to have windows either send it directly to windows procedure OR have message loop send it to the windows procedure?

  2. #2
    Registered User
    Join Date
    Jul 2007
    Posts
    36
    The message loop blocks execution (duh) so that ProcessMessage() can process the messages of the window. This involves drawing the window or windows and processing other controls. I could if I wanted create GUI system but if I want the window to stay open until it is closed I need some way of continuously drawing it and processing its messages. If there is no message loop the window will only be drawn once and its messages processed once. I think windows has too much to do to worry about processing windows. Besides, you want the window to run in the application's thread, not the systems.

  3. #3
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Winprog has a page with just your question.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Desperate Over Ecs!
    By cookie in forum C Programming
    Replies: 17
    Last Post: 07-16-2008, 01:25 PM
  2. Window message loop (Keys)
    By Blackroot in forum Windows Programming
    Replies: 3
    Last Post: 09-12-2006, 05:15 PM
  3. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 07:26 PM
  4. Help, the window gets killed......
    By incognito in forum Game Programming
    Replies: 2
    Last Post: 05-28-2002, 02:22 PM

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