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#
  4. c# program to move a window on desktop from a side to another when it looses focus

c# program to move a window on desktop from a side to another when it looses focus

Scheduled Pinned Locked Moved C#
questioncsharp
14 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.
  • A Offline
    A Offline
    ayandelhi
    wrote on last edited by
    #1

    I know i ask lots of question... M sorry to keep bugging... I wanted to know if i can make such a program which on running, can make the active window (if not maximized) to come in center of the desktop. and when that window looses focus, it is moved to a side... Every window which is not maximized shud be affected by it... Can I??? Plz enlight me with knowledge abt it...

    N P 2 Replies Last reply
    0
    • A ayandelhi

      I know i ask lots of question... M sorry to keep bugging... I wanted to know if i can make such a program which on running, can make the active window (if not maximized) to come in center of the desktop. and when that window looses focus, it is moved to a side... Every window which is not maximized shud be affected by it... Can I??? Plz enlight me with knowledge abt it...

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      You would need to use an API method such and FindWindow to locate all of the windows but hooking into them to override the locations and behaviors is not worth the effort IMO.


      I know the language. I've read a book. - _Madmatt

      1 Reply Last reply
      0
      • A ayandelhi

        I know i ask lots of question... M sorry to keep bugging... I wanted to know if i can make such a program which on running, can make the active window (if not maximized) to come in center of the desktop. and when that window looses focus, it is moved to a side... Every window which is not maximized shud be affected by it... Can I??? Plz enlight me with knowledge abt it...

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Is that what your users would want to have happen?

        OriginalGriffO A 2 Replies Last reply
        0
        • P PIEBALDconsult

          Is that what your users would want to have happen?

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          I have to agree, it would annoy the crap out of me...

          Did you know: That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          1 Reply Last reply
          0
          • P PIEBALDconsult

            Is that what your users would want to have happen?

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

            i want to make a program which can replace the desktop window manager in window... i want my program to handle all the open windows like the way i want it to... is it possible... a window opens it comes to center. when it looses focus of when i'm done with it it goes to either side of screen.. Dwm does it in a different way, it minimizes the windows to taskbar until again activated..and it restores the window in the last opened place...

            P 1 Reply Last reply
            0
            • A ayandelhi

              i want to make a program which can replace the desktop window manager in window... i want my program to handle all the open windows like the way i want it to... is it possible... a window opens it comes to center. when it looses focus of when i'm done with it it goes to either side of screen.. Dwm does it in a different way, it minimizes the windows to taskbar until again activated..and it restores the window in the last opened place...

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              Based on this and the other post I think you need to write your own operating system.

              A 1 Reply Last reply
              0
              • P PIEBALDconsult

                Based on this and the other post I think you need to write your own operating system.

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

                Really... doesn't any namespace can help me with this... C# has so many namespaces... u must be knowing some which can handle the windows...

                D P 2 Replies Last reply
                0
                • A ayandelhi

                  Really... doesn't any namespace can help me with this... C# has so many namespaces... u must be knowing some which can handle the windows...

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #8

                  It is likely possible, but probably very difficult, error-prone, and unlikely to be welcome to the user. All-in-all it's not worth the trouble.

                  A 1 Reply Last reply
                  0
                  • A ayandelhi

                    Really... doesn't any namespace can help me with this... C# has so many namespaces... u must be knowing some which can handle the windows...

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    He's correct. If you want a smooth version of this, you'd have to rewrite part of the Win32 API. There is no namespace or class in the .NET Framework that can do this for you. The only way you can do it is if you used a couple of the Win32 API functions, constantly polling for the foreground window and moving it when it appears. This will introduce a flicker as you have to wait for the window to show up in one spot then move it, painting the window twice in two different spots. There is no way to avoid this.

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak

                    A 1 Reply Last reply
                    0
                    • P PIEBALDconsult

                      It is likely possible, but probably very difficult, error-prone, and unlikely to be welcome to the user. All-in-all it's not worth the trouble.

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

                      m ready to do the hard work... m ready to do it... just guide me.. plz.. i wanna make this application... guide me...

                      D 1 Reply Last reply
                      0
                      • D Dave Kreskowiak

                        He's correct. If you want a smooth version of this, you'd have to rewrite part of the Win32 API. There is no namespace or class in the .NET Framework that can do this for you. The only way you can do it is if you used a couple of the Win32 API functions, constantly polling for the foreground window and moving it when it appears. This will introduce a flicker as you have to wait for the window to show up in one spot then move it, painting the window twice in two different spots. There is no way to avoid this.

                        A guide to posting questions on CodeProject[^]
                        Dave Kreskowiak

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

                        the problem u are mentioning... is tolerable.. i mean.. first let it be allowed to open as it opens then my program can take control of it... wat say...

                        D 1 Reply Last reply
                        0
                        • A ayandelhi

                          the problem u are mentioning... is tolerable.. i mean.. first let it be allowed to open as it opens then my program can take control of it... wat say...

                          D Offline
                          D Offline
                          Dave Kreskowiak
                          wrote on last edited by
                          #12

                          I say it looks cheesy and is of no benefit to users.

                          A guide to posting questions on CodeProject[^]
                          Dave Kreskowiak

                          A 1 Reply Last reply
                          0
                          • A ayandelhi

                            m ready to do the hard work... m ready to do it... just guide me.. plz.. i wanna make this application... guide me...

                            D Offline
                            D Offline
                            Dave Kreskowiak
                            wrote on last edited by
                            #13

                            ayandelhi wrote:

                            m ready to do the hard work... m ready to do it...

                            But are your users ready to use it?

                            A guide to posting questions on CodeProject[^]
                            Dave Kreskowiak

                            1 Reply Last reply
                            0
                            • D Dave Kreskowiak

                              I say it looks cheesy and is of no benefit to users.

                              A guide to posting questions on CodeProject[^]
                              Dave Kreskowiak

                              A Offline
                              A Offline
                              ayandelhi
                              wrote on last edited by
                              #14

                              m making it for myself... i wanna learn abt wat m thinking... i am wondering about this night and day... i just dont know the way.. m not goin to prove anything to anyone.. i want to make it for myself and only for myself...

                              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