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. modeless Dlg

modeless Dlg

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

    Hi, Is there a way to create a modeless dlg that we cannot move so that it always remains at the same place that I have created it? Thanks Everything's beautiful if you look at it long enough...

    A M 3 Replies Last reply
    0
    • M MemLeak

      Hi, Is there a way to create a modeless dlg that we cannot move so that it always remains at the same place that I have created it? Thanks Everything's beautiful if you look at it long enough...

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      You can easily do this via your dialog's OnWindowPosChanging() method. When the modeless dialog is created, save it's window rect to a member variable. Then in OnWindowPosChanging(), change the 'x', 'y', 'cx', and 'cy' values of the WINDOWPOS structure. BEGIN_MESSAGE_MAP(CModelessDlg, CDialog) //{{AFX_MSG_MAP(CModelessDlg) //}}AFX_MSG_MAP ON_WM_WINDOWPOSCHANGING() END_MESSAGE_MAP() BOOL CModelessDlg::OnInitDialog() { CDialog::OnInitDialog(); GetWindowRect(m_rect); return TRUE; } void CModelessDlg::OnWindowPosChanging( WINDOWPOS* lpwndpos ) { lpwndpos->x = m_rect.left; lpwndpos->y = m_rect.top; lpwndpos->cx = m_rect.Width(); lpwndpos->cy = m_rect.Height(); }

      1 Reply Last reply
      0
      • M MemLeak

        Hi, Is there a way to create a modeless dlg that we cannot move so that it always remains at the same place that I have created it? Thanks Everything's beautiful if you look at it long enough...

        M Offline
        M Offline
        MAAK
        wrote on last edited by
        #3

        This is another way to do it. To move the dialog the user should drag the dialog caption. you can override the WM_NCHITTEST message and disable the HTCAPTION result from reaching hte system. the could should be like this

        UINT CMyDlg::OnNcHitTest(CPoint point)
        {
        	//Store the result returned by the dialog's WinProc    
        	UINT hitResult = CDialog::OnNcHitTest(point);
        	//if the mouse is in the caption bar change the result to HTNOWHERE
        	//so the system wouldn't recognize it
        	if(hitResult == HTCAPTION)
        		return HTNOWHERE;
        	//any other result should be returned as it is
        	return hitResult;
        }
        
        1 Reply Last reply
        0
        • M MemLeak

          Hi, Is there a way to create a modeless dlg that we cannot move so that it always remains at the same place that I have created it? Thanks Everything's beautiful if you look at it long enough...

          M Offline
          M Offline
          MAAK
          wrote on last edited by
          #4

          There is another simple way to do it. To move the dialog the user must drag the caption bar, thus you can override the WM_NCHITTEST message and disable the system from recognizing that the mouse is in the caption bar. This code shows ho that is done:

          UINT CMyDlg::OnNcHitTest(CPoint point)
          {
          	//store the value returnd by the WndProc	
          	UINT hitResult = CDialog::OnNcHitTest(point);
          	//if the mouse is in the caption bar, change the result to HTNOWHERE
          	//so the system does not recognize that the mouse is in hte caption
          	if(hitResult == HTCAPTION)
          		return HTNOWHERE;
          	//any other result mus t be returned as it is
          	return hitResult;
          }
          
          N 1 Reply Last reply
          0
          • M MAAK

            There is another simple way to do it. To move the dialog the user must drag the caption bar, thus you can override the WM_NCHITTEST message and disable the system from recognizing that the mouse is in the caption bar. This code shows ho that is done:

            UINT CMyDlg::OnNcHitTest(CPoint point)
            {
            	//store the value returnd by the WndProc	
            	UINT hitResult = CDialog::OnNcHitTest(point);
            	//if the mouse is in the caption bar, change the result to HTNOWHERE
            	//so the system does not recognize that the mouse is in hte caption
            	if(hitResult == HTCAPTION)
            		return HTNOWHERE;
            	//any other result mus t be returned as it is
            	return hitResult;
            }
            
            N Offline
            N Offline
            Neville Franks
            wrote on last edited by
            #5

            If the dialog has a system menu the keyboard can be used to move it, so this isn't good enough. OnGetMinMaxInfo() may do the trick. Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com

            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