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. VS 2005 MFC Program Always In Focus

VS 2005 MFC Program Always In Focus

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studioquestion
11 Posts 3 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.
  • A Andy202

    I have a typical MFC program with lots of control and display items on its dialog. Several Timers control to regular updates. But I have just started to notice that the focus is always returning back to my program when its running. This is every second - the main Timer rate. I think I must have set some properity - but which one?!? So I have to close down the program to do anything else on the computer. ANy suggestions please Windows XP Pro; MFC C++ on VS 2005. Cheers

    C Offline
    C Offline
    Cedric Moonen
    wrote on last edited by
    #2

    Well, post some of code of what you are doing when the timer fires.

    Cédric Moonen Software developer
    Charting control [v1.4] OpenGL game tutorial in C++

    A 1 Reply Last reply
    0
    • C Cedric Moonen

      Well, post some of code of what you are doing when the timer fires.

      Cédric Moonen Software developer
      Charting control [v1.4] OpenGL game tutorial in C++

      A Offline
      A Offline
      Andy202
      wrote on last edited by
      #3

      This would be a lot of code:- Basically I update checkbox, textboxes, some ActiveX controls and enable/disable pushbuttons. Call other procedures. I was hoping that the dialog or one of the control had some sort of 'always-in-focus' set? Andy.

      1 Reply Last reply
      0
      • A Andy202

        I have a typical MFC program with lots of control and display items on its dialog. Several Timers control to regular updates. But I have just started to notice that the focus is always returning back to my program when its running. This is every second - the main Timer rate. I think I must have set some properity - but which one?!? So I have to close down the program to do anything else on the computer. ANy suggestions please Windows XP Pro; MFC C++ on VS 2005. Cheers

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #4

        Have you tried disabling some of those timers to see if they are at fault? Do you have any calls to SetFocus()?

        "Love people and use things, not love things and use people." - Unknown

        "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

        A 1 Reply Last reply
        0
        • D David Crow

          Have you tried disabling some of those timers to see if they are at fault? Do you have any calls to SetFocus()?

          "Love people and use things, not love things and use people." - Unknown

          "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

          A Offline
          A Offline
          Andy202
          wrote on last edited by
          #5

          Hi David, I have two Timers; 1 at 150 ms and 1 at 1000 ms. If I switch them off no problems. However I did have a look at a simular program and it used several Timers and that runs OK, GUI will still update when focus is lost. So still confused!?! Andy.

          D 1 Reply Last reply
          0
          • A Andy202

            Hi David, I have two Timers; 1 at 150 ms and 1 at 1000 ms. If I switch them off no problems. However I did have a look at a simular program and it used several Timers and that runs OK, GUI will still update when focus is lost. So still confused!?! Andy.

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #6

            Andy202 wrote:

            If I switch them off no problems.

            Meaning that if the app is minimized or not on top, it will stay as such?

            "Love people and use things, not love things and use people." - Unknown

            "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

            A 1 Reply Last reply
            0
            • D David Crow

              Andy202 wrote:

              If I switch them off no problems.

              Meaning that if the app is minimized or not on top, it will stay as such?

              "Love people and use things, not love things and use people." - Unknown

              "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

              A Offline
              A Offline
              Andy202
              wrote on last edited by
              #7

              I can minimize the application into the System Tray, but the problem still remains. No other application can hold focus. I have check as many proprities as I can and they all seem set OK.

              D 1 Reply Last reply
              0
              • A Andy202

                I can minimize the application into the System Tray, but the problem still remains. No other application can hold focus. I have check as many proprities as I can and they all seem set OK.

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #8

                What are you doing in response to the 1000ms timer?

                "Love people and use things, not love things and use people." - Unknown

                "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                A 1 Reply Last reply
                0
                • D David Crow

                  What are you doing in response to the 1000ms timer?

                  "Love people and use things, not love things and use people." - Unknown

                  "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                  A Offline
                  A Offline
                  Andy202
                  wrote on last edited by
                  #9

                  All I am doing is enable or disable buttons and checkboxes on the dialog - running a watchdog function to keep everything logical.

                  D 1 Reply Last reply
                  0
                  • A Andy202

                    All I am doing is enable or disable buttons and checkboxes on the dialog - running a watchdog function to keep everything logical.

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #10

                    Andy202 wrote:

                    All I am doing is enable or disable buttons and checkboxes on the dialog...

                    If you leave the timer code in place but comment out the enable/disable statements, what does that produce?

                    "Love people and use things, not love things and use people." - Unknown

                    "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                    A 1 Reply Last reply
                    0
                    • D David Crow

                      Andy202 wrote:

                      All I am doing is enable or disable buttons and checkboxes on the dialog...

                      If you leave the timer code in place but comment out the enable/disable statements, what does that produce?

                      "Love people and use things, not love things and use people." - Unknown

                      "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                      A Offline
                      A Offline
                      Andy202
                      wrote on last edited by
                      #11

                      Hi David. The problem was this line:-

                      m_cModeDisplay.SetForegroundWindow();

                      I don’t know why I put it in, but it’s the usual case when you loose something they are probably in the first place you looked, but you sometimes don't look properly! For the same reason I thought that the problem was setting some property of the dialog, but I needed to debug the program and try and locate the area and then the line that was the problem! I just needed someone to deflect me from my perceived view of the problem so that I could find the real problem. Many thanks. Andy.

                      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