Introduction

Sometime ago, I needed a form that had a sliding panel on its side. I’ve
checked the web to avoid coding. I’ve found a solution on
www.codeguru.com. I’ve 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 below a small example.

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 take a reference on the parent form and the step of sliding. This
step is a percentage of the slide form that will be showed at each ticks of
timer.

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

History

Initial posting - December 2002

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.

First off, thanks for the great Control. There are a couple nitpicky issues I have though, and I was curious to get your input on them.

If you have the slide window all the way behind the owner window (fully collapsed) and open a normal dialog from the owner window, it seems that the owner gets sent to the back - and the slide window will be draw on top of the owner until the owner regains focus.

To fix this, I thought it would be as simple as calling Hide() once the window was collapsed, but here is where the "issue" comes in. It seems that Show() (once you want to expand the slide window again) brings the window into focus - and brings it to the front - and there is some flicker where you can see it on top of the owner window for a second before owner.BringToFront() is called.

I can't seem to find any documentation on how it would be possible to override the behavior of Show() in terms of disabling the bring to front action.

My other thought is to slide by resizing the width or height to 0, rather than actually moving the window. Everything would need to be anchored to the side that is sliding out (possibly at runtime in OnLoad()?) and not anchored to the side that the form is growing from, but other than that, it seems like this might be a fair solution.

Other than the listed tradeoffs, is there any reason why this would be a very bad idea?

private void poOwner.Paint(object sender, PaintEventArgs e) { // Makes sure the form is opened and not still opening before bringing it forward. if((_bExpand) && (!timer1.Enabled)) this.BringToFront(); }

Finally The last thing you need to do is add the following bold lines in the event Timer_Tick procedure: