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. Jumping Window ?

Jumping Window ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
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.
  • C Offline
    C Offline
    CrocodileBuck
    wrote on last edited by
    #1

    Hi, I've made a little Window with the MFC, but when reposition the window and then select new, the window jums some lines down and some lines right. Did you know how i could avoid this ? void CTestView::OnFileNew() { CRect rc; GetWindowRect (&rc); CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd(); CClientDC dc(this); dc.SetMapMode (MM_TEXT); dc.LPtoDP (&rc); // ClientToScreen (&rc); pFrame->SetWindowPos (&CWnd::wndTop, rc.left, rc.top, 200, 100 ,SWP_NOREPOSITION); } Here is my codr, i hope you can help me ! Many THX CrocodileBuck

    M 1 Reply Last reply
    0
    • C CrocodileBuck

      Hi, I've made a little Window with the MFC, but when reposition the window and then select new, the window jums some lines down and some lines right. Did you know how i could avoid this ? void CTestView::OnFileNew() { CRect rc; GetWindowRect (&rc); CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd(); CClientDC dc(this); dc.SetMapMode (MM_TEXT); dc.LPtoDP (&rc); // ClientToScreen (&rc); pFrame->SetWindowPos (&CWnd::wndTop, rc.left, rc.top, 200, 100 ,SWP_NOREPOSITION); } Here is my codr, i hope you can help me ! Many THX CrocodileBuck

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      CrocodileBuck wrote:

      the window jums some lines down and some lines right. Did you know how i could avoid this ?

      Yes. Don't move the window! :) What are you trying to do to the rect there? Mark

      "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

      C 1 Reply Last reply
      0
      • M Mark Salsbery

        CrocodileBuck wrote:

        the window jums some lines down and some lines right. Did you know how i could avoid this ?

        Yes. Don't move the window! :) What are you trying to do to the rect there? Mark

        "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

        C Offline
        C Offline
        CrocodileBuck
        wrote on last edited by
        #3

        Hi Mark, thx for your quick reply! ! What are you trying to do to the rect there? ! What do you mean exactly ? I need the rect for Set WindowPos() function cause SetWindowPos needs the x and y Coord of the Window. But i onla want to chance the width and height of the window and i want it to keep his place when i move the window and click on new in the menue ! I hope you know what i want and sry for my bad engLish ;) ;) Buck

        D M 2 Replies Last reply
        0
        • C CrocodileBuck

          Hi Mark, thx for your quick reply! ! What are you trying to do to the rect there? ! What do you mean exactly ? I need the rect for Set WindowPos() function cause SetWindowPos needs the x and y Coord of the Window. But i onla want to chance the width and height of the window and i want it to keep his place when i move the window and click on new in the menue ! I hope you know what i want and sry for my bad engLish ;) ;) Buck

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

          CrocodileBuck wrote:

          I need the rect for Set WindowPos() function cause SetWindowPos needs the x and y Coord of the Window. But i onla want to chance the width and height of the window...

          While SetWindowPos() is ignoring them, you might want to go ahead and specifiy 0 for x and y. The last argument should also be changed to SWP_NOMOVE.


          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

          "Judge not by the eye but by the heart." - Native American Proverb

          C 1 Reply Last reply
          0
          • D David Crow

            CrocodileBuck wrote:

            I need the rect for Set WindowPos() function cause SetWindowPos needs the x and y Coord of the Window. But i onla want to chance the width and height of the window...

            While SetWindowPos() is ignoring them, you might want to go ahead and specifiy 0 for x and y. The last argument should also be changed to SWP_NOMOVE.


            "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

            "Judge not by the eye but by the heart." - Native American Proverb

            C Offline
            C Offline
            CrocodileBuck
            wrote on last edited by
            #5

            SetWindowPos() ignores nothing ! When i Set X and Y to 0 the Window jumps to the upper left corner of the screen, but i want it to stay where i moved it to. I only want to change the With and height of the window and not its position ! ;) Buck

            D 1 Reply Last reply
            0
            • C CrocodileBuck

              SetWindowPos() ignores nothing ! When i Set X and Y to 0 the Window jumps to the upper left corner of the screen, but i want it to stay where i moved it to. I only want to change the With and height of the window and not its position ! ;) Buck

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

              CrocodileBuck wrote:

              SetWindowPos() ignores nothing !

              It does if you use it correctly.


              "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

              "Judge not by the eye but by the heart." - Native American Proverb

              C 1 Reply Last reply
              0
              • D David Crow

                CrocodileBuck wrote:

                SetWindowPos() ignores nothing !

                It does if you use it correctly.


                "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                "Judge not by the eye but by the heart." - Native American Proverb

                C Offline
                C Offline
                CrocodileBuck
                wrote on last edited by
                #7

                OK. coud you pleeeese explain me how i use it correctly???? pleeese i am coding the mfc since 2 weeks and try to solfe this prob since Sunday please david help me to get it working correctly ! ;) Buck

                C 1 Reply Last reply
                0
                • C CrocodileBuck

                  OK. coud you pleeeese explain me how i use it correctly???? pleeese i am coding the mfc since 2 weeks and try to solfe this prob since Sunday please david help me to get it working correctly ! ;) Buck

                  C Offline
                  C Offline
                  CrocodileBuck
                  wrote on last edited by
                  #8

                  AAAAAAAAAHHHHHRRGGGGGGGGGGHHHHHHHHHHHHHHHH!!!!!!!!!!!!!!!! SWP_NOMOVE Retains the current position (ignores X and Y parameters). YYYIIIIIIIIIIPPPIIIIIIEEEEEEYAAAAAAAAAYEEEEEEEEEEEEAAAAAAAAAAAAAHHHHHH! THX David it was you who kicked me to the Flags ;) Buck

                  W 1 Reply Last reply
                  0
                  • C CrocodileBuck

                    Hi Mark, thx for your quick reply! ! What are you trying to do to the rect there? ! What do you mean exactly ? I need the rect for Set WindowPos() function cause SetWindowPos needs the x and y Coord of the Window. But i onla want to chance the width and height of the window and i want it to keep his place when i move the window and click on new in the menue ! I hope you know what i want and sry for my bad engLish ;) ;) Buck

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #9

                    I see you have a solution cool! :) I just meant the SetMapMode and LPtoDP stuff. Seems to me simply doing something like this would work - CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd(); CRect rc; pFrame->GetWindowRect (&rc); pFrame->MoveWindow (rc.left, rc.top, 200, 100);

                    "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

                    1 Reply Last reply
                    0
                    • C CrocodileBuck

                      AAAAAAAAAHHHHHRRGGGGGGGGGGHHHHHHHHHHHHHHHH!!!!!!!!!!!!!!!! SWP_NOMOVE Retains the current position (ignores X and Y parameters). YYYIIIIIIIIIIPPPIIIIIIEEEEEEYAAAAAAAAAYEEEEEEEEEEEEAAAAAAAAAAAAAHHHHHH! THX David it was you who kicked me to the Flags ;) Buck

                      W Offline
                      W Offline
                      William Wang
                      wrote on last edited by
                      #10

                      void CTestView::OnFileNew() { CRect rc; GetWindowRect (&rc); CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd(); CClientDC dc(this); dc.SetMapMode (MM_TEXT); dc.LPtoDP (&rc); // ClientToScreen (&rc); pFrame->SetWindowPos (&CWnd::wndTop, 0, 0, 200, 100 ,SWP_NOREPOSITION|SWP_NOMOVE); //add one more flag SWP_NOMOVE }

                      life is like a box of chocolate,you never know what you r going to get.

                      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