Toll Free: (877) 723-1442 U.S. and Canada
Support
ActiveX / COM
Visual C++ / MFC
Customer Spotlight
Corporate Partners
Contact Sales

Call center available M-F 9:00 - 6:00 US Eastern Time.

U.S. and Canada
(877) 723-1442

International
(517) 625-5729

Email

Programmatically Moving\Docking an Existing Pane

Author: Mike Palmatier
Posted: April 26, 2006
Environment: Visual Basic 6.0

Downloads:
  movepanesample.zip - Source Files with Demo Project [8 KB]

To programmatically dock a pane, you will need to destroy the pane, then create a new pane, using the CreatePane method to specify the new place to dock the pane.

The instance of the attached form\object still exists after a pane is destroyed. After you re-create the pane in the desired location you will then attach the form\object that was previously attached to the old pane to the new pane. If you set up the Attach_Pane event properly you should not have to worry about re-attaching the form\object to the pane.

The sample code below simply shows how to dock an existing pane to the right side of the application. Please download the sample project for the entire source.

    'Dock the pane with Id ID_SEARCH_PANE to the right of

    'the application

    MoveSearchPane ID_SEARCH_PANE, 200, 200, _

                                DockingDirection.DockRightOf

 

 

    'Subroutine used to dock a pane to the top, bottom, left, or right

    'side of an application

    Private Sub MoveSearchPane(PANE_TO_MOVE As Integer, nWidth As _

        Integer, nHeight As Integer, _

        Optional Direction = DockingDirection.DockLeftOf)

 

        Dim Pane As Pane

        Dim sTitle As String

        Dim iIconId As Integer

 

        'Search for a pane with Id PANE_TO_MOVE

        Set Pane = DockingPaneManager.FindPane(PANE_TO_MOVE)

 

        'If a pane with Id PANE_TO_MOVE exists save the Title and

        'IconId, then destroy it

        If Not Pane Is Nothing Then

 

            'Save Title

            sTitle = Pane.Title

 

            'Save IconId

            iIconId = Pane.IconId

 

            'Destroy Pane with Id PANE_TO_MOVE.

            '

            'NOTE: The instance of the attached form\object still

            'exists and is not deleted, only the pane

            DockingPaneManager.DestroyPane Pane

        End If

 

        'Creates new pane docking it in the new location, when the

        'attach_pane event is called (which is the first time the

        'pane becomes visible) the old form\object will get attached

        'to the new pane

        Set Pane = DockingPaneManager.CreatePane(PANE_TO_MOVE, _

                                nWidth, nHeight, Direction, Nothing)

 

        'Restore Title and IconId

        Pane.Title = sTitle

        Pane.IconId = iIconId

 

    End Sub

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Other products and/or company names may be trademarks or registered trademarks of their respective owners.