Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

A Slide Form Base

0.00/5 (No votes)
18 Dec 2002 1  
A slide form class from which to derive your forms from

Introduction

Some time ago, I needed a form that had a sliding panel on its side. I checked the web to avoid coding. I found a solution on www.codeguru.com. I used and improved the C++/MFC code. Since I use C# for my development, you can find here the result of my work. The form class must be inherited and the specialized form must implement a special constructor. You can find a small example below.

Design of a Simple Slide Form

Use the “Add inherited form” wizard in Visual Studio .NET, and select the SlideForm in the inheritance picker dialog.

You’ve got the following form in your project:

Resize and customize it with the appropriate controls. Keep in mind that this form will be hidden by the main form, so, ensure that the child form is smaller than the parent:

Next, you must provide a special constructor for this slide form. This constructor takes a reference on the parent form and the step of sliding. This step is a percentage of the slide form that will be shown at each tick of timer.

public MySlideForm(Form poOwner, float pfStep) : base(poOwner, pfStep) 
{
    InitializeComponent();
} 

We are done with the sliding form. Now, have a look at the way we will make our slide form slide. First, instantiate the slide form:

// In parent form constructor for instance
oSlideForm = new MySlideForm(this, 0.1f); 
// ...

Next, in the handler of the button that command the sliding of the form, use the following code:

// ...
_oSlideForm.SlideDirection = SlideDialog.SlideDialog.SLIDE_DIRECTION.RIGHT; 
_oSlideForm.Slide(); 
// ...

In this example, the form will slide by the right side of the parent form. That's all! Enjoy!

History

  • December 2002: Initial post

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.

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