Click here to Skip to main content
Licence 
First Posted 17 Feb 2002
Views 213,758
Bookmarked 85 times

3D Studio Max like Slidable DialogBar

By | 17 Feb 2002 | Article
Ever seen 3D Studio 2.5 Slidable DialogBar? Want to know how they did it?

Introduction

Kinetix and Autodesk always impressed me with their great GUI. 3D Studio Max has a Slidable DialogBar that the user can slide up and down... Well here is how to do it yourself. It is probably one of the easiest code I ever had to show around and anybody with a little experience in VC++ / MFC will get it. (I actually posted it because I have never seen another programmer or company create a GUI similar to 3DS Max)

Here is the Magic Theory behind it

  1. Create any kind of CWnd derived class . That will be your TOP level Window (could be a CDialog / CDialogBar / CButton anything...)

    Lets say CDialogBarExt ....derived from CDialogBar.

  2. Create a CWnd derived Class that will contain the actual sliding dialog.

    Lets say CDlgContainer ....derived from CWnd

  3. Create a member variable for CDialogBarExt of type CDlgContainer.

  4. Create a CDialog derived class .

    Lets say CInnerDlg (this is the actual sliding dialog !!!)

  5. Create a member variable of type CInnerDlg for CDlgContainer....

So up till know we have CDialogBarExt--->CDlgContainer--->CInnerDlg ? ok? the Code for Sliding the dialog is below and should be entered in the CInnerDlg

The easiest way to understand, is to look through the code it is very simple!!!

void CInnerDlg::OnLButtonUp(UINT nFlags, CPoint point) 
{
    /// IF WE WHERE DRAGGING THEN RELEASE THE MOUSE CAPTURE
    if(m_bDragging)
    {
        ReleaseCapture();
        m_bDragging = FALSE;
    }
    
    CDialog::OnLButtonUp(nFlags, point);
}

void CInnerDlg::OnMouseMove(UINT nFlags, CPoint point) 
{

 int ydiff;

    if(m_bDragging && nFlags & MK_LBUTTON)
    {
       // GET DIALOGS WINDOW SCREEN COORDINATES
       CRect rcWnd;
       GetWindowRect(&rcWnd);

       // GET PARENTS CLIENT RECTANGLE
       CRect prect;
       GetParent()->GetClientRect (prect);

       // IF WE HAVE TO GO DOWN OR UP // 
       if (m_ptDragFrom.y>point.y) {    
          ydiff = point.y - m_ptDragFrom.y;
          posY+=ydiff;
       }// IF WE HAVE TO GO DOWN OR UP // 
       if (m_ptDragFrom.y<point.y) {    
          ydiff = m_ptDragFrom.y -point.y;
          posY-=ydiff;
       }
       //////////////////////////////


       // CALCULATE IF WE ARE GOING TO EXCEED BOTTOM DIALOG BORDER
       int tmp=prect.Height ()-rcWnd.Height ();
       
       // CONSTRAINTS !
       if (posY<tmp+1) posY=tmp+1;
       if (posY>-1) posY=-1;

       // MOVE THE DIALOG 
        SetWindowPos(NULL, 3, 
                     posY, 
                     rcWnd.Width(), 
                     rcWnd.Height(), SWP_SHOWWINDOW|SWP_NOSIZE);


    }    
    
    CDialog::OnMouseMove(nFlags, point);
}

void CInnerDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
   // START DRAGGING 
   SetCapture();
   m_bDragging = TRUE;
   m_ptDragFrom = point;
   ::SetCursor(AfxGetApp()->LoadCursor (IDC_CURSOR_HAND));
   CDialog::OnLButtonDown(nFlags, point);
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

John Aspras



United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalyes but... legal issues PinmemberMember 56468674:53 13 Nov '08  
QuestionHow do I replace m_inner with a sheet Pinmemberakira320:57 30 Oct '08  
QuestionHelp to use the buttons on it Pinmembermaster_pgl20:59 30 Oct '07  
GeneralGreat effort indeed (to author) PinmemberRAD CPP1:34 30 Jul '06  
GeneralProblem CInnerDlg is not "inside" my Container Pinmemberpeca200623:35 10 Jun '06  
Generalgreat job, can you helpl me to figure out this problem, thanks a lot Pinmembernickong22:47 25 Jul '05  
QuestionHow to make a Dockable "TabPan" with this DialogBar just like 3DS MAX ? Pinmembersgy2323:22 21 Dec '03  
AnswerRe: How to make a Dockable "TabPan" with this DialogBar just like 3DS MAX ? Pinmemberimsniper3:36 15 Jan '04  
QuestionHow to map messages back to the main frame? PinmemberBubba21463:48 18 Jul '03  
AnswerRe: How to map messages back to the main frame? PinmemberBubba21465:06 21 Jul '03  
GeneralRe: How to map messages back to the main frame? PinmemberWREY18:43 3 Jun '04  
Generaldoesn't always work Pinmembermel@endlessquests.com10:07 1 Jul '03  
GeneralAwesome, but I have problems PinmemberTurok_4_2_07:33 23 May '03  
GeneralThanks a lot Pinmembercwtung21:33 10 Apr '03  
GeneralRe: Thanks a lot Pinmemberimsniper0:19 18 Apr '03  
GeneralRe: Thanks a lot Pinmembercwtung18:51 14 Aug '07  
QuestionHow to make it slide? PinsussJinming Xu9:16 10 Apr '03  
AnswerRe: How to make it slide? PinsussAnonymous1:39 22 Apr '03  
Generalthere is a control better than this already in Code Project Pinmemberkonqueror23:47 22 Jan '03  
Generaldocking CdialogBar like toolbal Pinmemberyaser21:16 8 Sep '02  
GeneralRe: docking CdialogBar like toolbal Pinmembermnansyah20:04 30 Jan '03  
GeneralUsability... Pinmemberaaronp6:29 3 Sep '02  
GeneralRe: Usability... PinsussAnonymous1:26 8 Sep '02  
GeneralThank you, thank you..oh, and thank you!! PinsussAnonymous22:33 16 Jul '02  
GeneralIt has a problem.... PinmemberAnonymous3:04 18 Jun '02  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 18 Feb 2002
Article Copyright 2002 by John Aspras
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid