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. SetWindowPos does nothing

SetWindowPos does nothing

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

    Hi, I try to resize a Custom Control in the OnSize Function of my Views OnSize Function. There is no Error, but nothing happens:

    afx_msg void CCustomView::OnSize(UINT nType, int cx, int cy) {

    if (::IsWindow(m\_datagrid)) {
    	m\_datagrid.SetWindowPos(&wndTopMost, 12, 48, 500, 500, SWP\_NOZORDER | SWP\_NOMOVE);
    }
    
    CView::OnSize(nType, cx, cy);
    

    }

    What am I do wrong? m_datagrid.SetWindowPos is executed, I checked it by debugging. Thank you for your help, Johannes

    M 1 Reply Last reply
    0
    • J Joschwenk666

      Hi, I try to resize a Custom Control in the OnSize Function of my Views OnSize Function. There is no Error, but nothing happens:

      afx_msg void CCustomView::OnSize(UINT nType, int cx, int cy) {

      if (::IsWindow(m\_datagrid)) {
      	m\_datagrid.SetWindowPos(&wndTopMost, 12, 48, 500, 500, SWP\_NOZORDER | SWP\_NOMOVE);
      }
      
      CView::OnSize(nType, cx, cy);
      

      }

      What am I do wrong? m_datagrid.SetWindowPos is executed, I checked it by debugging. Thank you for your help, Johannes

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

      What are you wanting to happen? You use wndTopMost but it's ignored because of SWP_NOZORDER. You use x and y positions but they're ignored because of SWP_NOMOVE. That leaves resize :)

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      J 1 Reply Last reply
      0
      • M Mark Salsbery

        What are you wanting to happen? You use wndTopMost but it's ignored because of SWP_NOZORDER. You use x and y positions but they're ignored because of SWP_NOMOVE. That leaves resize :)

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        J Offline
        J Offline
        Joschwenk666
        wrote on last edited by
        #3

        Yes, it would have been better if I posted the code without the flags. When I do not use the Flags it`s the same thing: My Custom control is not be resized and not moved, and this is what I want it to do...

        M 1 Reply Last reply
        0
        • J Joschwenk666

          Yes, it would have been better if I posted the code without the flags. When I do not use the Flags it`s the same thing: My Custom control is not be resized and not moved, and this is what I want it to do...

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

          If you want to move and resize, just use MoveWindow(). The other problem may be where you're doing it from. The view may not get a WM_SIZE message after the child window you're moving is created (until the next time the view is resized). Put a breakpoint on the SetWindowPos() call to check.

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          J 1 Reply Last reply
          0
          • M Mark Salsbery

            If you want to move and resize, just use MoveWindow(). The other problem may be where you're doing it from. The view may not get a WM_SIZE message after the child window you're moving is created (until the next time the view is resized). Put a breakpoint on the SetWindowPos() call to check.

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            J Offline
            J Offline
            Joschwenk666
            wrote on last edited by
            #5

            Hi Mark, thank you. With MoveWindow() it works!

            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