Docking a Form Window within VS 2005

Haven't been coding for some time now. Just started to familiarize myself with VS 2005.
I've been trying to get a form to dock to the side of a screen.

Found a few coding examples online, mostly for VB 5 and VB 6. And expressions like "Screen.Width" and "Form1.Width" don't seem
to work any longer. Here is an example:
http://www.freevbcode.com/ShowCode.asp?ID=5329
I tried updating it, but didn't get anywhere.

I also tried code like "Me.Dock = Dockstyle.Right", but that didn't work either.

I need the form to be dockable via the title bar when in motion. Like ICQ basically...
ITD_TechnicianAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nayernaguibCommented:
Using the following code, you can dock a form to the right:

_____________________________________

        Me.Width = 200
        Me.Height = SystemInformation.WorkingArea.Height
        Me.Left = SystemInformation.WorkingArea.Width - 200
        Me.Top = 0

_____________________________________

Similarly, you can dock the form to any other screen edge.

_______________

  Nayer Naguib
0
ITD_TechnicianAuthor Commented:
That certainly does move it to the proper place, but it doesn't dock.
I want other applications to be able to maximize beside it
0
nayernaguibCommented:
The code on the page you posted above provides very similar functionality. It only adds the ability to drag forms to screen edges, but does not provide taskbar-like behavior.

_______________

  Nayer Naguib
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

nayernaguibCommented:
What you are trying to do is create what is called "application desktop toolbar". This can be done using Win32 API calls which will register your application as an "application desktop toolbar", set the position of the form, resize the desktop working area, etc...

This article provides a link to C++ source code that will do the job (if you are not familiar with Win32 C++ code, then you will not find this interesting at all):

  http://support.microsoft.com/default.aspx?scid=kb;en-us;134206

I will try to locate similar VB code for you.

_______________

  Nayer Naguib
0
nayernaguibCommented:
Here's what you need to do:

1. Download source code from this page:

  http://www.codeproject.com/csharp/csdoesshell3.asp

2. Using a C# compiler, compile the source code into a class library (DLL). Using Visual Studio IDE, you can create a new C# class library project, add all of the source files, remove the duplicate AssemblyInfo.cs file (the default copy generated by the new project wizard), and compile the code. Now you should have a DLL that contains the compiled classes.

3. Open your Visual Basic project, and add the DLL file using the Add Reference command.

4. Now you can write code like that shown below to create and show a docked form:

        Dim frm As New ShellLib.ApplicationDesktopToolbar
        frm.Width = 50
        frm.Edge = ShellLib.ApplicationDesktopToolbar.AppBarEdges.Left
        frm.Show()

and to restore previos desktop work area, you can use the statement:

        frm.Close()

_______________

  Nayer Naguib
0
ITD_TechnicianAuthor Commented:
Pretty sure I was able to create the DLL properly (Started the C# interface, created a new class library project. Used Add New Item to import all the cs files from the link and compiled the DLL).

Visual Studio doesn't seem to understand ShellLib.ApplicationDesktopToolbar however.
0
ITD_TechnicianAuthor Commented:
I must have created the DLL wrong. If I Add refference to ShellBasics.dll from the demo source code, then your code works fine.
Can you walk me through the DLL creation a little better?

Thanks..
0
nayernaguibCommented:
To use the compiled classes, you first need to add the DLL to the VB project that you are working on. Use the Add Reference command, browse to the DLL location and add it to your project.

_______________

  Nayer Naguib
0
ITD_TechnicianAuthor Commented:
Also is there a way I can use the DLL it creates on the form I am currently working on, rather then generating a new form on the fly
0
nayernaguibCommented:
Of course. To modify an existing form, let it inherit from class ShellLib.ApplicationDesktopToolbar rather than System.Windows.Forms.Form.

_______________

  Nayer Naguib
0
nayernaguibCommented:
The following line shows how to inherit from the ShellLib.ApplicationDesktopToolbar class:

Public Class myForm
    Inherits ShellLib.ApplicationDesktopToolbar

_______________

  Nayer Naguib
0
ITD_TechnicianAuthor Commented:
I get this error with that code

Base class 'ShellLib.ApplicationDesktopToolbar' specified for class 'myForm' cannot be different from the base class 'System.Windows.Forms.Form' of one of its other partial types.
0
nayernaguibCommented:
Click the exclamation mark that appears just below the line containing the error, and select "Change class 'myForm' to inherit from 'ShellLib.ApplicationDesktopToolbar'.

_______________

  Nayer Naguib
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ITD_TechnicianAuthor Commented:
Works like a charm. For refference.

Added Refference to ShellBasics.dll from csdoesshell3_demo

Used the following code:

Public Class Form1
    Inherits ShellLib.ApplicationDesktopToolbar

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Width = 200
        Me.Edge = ShellLib.ApplicationDesktopToolbar.AppBarEdges.Left

    End Sub

End Class
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.