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. MoveWindow()

MoveWindow()

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingtutorial
13 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.
  • R Offline
    R Offline
    ROK_RShadow
    wrote on last edited by
    #1

    I am trying to resize my application based on the size of a loaded file. First I tried to use SetWindowPos() this worked, but did not resize the frame. So I have attempted to use MoveWindow() to do this, and it works.. but not as expected. For example if somebody could review this code fragment and tell me whats up. The file I am loading is a video, and lets say the size is 320 x 480 the frame resizes to a really tiny window. CRect winRect; CRect tmpRect; GetClientRect(tmpRect); if(!m_media.GetVidSize(winRect)) DoError("Unable to receive size"); GetParentFrame()->MoveWindow(tmpRect.Width(),tmpRect.Height(),winRect.Width(), winRect.Height()); CString str; str.Format("Video Width: %d\nVideo Height: %d\n", winRect.Width(), winRect.Height()); TRACE(str); I can verify that GetVidSize() is returning correct results based upon the TRACE statment wich outputs 320 and 480. Thank you

    C V 2 Replies Last reply
    0
    • R ROK_RShadow

      I am trying to resize my application based on the size of a loaded file. First I tried to use SetWindowPos() this worked, but did not resize the frame. So I have attempted to use MoveWindow() to do this, and it works.. but not as expected. For example if somebody could review this code fragment and tell me whats up. The file I am loading is a video, and lets say the size is 320 x 480 the frame resizes to a really tiny window. CRect winRect; CRect tmpRect; GetClientRect(tmpRect); if(!m_media.GetVidSize(winRect)) DoError("Unable to receive size"); GetParentFrame()->MoveWindow(tmpRect.Width(),tmpRect.Height(),winRect.Width(), winRect.Height()); CString str; str.Format("Video Width: %d\nVideo Height: %d\n", winRect.Width(), winRect.Height()); TRACE(str); I can verify that GetVidSize() is returning correct results based upon the TRACE statment wich outputs 320 and 480. Thank you

      C Offline
      C Offline
      Chintan
      wrote on last edited by
      #2

      You have made mistake in the following function call : GetParentFrame()->MoveWindow(tmpRect.Width(),tmpRect.Height(),winRect.Width(), winRect.Height()); First parameter should be X coordinate and second one should be Y coordinate of the screen. So in your case it should be tempRect.TopLeft().x & tempRect.TopLeft().y respectively Regards C.R.Naik

      R 1 Reply Last reply
      0
      • R ROK_RShadow

        I am trying to resize my application based on the size of a loaded file. First I tried to use SetWindowPos() this worked, but did not resize the frame. So I have attempted to use MoveWindow() to do this, and it works.. but not as expected. For example if somebody could review this code fragment and tell me whats up. The file I am loading is a video, and lets say the size is 320 x 480 the frame resizes to a really tiny window. CRect winRect; CRect tmpRect; GetClientRect(tmpRect); if(!m_media.GetVidSize(winRect)) DoError("Unable to receive size"); GetParentFrame()->MoveWindow(tmpRect.Width(),tmpRect.Height(),winRect.Width(), winRect.Height()); CString str; str.Format("Video Width: %d\nVideo Height: %d\n", winRect.Width(), winRect.Height()); TRACE(str); I can verify that GetVidSize() is returning correct results based upon the TRACE statment wich outputs 320 and 480. Thank you

        V Offline
        V Offline
        vikramlinux
        wrote on last edited by
        #3

        What Kind of application you are developing ? SDI,MDI ? let mw know..:| Vikram

        R 1 Reply Last reply
        0
        • V vikramlinux

          What Kind of application you are developing ? SDI,MDI ? let mw know..:| Vikram

          R Offline
          R Offline
          ROK_RShadow
          wrote on last edited by
          #4

          Developing an SDI Application.

          V 1 Reply Last reply
          0
          • R ROK_RShadow

            Developing an SDI Application.

            V Offline
            V Offline
            vikramlinux
            wrote on last edited by
            #5

            The reply from naik is correct. Just check it out...

            R 1 Reply Last reply
            0
            • C Chintan

              You have made mistake in the following function call : GetParentFrame()->MoveWindow(tmpRect.Width(),tmpRect.Height(),winRect.Width(), winRect.Height()); First parameter should be X coordinate and second one should be Y coordinate of the screen. So in your case it should be tempRect.TopLeft().x & tempRect.TopLeft().y respectively Regards C.R.Naik

              R Offline
              R Offline
              ROK_RShadow
              wrote on last edited by
              #6

              Thank you for the correction Chintan, I realized that something was not right with the first two values. However these values reflect were the x,y orgin of the window is if I'm correct in saying that. In my actual code I was using 0,0 and just putting the frame in the upper left corner. Anyways thank you again. You have prolly saved me a little research on how to get the correct coordinates

              1 Reply Last reply
              0
              • V vikramlinux

                The reply from naik is correct. Just check it out...

                R Offline
                R Offline
                ROK_RShadow
                wrote on last edited by
                #7

                Not exactly what I am looking for. The frame still resizes to a very tiny view. I have tried setting the SetMapMode() to different values.. but that has not worked out very well either.

                V 1 Reply Last reply
                0
                • R ROK_RShadow

                  Not exactly what I am looking for. The frame still resizes to a very tiny view. I have tried setting the SetMapMode() to different values.. but that has not worked out very well either.

                  V Offline
                  V Offline
                  vikramlinux
                  wrote on last edited by
                  #8

                  If you are tring in CMainFrame then just use this->MoveWindow(...); else if it is in View use AfxGetMainWnd()->MoveWindow(..); ;)

                  R 1 Reply Last reply
                  0
                  • V vikramlinux

                    If you are tring in CMainFrame then just use this->MoveWindow(...); else if it is in View use AfxGetMainWnd()->MoveWindow(..); ;)

                    R Offline
                    R Offline
                    ROK_RShadow
                    wrote on last edited by
                    #9

                    That is the code that I am using MoveWindow(...) ::MoveWindow(...) GetParentFrame()->MoveWindow(...) AfxGetMainWind()->MoveWindow(...) all produce the same results. The window is resized, but not of the correct size. the CRect structure will have correct numbers for the Width and Height.. however I don't understand how those numbers are being mapped. It seems like 320 is being mapped to 320 mini micro half pixels.

                    V 1 Reply Last reply
                    0
                    • R ROK_RShadow

                      That is the code that I am using MoveWindow(...) ::MoveWindow(...) GetParentFrame()->MoveWindow(...) AfxGetMainWind()->MoveWindow(...) all produce the same results. The window is resized, but not of the correct size. the CRect structure will have correct numbers for the Width and Height.. however I don't understand how those numbers are being mapped. It seems like 320 is being mapped to 320 mini micro half pixels.

                      V Offline
                      V Offline
                      vikramlinux
                      wrote on last edited by
                      #10

                      I think this must be issue between player output coorinates and the co-odinates you are setttig..i think you need to set the View's size ..Is it so?and not whole Window..

                      R 1 Reply Last reply
                      0
                      • V vikramlinux

                        I think this must be issue between player output coorinates and the co-odinates you are setttig..i think you need to set the View's size ..Is it so?and not whole Window..

                        R Offline
                        R Offline
                        ROK_RShadow
                        wrote on last edited by
                        #11

                        Hmmmm.. Using DirectX9 VMR to display a video.. If I use MoveWindow(...) on the view and don't call it through the parent frame .. it sets to the correct size. However the view is never "updated" wether I call Invalidate() or not. so It appears that a Video has plopped on top of the CView window, and will overwrite the status bar, and what not. If I call the funtion through the Frame Window.. It resizes the whole window.. but makes the window tiny.

                        V 1 Reply Last reply
                        0
                        • R ROK_RShadow

                          Hmmmm.. Using DirectX9 VMR to display a video.. If I use MoveWindow(...) on the view and don't call it through the parent frame .. it sets to the correct size. However the view is never "updated" wether I call Invalidate() or not. so It appears that a Video has plopped on top of the CView window, and will overwrite the status bar, and what not. If I call the funtion through the Frame Window.. It resizes the whole window.. but makes the window tiny.

                          V Offline
                          V Offline
                          vikramlinux
                          wrote on last edited by
                          #12

                          see actually the size of the FrameWindow you are considering while resizing.and actually the View needs to be of that size.so just take the framewindows rectangle and view rectangle and fine out what exactly the size you want. that meant your main windows is slightly bigger. and view will be of exact size.In short you need to manipulate the width and height of main window ...by finding the exact difference between upper left and top coordinates of view and Mainframe.

                          R 1 Reply Last reply
                          0
                          • V vikramlinux

                            see actually the size of the FrameWindow you are considering while resizing.and actually the View needs to be of that size.so just take the framewindows rectangle and view rectangle and fine out what exactly the size you want. that meant your main windows is slightly bigger. and view will be of exact size.In short you need to manipulate the width and height of main window ...by finding the exact difference between upper left and top coordinates of view and Mainframe.

                            R Offline
                            R Offline
                            ROK_RShadow
                            wrote on last edited by
                            #13

                            hmm.. that is understandable.. makes scence I guess.. For now I have moved on .. automaticly resizing the default video widht and height isn't a need to have feature I guess, since the user can simply drag the window to whatever size he/she wants.

                            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