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() causing crash on closing maximized child window with listbox

MoveWindow() causing crash on closing maximized child window with listbox

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structureshelpquestionworkspace
8 Posts 2 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.
  • S Offline
    S Offline
    Sharath C V
    wrote on last edited by
    #1

    I have a listview within an MDI child window. There is another child window with tree control also in the MDI application. Steps to replicate the problem: First I open the child window with tree control, leave it as it is in non-maximized state. Then I open the second child window which has the list view. Maximize the child window which has listview. Close the listview from maximized state. Application crashes. I have cornered it to a MoveWindow() call, but could not go any further, is this a known problem with listview, is there any specfic tweaking that needs to be done? It causes the crash irrespective of data filled in the listview! Environment: OS- XP SP3 Pure Win32 application No MFC is used This is my call to create the listview: CreateWindowEx( WS_EX_CLIENTEDGE, WC_LISTVIEW, "", //caption not required WS_CHILD | WS_VISIBLE | LVS_REPORT, 0, 0, rect.right, // width rect.bottom,// height m_hwndParent, NULL, (HINSTANCE) GetWindowLong (m_hwndParent, GWL_HINSTANCE), NULL);

    _ 1 Reply Last reply
    0
    • S Sharath C V

      I have a listview within an MDI child window. There is another child window with tree control also in the MDI application. Steps to replicate the problem: First I open the child window with tree control, leave it as it is in non-maximized state. Then I open the second child window which has the list view. Maximize the child window which has listview. Close the listview from maximized state. Application crashes. I have cornered it to a MoveWindow() call, but could not go any further, is this a known problem with listview, is there any specfic tweaking that needs to be done? It causes the crash irrespective of data filled in the listview! Environment: OS- XP SP3 Pure Win32 application No MFC is used This is my call to create the listview: CreateWindowEx( WS_EX_CLIENTEDGE, WC_LISTVIEW, "", //caption not required WS_CHILD | WS_VISIBLE | LVS_REPORT, 0, 0, rect.right, // width rect.bottom,// height m_hwndParent, NULL, (HINSTANCE) GetWindowLong (m_hwndParent, GWL_HINSTANCE), NULL);

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Where is the MoveWindow called? On which window is MoveWindow called?

      «_Superman_» I love work. It gives me something to do between weekends.

      S 1 Reply Last reply
      0
      • _ _Superman_

        Where is the MoveWindow called? On which window is MoveWindow called?

        «_Superman_» I love work. It gives me something to do between weekends.

        S Offline
        S Offline
        Sharath C V
        wrote on last edited by
        #3

        Hi Superman, Thanks very much for your reply. Sorry for missing out that detail. MoveWindow() is called on WM_SIZE of child window in winproc of the child window which has the list view in it.

        case WM_SIZE:
        // Redraw controls
        RECT rect;
        GetClientRect(hWnd, &rect); // gets childwindow client area

        	MoveWindow(m\_hwndListView, //Handle to the window. 
        				0, // \[in\] Specifies the new position of the left side of the window. 
        				0, // \[in\] Specifies the new position of the top of the window. 
        				rect.right,	// Specifies the new width of the window.
        				rect.bottom,// Specifies the new height of the window. 
        				true); // Boolean that specifies whether the window is to be repainted. 
        	break; //Do not return since this should be processed by DefMDIChildProc
        
        _ 1 Reply Last reply
        0
        • S Sharath C V

          Hi Superman, Thanks very much for your reply. Sorry for missing out that detail. MoveWindow() is called on WM_SIZE of child window in winproc of the child window which has the list view in it.

          case WM_SIZE:
          // Redraw controls
          RECT rect;
          GetClientRect(hWnd, &rect); // gets childwindow client area

          	MoveWindow(m\_hwndListView, //Handle to the window. 
          				0, // \[in\] Specifies the new position of the left side of the window. 
          				0, // \[in\] Specifies the new position of the top of the window. 
          				rect.right,	// Specifies the new width of the window.
          				rect.bottom,// Specifies the new height of the window. 
          				true); // Boolean that specifies whether the window is to be repainted. 
          	break; //Do not return since this should be processed by DefMDIChildProc
          
          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          I'm guessing the crash occurs because MoveWindow is called on the list view after it is destroyed. Try putting an IsWindow check over the MoveWindow.

          if (IsWindow(m_hwndListView))
          {
          MoveWindow(m_hwndListView, //Handle to the window.
          0, // [in] Specifies the new position of the left side of the window.
          0, // [in] Specifies the new position of the top of the window.
          rect.right, // Specifies the new width of the window.
          rect.bottom,// Specifies the new height of the window.
          true); // Boolean that specifies whether the window is to be repainted.
          }

          «_Superman_» I love work. It gives me something to do between weekends.

          S 1 Reply Last reply
          0
          • _ _Superman_

            I'm guessing the crash occurs because MoveWindow is called on the list view after it is destroyed. Try putting an IsWindow check over the MoveWindow.

            if (IsWindow(m_hwndListView))
            {
            MoveWindow(m_hwndListView, //Handle to the window.
            0, // [in] Specifies the new position of the left side of the window.
            0, // [in] Specifies the new position of the top of the window.
            rect.right, // Specifies the new width of the window.
            rect.bottom,// Specifies the new height of the window.
            true); // Boolean that specifies whether the window is to be repainted.
            }

            «_Superman_» I love work. It gives me something to do between weekends.

            S Offline
            S Offline
            Sharath C V
            wrote on last edited by
            #5

            Thanks very much for your reply. IsWindow() did not help. Crash occurs only under following condition: Child window containing tree control is opened and kept in non-maximized state Then, child window containing the list is maximized and then this closed. :( Anything else that you could think of?

            _ 1 Reply Last reply
            0
            • S Sharath C V

              Thanks very much for your reply. IsWindow() did not help. Crash occurs only under following condition: Child window containing tree control is opened and kept in non-maximized state Then, child window containing the list is maximized and then this closed. :( Anything else that you could think of?

              _ Offline
              _ Offline
              _Superman_
              wrote on last edited by
              #6

              You could try to use MoveWindow only when the wParam parameter of WM_SIZE is SIZE_RESTORED.

              «_Superman_» I love work. It gives me something to do between weekends.

              S 1 Reply Last reply
              0
              • _ _Superman_

                You could try to use MoveWindow only when the wParam parameter of WM_SIZE is SIZE_RESTORED.

                «_Superman_» I love work. It gives me something to do between weekends.

                S Offline
                S Offline
                Sharath C V
                wrote on last edited by
                #7

                That also does not help :(

                S 1 Reply Last reply
                0
                • S Sharath C V

                  That also does not help :(

                  S Offline
                  S Offline
                  Sharath C V
                  wrote on last edited by
                  #8

                  Thanks for your time and help superman. Tried IsZoomed(hWnd) to do some conditional operation when closing in maximized state, but that also did not help. Problem was that an allocated object was being deleted in WM_CLOSE. When this was moved to WM_DESTROY the crash is solved. Still not sure why this was causing the crash only when in maximized state!! :confused: Will look into this at a later time.

                  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