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. Window activation

Window activation

Scheduled Pinned Locked Moved C / C++ / MFC
help
10 Posts 4 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.
  • K Offline
    K Offline
    KKumarTG
    wrote on last edited by
    #1

    Hi, I have a program, which has a timer and dialog. Program purpose is to set the window on top most and active in a specified interval. Problem is that the dialog is getting on the top most. That is ok. But not getting activated ( No focus ). Please see the code: void CTestSetWPosDlg::OnTimer( UINT nIDEvent ) { CDialog::OnTimer( nIDEvent ); SYSTEMTIME stSystemTime; GetLocalTime( &stSystemTime ); CString csTime; csTime.Format( "%d:%d", stSystemTime.wMinute, stSystemTime.wSecond ); SetWindowText( csTime.operator LPCTSTR()); SetWindowPos( &wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_ASYNCWINDOWPOS ); SetActiveWindow(); } Krishnakumar

    S A 2 Replies Last reply
    0
    • K KKumarTG

      Hi, I have a program, which has a timer and dialog. Program purpose is to set the window on top most and active in a specified interval. Problem is that the dialog is getting on the top most. That is ok. But not getting activated ( No focus ). Please see the code: void CTestSetWPosDlg::OnTimer( UINT nIDEvent ) { CDialog::OnTimer( nIDEvent ); SYSTEMTIME stSystemTime; GetLocalTime( &stSystemTime ); CString csTime; csTime.Format( "%d:%d", stSystemTime.wMinute, stSystemTime.wSecond ); SetWindowText( csTime.operator LPCTSTR()); SetWindowPos( &wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_ASYNCWINDOWPOS ); SetActiveWindow(); } Krishnakumar

      S Offline
      S Offline
      shilianghui2
      wrote on last edited by
      #2

      you should get the return value of SetActiveWindow.if the return value is null,it means failure.then you can call GetLastError and get the error code.you can use the error lookup tool to get the reason for the failure.

      K 1 Reply Last reply
      0
      • S shilianghui2

        you should get the return value of SetActiveWindow.if the return value is null,it means failure.then you can call GetLastError and get the error code.you can use the error lookup tool to get the reason for the failure.

        K Offline
        K Offline
        KKumarTG
        wrote on last edited by
        #3

        SetActivateWindow function returns the same window handle Krishnakumar

        S 2 Replies Last reply
        0
        • K KKumarTG

          SetActivateWindow function returns the same window handle Krishnakumar

          S Offline
          S Offline
          shilianghui2
          wrote on last edited by
          #4

          are you sure?that means your window is active.

          1 Reply Last reply
          0
          • K KKumarTG

            SetActivateWindow function returns the same window handle Krishnakumar

            S Offline
            S Offline
            shilianghui2
            wrote on last edited by
            #5

            maybe you can use SetFocus.

            K 1 Reply Last reply
            0
            • S shilianghui2

              maybe you can use SetFocus.

              K Offline
              K Offline
              KKumarTG
              wrote on last edited by
              #6

              Tried. Still dialog has no focus. :-( Krishnakumar

              S 1 Reply Last reply
              0
              • K KKumarTG

                Tried. Still dialog has no focus. :-( Krishnakumar

                S Offline
                S Offline
                shilianghui2
                wrote on last edited by
                #7

                try to use the SetForegroundWindow.

                K 1 Reply Last reply
                0
                • S shilianghui2

                  try to use the SetForegroundWindow.

                  K Offline
                  K Offline
                  KKumarTG
                  wrote on last edited by
                  #8

                  Icon in the task bar is flashing... Krishnakumar

                  N 1 Reply Last reply
                  0
                  • K KKumarTG

                    Icon in the task bar is flashing... Krishnakumar

                    N Offline
                    N Offline
                    Nibu babu thomas
                    wrote on last edited by
                    #9

                    KKumarTG wrote:

                    Icon in the task bar is flashing...

                    BringWindowToTop :~


                    Nibu thomas A Developer Programming tips[^]  My site[^]

                    1 Reply Last reply
                    0
                    • K KKumarTG

                      Hi, I have a program, which has a timer and dialog. Program purpose is to set the window on top most and active in a specified interval. Problem is that the dialog is getting on the top most. That is ok. But not getting activated ( No focus ). Please see the code: void CTestSetWPosDlg::OnTimer( UINT nIDEvent ) { CDialog::OnTimer( nIDEvent ); SYSTEMTIME stSystemTime; GetLocalTime( &stSystemTime ); CString csTime; csTime.Format( "%d:%d", stSystemTime.wMinute, stSystemTime.wSecond ); SetWindowText( csTime.operator LPCTSTR()); SetWindowPos( &wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_ASYNCWINDOWPOS ); SetActiveWindow(); } Krishnakumar

                      A Offline
                      A Offline
                      anwer_skk
                      wrote on last edited by
                      #10

                      SetForegroundWindow() is working fine in my sample application. SetActiveWindow() only activates the window if the calling thread is foreground thread. Please see the KB http://support.microsoft.com/default.aspx?kbid=97925

                      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