how to develop a taskbar

i want to develop an application which will be like a ticker above the windows taskbar and i need to reserve a space so the windows dekstop will be -taskbar -my ticker


Answer this question

how to develop a taskbar

  • dsani

    Sorry for late reply

     

    Please use the following class to set the work area

     

     

    using System;

    using System.Runtime.InteropServices;

    public class WorkArea

    {

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

    private static extern Int32 SystemParametersInfo(Int32 uAction, Int32 uParam, IntPtr lpvParam, Int32 fuWinIni);

    private const Int32 SPI_SETWORKAREA = 47;

    public WorkArea(Int32 Left,Int32 Right,Int32 Top,Int32 Bottom)

    {

    _WorkArea.Left = Left;

    _WorkArea.Top = Top;

    _WorkArea.Bottom = Bottom;

    _WorkArea.Right = Right;

    }

    public struct RECT

    {

    public Int32 Left;

    public Int32 Right;

    public Int32 Top;

    public Int32 Bottom;

    }

    private RECT _WorkArea;

    public void SetWorkingArea()

    {

    IntPtr ptr=IntPtr.Zero;

    ptr = Marshal.AllocHGlobal(Marshal.SizeOf(_WorkArea));

    Marshal.StructureToPtr(_WorkArea,ptr,false);

    int i=SystemParametersInfo(SPI_SETWORKAREA,0,ptr,0);

    }

    }



  • Adam Davidson

    Hi Vikas,

    Iam coming across some issues with the docking sidebar on WIndows XP and Windows 2000 Systems. On XP the Sidebar reduces the work area as defined by its width and docks to the extreme right(in this case other windows get aligned to the left of the appbar and the appbars right is aligned with the right of the desktop before the work area was reduced) when i have an option set for Sidebar. If it is not a sidebar(reset actual work area) then i can drag my window and place it anywhere on the desktop. It works perfectly fine as desired.. But when i run the application on Windows 2000/2003 systems, the application when set as sidebar gets docked to the reduced desktop work area(the bars right is aligned with the right of reduced work area and all other windows right is aligned with bars left) leaving a blank space at the right of the desktop whose width is equal to the bars width.. It seems like it reduces the work area and then docks to the right(of the reduced work area) unlike in Windows XP system. iam not sure why this different behaviour on different systems.

    Can you help.. Appreciate your earlier help. I hope i explained the problem correctly.

    Thanks,

    Vinay


  • Darrell Davis

    How do i make other windows automatically adjust to the reduced working area. The SendNotifyMessage does not seem to work.

    Please help.

    Vinay


  • rasmasyean

    You are kinda fighting the system here. Look into doing it this way...


  • heinrich Breedt

    Hi all.. Can any one help me finding a VB .net version of the code in the above article. I read through the blog and found Vikas having some info about it. I would really appreciate you help guys.. thanks
  • Eric Richter

    You need to register your form as an "AppBar". Click here.

    I used this tutorial about a year ago and it worked just fine. With the class he made in that article you are able to register your application as an "AppBar" just like the taskbar. There are different dock modes you can set as well.


  • MaheshKshirsagar

    Max... although I have not tested it as its automatic conversion... hopefully it should work...

    Conversion Courtesy

    C# to VB.Net

    http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx

    VB.Net to C#

    http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx

    Code Snippet

    Imports System

    Imports System.Runtime.InteropServices


    Public Class WorkArea



    <System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint := "SystemParametersInfoA")> _
    Private Shared Function SystemParametersInfo(ByVal uAction As Int32, ByVal uParam As Int32, ByVal lpvParam As IntPtr, ByVal fuWinIni As Int32) As Int32
    End Function

    Private Const SPI_SETWORKAREA As Int32 = 47

    Public Sub New(ByVal Left As Int32, ByVal Right As Int32, ByVal Top As Int32, ByVal Bottom As Int32)


    _WorkArea.Left = Left

    _WorkArea.Top = Top

    _WorkArea.Bottom = Bottom


    _WorkArea.Right = Right
    End Sub

    Public Structure RECT


    Public Left As Int32

    Public Right As Int32

    Public Top As Int32

    Public Bottom As Int32

    End Structure

    Private _WorkArea As RECT

    Public Sub SetWorkingArea()



    Dim ptr As IntPtr = IntPtr.Zero

    ptr = Marshal.AllocHGlobal(Marshal.SizeOf(_WorkArea))

    Marshal.StructureToPtr(_WorkArea, ptr, False)

    Dim i As Integer = SystemParametersInfo(SPI_SETWORKAREA, 0, ptr, 0)

    End Sub

    End Class



  • cheariot

    can you please explain what you are trying to do. are you trying to emulate windows taskbar and want to recieve events for every new task being created/updated or destroyed.

  • David Pritchard

    I was doing wrong code..it works on Windows 2000 as well..but some some reason, the form docks to the reduced work area for a moment and then docks to the right corner of the desktop work area(original before reducing) and then it sets back the work area so that all other windows get refreshed to the reduced work area..

    I now need help on automatically resizing my form as taskbar is resized..right now thats not happening...How do i achieve that in C#

    Vinay


  • ZaeSr

    no

    i want to develop something like a news ticker which should resize the windows desktop because application should be always on top and i don't want to disturb other application by being on the top of it so i prefer to have a space for me to put my applicatio on it which will be above the taskbar



  • AlaaZaghmout

    sorry... forgot to say I am using C#



  • Jason Matkowsky

    Declare following constants

    Code Snippet

    private const int SPIF_SENDWININICHANGE = 2;

    private const int SPIF_UPDATEINIFILE = 1;

    private const int SPIF_change = SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE;

    and use the following line of code

    Code Snippet

    int i = SystemParametersInfo(SPI_SETWORKAREA, Marshal.SizeOf(_WorkArea), ptr, SPIF_change);

    Let me know if you still face any problem



  • Ansible

    It worked thanks very much

    I did my Get and Set Working area methods as below

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

    private static extern Int32 SystemParametersInfo(Int32 uAction, Int32 uParam, IntPtr lpvParam, Int32 fuWinIni);

    public static void GetWorkspace(ref RECT oRECT)

    {

    IntPtr ptr = IntPtr.Zero;

    ptr = Marshal.AllocHGlobal(Marshal.SizeOf(oRECT));

    Marshal.StructureToPtr(oRECT, ptr, true);

    SystemParametersInfo(SPI_GETWORKAREA, Marshal.SizeOf(oRECT), ptr, 0);

    oRECT = (RECT) Marshal.PtrToStructure(ptr, new RECT().GetType());

    }

    public static int SetWorkspace(RECT oRECT)

    {

    IntPtr ptr = IntPtr.Zero;

    ptr = Marshal.AllocHGlobal(Marshal.SizeOf(oRECT));

    Marshal.StructureToPtr(oRECT, ptr, true);

    return SystemParametersInfo(SPI_SETWORKAREA, Marshal.SizeOf(oRECT), ptr, SPIF_change);

    }


  • PattiBiggs

    use the following code to resize the work area (the area in which an application can be maximized)

    Public Declare Function SystemParametersInfo Lib "user32.dll" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
    Public Const SPI_SETWORKAREA As Long = 47
    Public Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
    End Type

    Public Function SetWorkingArea()
    Dim WorkArea As RECT

    With WorkArea
    .Left = 0
    .Top = 0
    .Bottom = 768
    .Right = 1024
    End With

    SystemParametersInfo SPI_SETWORKAREA, Len(WorkArea), WorkArea, 1
    End Function

    please make sure to refresh the work area again if sumone resize or move the taskbar.



  • how to develop a taskbar