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. ATL / WTL / STL
  4. detect event in MFC dialog

detect event in MFC dialog

Scheduled Pinned Locked Moved ATL / WTL / STL
c++csharpvisual-studiocomquestion
10 Posts 4 Posters 14 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.
  • B Offline
    B Offline
    bkelly13
    wrote on last edited by
    #1

    Windows 7, Visual Studio 2008, MFC, C++ A thread is started when a dialog button is clicked. The thread performs some tasks than sets event 100, an arbitrary number for conversation. The dialog is to detect that event and display some text without user intervention. What can be done in the dialog to accomplish this?

    Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

    L 1 Reply Last reply
    0
    • B bkelly13

      Windows 7, Visual Studio 2008, MFC, C++ A thread is started when a dialog button is clicked. The thread performs some tasks than sets event 100, an arbitrary number for conversation. The dialog is to detect that event and display some text without user intervention. What can be done in the dialog to accomplish this?

      Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

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

      It would be a better idea to use the proper Windows mechanisms. When the thread has completed its task it should send a message to the dialog.

      B 1 Reply Last reply
      0
      • L Lost User

        It would be a better idea to use the proper Windows mechanisms. When the thread has completed its task it should send a message to the dialog.

        B Offline
        B Offline
        bkelly13
        wrote on last edited by
        #3

        Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events. MFC and the dialog are being used as a test vehicle to get close to the thread during development. Maybe I should switch to a console environment now. Or continue on a use a button to poll for events then update the status as appropriate.

        Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

        L A 3 Replies Last reply
        0
        • B bkelly13

          Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events. MFC and the dialog are being used as a test vehicle to get close to the thread during development. Maybe I should switch to a console environment now. Or continue on a use a button to poll for events then update the status as appropriate.

          Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

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

          bkelly13 wrote:

          an environment with no window and will set several events

          Without knowing how and where it sets these events it's difficult to suggest anything else. However, you may like to look into the various IPC mechanisms[^].

          1 Reply Last reply
          0
          • B bkelly13

            Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events. MFC and the dialog are being used as a test vehicle to get close to the thread during development. Maybe I should switch to a console environment now. Or continue on a use a button to poll for events then update the status as appropriate.

            Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

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

            Hi,

            bkelly13 wrote:

            Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events.

            Threads can have a messages queue on Microsoft Windows. How to post a thread message to a console application.[^] Using PostThreadMessage function[^] would be a great way to solve your issue. Potentially without creating additional threads. Best Wishes, -David Delaune

            M B 2 Replies Last reply
            0
            • L Lost User

              Hi,

              bkelly13 wrote:

              Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events.

              Threads can have a messages queue on Microsoft Windows. How to post a thread message to a console application.[^] Using PostThreadMessage function[^] would be a great way to solve your issue. Potentially without creating additional threads. Best Wishes, -David Delaune

              M Offline
              M Offline
              monitsystem
              wrote on last edited by
              #6

              Kamery do monitoringu - telewizja przemysłowa

              1 Reply Last reply
              0
              • L Lost User

                Hi,

                bkelly13 wrote:

                Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events.

                Threads can have a messages queue on Microsoft Windows. How to post a thread message to a console application.[^] Using PostThreadMessage function[^] would be a great way to solve your issue. Potentially without creating additional threads. Best Wishes, -David Delaune

                B Offline
                B Offline
                bkelly13
                wrote on last edited by
                #7

                That looks useful. My TCP app can post messages to a dialog so the user can determine the state of the thread. One dialog might display the status of several instances of the message app. I will have to figure out how the app will get the ID to that dialog, but it may well be useful. Thank you for the tip.

                Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

                1 Reply Last reply
                0
                • B bkelly13

                  Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events. MFC and the dialog are being used as a test vehicle to get close to the thread during development. Maybe I should switch to a console environment now. Or continue on a use a button to poll for events then update the status as appropriate.

                  Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

                  A Offline
                  A Offline
                  Albert Holguin
                  wrote on last edited by
                  #8

                  Messaging is likely the best alternative (although not the only option). It is also common for people to make invisible windows simply for the messaging mechanism (instead of handling it by hand as in the article below). Your other alternative could be to have the window occasionally check a critical section (or mutex) protected variable to know the current state.

                  B 1 Reply Last reply
                  0
                  • A Albert Holguin

                    Messaging is likely the best alternative (although not the only option). It is also common for people to make invisible windows simply for the messaging mechanism (instead of handling it by hand as in the article below). Your other alternative could be to have the window occasionally check a critical section (or mutex) protected variable to know the current state.

                    B Offline
                    B Offline
                    bkelly13
                    wrote on last edited by
                    #9

                    This MFC dialog is just a test vehicle to develop the classes and thread that will perform all the TCP/IP I/O. I will add a button to poll the events set by the TCP code, or maybe a button that starts a timer that leads to a poll every couple of seconds. Thanks for taking the time to reply.

                    Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

                    A 1 Reply Last reply
                    0
                    • B bkelly13

                      This MFC dialog is just a test vehicle to develop the classes and thread that will perform all the TCP/IP I/O. I will add a button to poll the events set by the TCP code, or maybe a button that starts a timer that leads to a poll every couple of seconds. Thanks for taking the time to reply.

                      Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

                      A Offline
                      A Offline
                      Albert Holguin
                      wrote on last edited by
                      #10

                      I use the polling method for high-frequency updates to a GUI. Since messaging can lead to a flood of messages updating things at such a high-rate you probably wouldn't make out the least significant digits.

                      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