Windows Develop Bookmark and Share   
 index > Windows Forms General > Control Similar to Taskbar
• Windows Forms General
• Windows Forms Designer
• ClickOnce and Setup & Deployment Projects
• Windows Forms Data Controls and Databinding
• Windows Forms Sample Applications

Control Similar to Taskbar

I'm developing a Windows Application, in which i'm having a form with just toolbar alone. I need to develop an application that is very similar to windows taskbar, i mean, the taskbar resizes the desktop screen for general usage. For example When you resize the taskbar control to half the screen, the desktop got shrunk. and all the windows in the desktop is resized.

Similarly, i will be placing the form in the top of the screen, And that portion where the form resided needs to change the usable desktop area. Any Ideas ?
Thanks & Regards, Srinivasan
SrinivasanMandiHariharan  Tuesday, April 21, 2009 3:14 PM
You can adjust the working area of the screen using the SystemParametersInfo WinAPI call. This requires a bit of P/Invoke. The following code should get you started in that direction. It's a short example that changes the working bounds of the desktop area by reducing it from the top 40 pixels. It then waits for user input, and re-adjusts the area back to it's original position. This is a console application.

using System.Runtime.InteropServices;

using System;

namespace ConsoleApplication1

{

public struct RECT

{

public int Left;

public int Top;

public int Right;

public int Bottom;

}

class WorkArea

{

[DllImport("user32.dll", EntryPoint="SystemParametersInfoA")]

public static extern bool SystemParametersInfo(uint uAction, uint uparam, ref RECT rect, uint fuWinIni);

private const uint WM_SETTINGCHANGE = 0x1a;

const uint SPI_GETWORKAREA = 48;

const uint SPI_SETWORKAREA = 47;

public static bool SetWorkArea(RECT rect)

{

return SystemParametersInfo(SPI_SETWORKAREA, 0, ref rect, WM_SETTINGCHANGE);

}

public static RECT GetWorkArea()

{

RECT rect = new RECT();

SystemParametersInfo(SPI_GETWORKAREA, 0, ref rect, 0);

return rect;

}

}

class Program

{

static void Main(string[] args)

{

RECT original = WorkArea.GetWorkArea();

// create the new boundaries. Start with the original

RECT newBounds = original;

newBounds.Top += 40;

// set the new boundaries.

WorkArea.SetWorkArea(newBounds);

// wait for user input.

Console.WriteLine("Bounds have changed. Try minimizing and maximizing a window," +

"then press enter to restore the window to it's original state.");

Console.ReadLine();

// reset the original boundaries.

WorkArea.SetWorkArea(original);

// wait for user input.

Console.WriteLine("All done.");

Console.ReadLine();

}

}

}


David Morton - http://blog.davemorton.net/
David M Morton  Tuesday, April 21, 2009 4:39 PM
You can adjust the working area of the screen using the SystemParametersInfo WinAPI call. This requires a bit of P/Invoke. The following code should get you started in that direction. It's a short example that changes the working bounds of the desktop area by reducing it from the top 40 pixels. It then waits for user input, and re-adjusts the area back to it's original position. This is a console application.

using System.Runtime.InteropServices;

using System;

namespace ConsoleApplication1

{

public struct RECT

{

public int Left;

public int Top;

public int Right;

public int Bottom;

}

class WorkArea

{

[DllImport("user32.dll", EntryPoint="SystemParametersInfoA")]

public static extern bool SystemParametersInfo(uint uAction, uint uparam, ref RECT rect, uint fuWinIni);

private const uint WM_SETTINGCHANGE = 0x1a;

const uint SPI_GETWORKAREA = 48;

const uint SPI_SETWORKAREA = 47;

public static bool SetWorkArea(RECT rect)

{

return SystemParametersInfo(SPI_SETWORKAREA, 0, ref rect, WM_SETTINGCHANGE);

}

public static RECT GetWorkArea()

{

RECT rect = new RECT();

SystemParametersInfo(SPI_GETWORKAREA, 0, ref rect, 0);

return rect;

}

}

class Program

{

static void Main(string[] args)

{

RECT original = WorkArea.GetWorkArea();

// create the new boundaries. Start with the original

RECT newBounds = original;

newBounds.Top += 40;

// set the new boundaries.

WorkArea.SetWorkArea(newBounds);

// wait for user input.

Console.WriteLine("Bounds have changed. Try minimizing and maximizing a window," +

"then press enter to restore the window to it's original state.");

Console.ReadLine();

// reset the original boundaries.

WorkArea.SetWorkArea(original);

// wait for user input.

Console.WriteLine("All done.");

Console.ReadLine();

}

}

}


David Morton - http://blog.davemorton.net/
David M Morton  Tuesday, April 21, 2009 4:39 PM
Google SHAppBarMessage to find out how to create your own taskbar.
Hans Passant.
nobugz  Wednesday, April 22, 2009 3:30 AM

You can use google to search for other answers

 

More Threads

• Blinking a cell in datagridview
• textbox hooks?
• sub New() vs Sub Main()
• Logging application: Want my RichTextBox to not scroll all the time.
• DataGridView ignoring GUI operations
• Multi Variables in URL
• MDI Keystrokes
• can i map the content at form to the printdocument
• execute function without Button click
• Can I query an embedded (csv file) resource with LINQ?