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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Moving a Dialogbox

Moving a Dialogbox

Scheduled Pinned Locked Moved C / C++ / MFC
jsonquestion
8 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi, how kan i mov a Dialogbox without a titlelist? Is just normal Dialogwindow without a titlelist and system menue, i kan only move, replace, them in the screen when is a titlelist created? :( i think on a event like OnMouseDown or somethink like this, is there any API or Function for this? thanx mirsad

    N S 2 Replies Last reply
    0
    • L Lost User

      Hi, how kan i mov a Dialogbox without a titlelist? Is just normal Dialogwindow without a titlelist and system menue, i kan only move, replace, them in the screen when is a titlelist created? :( i think on a event like OnMouseDown or somethink like this, is there any API or Function for this? thanx mirsad

      N Offline
      N Offline
      namaskaaram
      wrote on last edited by
      #2

      hmmm.....i had the same prob.....though i can move the dialog where i want to it still doesnt move the way it does as it does in the windows dialog...... well thiz is what i have done..... sense for the drag of the mouse,whenever the mouse is dragged use the SetWindowPos() function..... here is the coding i have used in the in OnMouseMove() function......

      void CxyzDlg::OnMouseMove(UINT nFlags, CPoint point)
      {
      // TODO: Add your message handler code here and/or call default

      if(m\_DragOn==TRUE)
      {
      CPoint point1=point;
      ClientToScreen(&point1);
      this->SetWindowPos(&CWnd::wndTop ,point1.x-473,point1.y-23,0,0, SWP\_SHOWWINDOW|SWP\_NOSIZE);
      }//end of if(m\_DragOn==TRUE)
      
      CDialog::OnMouseMove(nFlags, point);
      

      }

      please note that the m_DragOn is set to ONE on the OnLButtonDown()function and set to zero on the OnLButtonUp() function..... also note that in the SetWindowPos() function i have changed the value of the x cordinate by 473 and y cordinate by 23(which happenz to make the mouse pointer to point to the center of my dialog)....u will have to set the value accordingly!!!!! ps:there definitely an another way to do it,but i guess thiz gives a good result as well..... hope thiz helpz ...... cheerz.....:-D "faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13

      K 1 Reply Last reply
      0
      • N namaskaaram

        hmmm.....i had the same prob.....though i can move the dialog where i want to it still doesnt move the way it does as it does in the windows dialog...... well thiz is what i have done..... sense for the drag of the mouse,whenever the mouse is dragged use the SetWindowPos() function..... here is the coding i have used in the in OnMouseMove() function......

        void CxyzDlg::OnMouseMove(UINT nFlags, CPoint point)
        {
        // TODO: Add your message handler code here and/or call default

        if(m\_DragOn==TRUE)
        {
        CPoint point1=point;
        ClientToScreen(&point1);
        this->SetWindowPos(&CWnd::wndTop ,point1.x-473,point1.y-23,0,0, SWP\_SHOWWINDOW|SWP\_NOSIZE);
        }//end of if(m\_DragOn==TRUE)
        
        CDialog::OnMouseMove(nFlags, point);
        

        }

        please note that the m_DragOn is set to ONE on the OnLButtonDown()function and set to zero on the OnLButtonUp() function..... also note that in the SetWindowPos() function i have changed the value of the x cordinate by 473 and y cordinate by 23(which happenz to make the mouse pointer to point to the center of my dialog)....u will have to set the value accordingly!!!!! ps:there definitely an another way to do it,but i guess thiz gives a good result as well..... hope thiz helpz ...... cheerz.....:-D "faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13

        K Offline
        K Offline
        khan
        wrote on last edited by
        #3

        If I understand your question, Handle the WM_NCHITTEST. Write the following code in OnNcHitTest(CPoint point) { CRect rect; GetClientRect(&rect); ClientToScreen(&rect); if (rect.PtInRect(point)) return HTCAPTION; return CDialog::OnNcHitTest(point); } Good code for life.

        L 1 Reply Last reply
        0
        • K khan

          If I understand your question, Handle the WM_NCHITTEST. Write the following code in OnNcHitTest(CPoint point) { CRect rect; GetClientRect(&rect); ClientToScreen(&rect); if (rect.PtInRect(point)) return HTCAPTION; return CDialog::OnNcHitTest(point); } Good code for life.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          hi, @rateep thanx for the great help! That is what i need! @khan++, i kant find the WM_NCHITTEST event in my Class Wizard :( thanx mirsad

          T 1 Reply Last reply
          0
          • L Lost User

            hi, @rateep thanx for the great help! That is what i need! @khan++, i kant find the WM_NCHITTEST event in my Class Wizard :( thanx mirsad

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            mirso67 wrote: kant find the WM_NCHITTEST event in my Class Wizard Switch MessageView of Your Windows Message Handller from Dialog to Windows, you wil find this option in combobox situated at bottom-right of Window Message Handller Wizard


            [Vote One Here, Complete my Survey....] Alok Gupta
            visit me at http://www.thisisalok.tk          "I Think Believe this Will Help"

            L 1 Reply Last reply
            0
            • T ThatsAlok

              mirso67 wrote: kant find the WM_NCHITTEST event in my Class Wizard Switch MessageView of Your Windows Message Handller from Dialog to Windows, you wil find this option in combobox situated at bottom-right of Window Message Handller Wizard


              [Vote One Here, Complete my Survey....] Alok Gupta
              visit me at http://www.thisisalok.tk          "I Think Believe this Will Help"

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              thanx! :-O :sigh: mirsad

              1 Reply Last reply
              0
              • L Lost User

                Hi, how kan i mov a Dialogbox without a titlelist? Is just normal Dialogwindow without a titlelist and system menue, i kan only move, replace, them in the screen when is a titlelist created? :( i think on a event like OnMouseDown or somethink like this, is there any API or Function for this? thanx mirsad

                S Offline
                S Offline
                Static x
                wrote on last edited by
                #7

                Simply Add this code to WM_LBUTTONDOWN event : void CYourDialog::OnLButtonDown(UINT nFlags, CPoint point) { CDialog::OnLButtonDown(nFlags, point); PostMessage( WM_NCLBUTTONDOWN, HTCAPTION,MAKELPARAM( point.x, point.y)); } Thats it!!! m0n0

                L 1 Reply Last reply
                0
                • S Static x

                  Simply Add this code to WM_LBUTTONDOWN event : void CYourDialog::OnLButtonDown(UINT nFlags, CPoint point) { CDialog::OnLButtonDown(nFlags, point); PostMessage( WM_NCLBUTTONDOWN, HTCAPTION,MAKELPARAM( point.x, point.y)); } Thats it!!! m0n0

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  thanxs to all, it works super! mfg mirsad

                  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