Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. who will create the message loop and message queue?

who will create the message loop and message queue?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++data-structures
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vasu_sri
    wrote on last edited by
    #1

    in win32, where will keep the all messages are generated by the window? and how do know this message is belongs to this window? and who will maintain the message queue? what happand in background? what is the code in c++? what are the methods are fallows in background?

    Regards, Srinivas

    L S 2 Replies Last reply
    0
    • V vasu_sri

      in win32, where will keep the all messages are generated by the window? and how do know this message is belongs to this window? and who will maintain the message queue? what happand in background? what is the code in c++? what are the methods are fallows in background?

      Regards, Srinivas

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Every thread has its own message queue that is setup by the system into which it posts the messages. Now that you have a start, dig into MSDN.

      ...byte till it megahertz... my donation to web rubbish

      C 1 Reply Last reply
      0
      • V vasu_sri

        in win32, where will keep the all messages are generated by the window? and how do know this message is belongs to this window? and who will maintain the message queue? what happand in background? what is the code in c++? what are the methods are fallows in background?

        Regards, Srinivas

        S Offline
        S Offline
        Sauro Viti
        wrote on last edited by
        #3

        There are lots of things to say about your question. Let's say:

        • the operating system handle a message queue for each thread in your process;
        • it's up to you to write down the message loop for each thread
        • each time you call the DispatchMessage from your message loop, the message is dispatched to the window procedure of the window to which the message is targeted

        To learn about this topic, start from Messages and Message Queues (Windows)[^]

        V 1 Reply Last reply
        0
        • L Lost User

          Every thread has its own message queue that is setup by the system into which it posts the messages. Now that you have a start, dig into MSDN.

          ...byte till it megahertz... my donation to web rubbish

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          bleedingfingers wrote:

          Every thread has its own message queue that is setup by the system into which it posts the messages.

          That's not completely true, see The Old New Thing - In pursuit of the message queue. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          L 1 Reply Last reply
          0
          • C CPallini

            bleedingfingers wrote:

            Every thread has its own message queue that is setup by the system into which it posts the messages.

            That's not completely true, see The Old New Thing - In pursuit of the message queue. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            CPallini wrote:

            bleedingfingers wrote: Every thread has its own message queue that is setup by the system into which it posts the messages. That's not completely true, see The Old New Thing - In pursuit of the message queue.

            I know I know. And one would have to use PeekMessage(...) to force a queue to be created but I just gave him a start. Now, let him wipe that e-dust off his MSDN will ya ;)

            ...byte till it megahertz... my donation to web rubbish

            R 1 Reply Last reply
            0
            • L Lost User

              CPallini wrote:

              bleedingfingers wrote: Every thread has its own message queue that is setup by the system into which it posts the messages. That's not completely true, see The Old New Thing - In pursuit of the message queue.

              I know I know. And one would have to use PeekMessage(...) to force a queue to be created but I just gave him a start. Now, let him wipe that e-dust off his MSDN will ya ;)

              ...byte till it megahertz... my donation to web rubbish

              R Offline
              R Offline
              Rajesh R Subramanian
              wrote on last edited by
              #6

              [Edit] I overlooked it - A 5 vote is offered. :) [/Edit]

              There are some really weird people on this planet - MIM.

              modified on Monday, October 18, 2010 1:52 PM

              1 Reply Last reply
              0
              • S Sauro Viti

                There are lots of things to say about your question. Let's say:

                • the operating system handle a message queue for each thread in your process;
                • it's up to you to write down the message loop for each thread
                • each time you call the DispatchMessage from your message loop, the message is dispatched to the window procedure of the window to which the message is targeted

                To learn about this topic, start from Messages and Message Queues (Windows)[^]

                V Offline
                V Offline
                vasu_sri
                wrote on last edited by
                #7

                who will create a thread and message queue? what relation ship between operating system, thread, message queue, and application?

                Regards, Srinivas

                S 1 Reply Last reply
                0
                • V vasu_sri

                  who will create a thread and message queue? what relation ship between operating system, thread, message queue, and application?

                  Regards, Srinivas

                  S Offline
                  S Offline
                  Sauro Viti
                  wrote on last edited by
                  #8

                  vasu_sri wrote:

                  who will create a thread and message queue?

                  The first thread is created by the operating system when you start an application. Other threads will be created by the application itself, for example by calling the CreateThread Function (Windows)[^]. A message queue is created and maintained by the operating system; the OS creates it only when needed, i.e. when your thread creates a window or calls any function that involves message queues.

                  vasu_sri wrote:

                  what relation ship between operating system, thread, message queue, and application?

                  It's a very generic question, and answer it requires thousands of words... Have you had a look at the documentation on MSDN that I suggested you?

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups