Taskbar Location

How to determine where the taskbar is located? I need to know how to show my notification in the right corner. Thanks

Edit: Thank you, Hans Passant. I used this to get a place. I hope everything is in order.

GetTaskbarLocation(TaskbarPosition.GetTaskbarPosition()); private void GetTaskbarLocation(Rectangle rc) { if (rc.X == rc.Y) { if (rc.Right < rc.Bottom) taskbarLocation = TaskbarLocation.Left; if (rc.Right > rc.Bottom) taskbarLocation = TaskbarLocation.Top; } if (rc.X > rc.Y) taskbarLocation = TaskbarLocation.Right; if (rc.X < rc.Y) taskbarLocation = TaskbarLocation.Bottom; } 
+4
source share
4 answers
  public static Rectangle GetTaskbarPosition() { var data = new APPBARDATA(); data.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(data); IntPtr retval = SHAppBarMessage(ABM_GETTASKBARPOS, ref data); if (retval == IntPtr.Zero) throw new Win32Exception("Please re-install Windows"); return new Rectangle(data.rc.left, data.rc.top, data.rc.right - data.rc.left, data.rc.bottom - data.rc.top); } // P/Invoke goo: private const int ABM_GETTASKBARPOS = 5; [System.Runtime.InteropServices.DllImport("shell32.dll")] private static extern IntPtr SHAppBarMessage(int msg, ref APPBARDATA data); private struct APPBARDATA { public int cbSize; public IntPtr hWnd; public int uCallbackMessage; public int uEdge; public RECT rc; public IntPtr lParam; } private struct RECT { public int left, top, right, bottom; } 
+5
source
 SHAppBarMessage(ABM_GETTASKBARPOS) 

See the SHAppBarMessage Function and ABM_GETTASKBARPOS Message for more information and the pinvoke page for SHAppBarMessage contains a sample VB.Net that should not be translated too complicated.

+1
source

The SHAppBarMessage function will return you taskbar information if you go to ABM_GETTASKBARPOS . It has an out parameter, which is a pointer to APPBARDATA , which contains the taskbar screen corridors. You can use to determine where on the screen.

+1
source

It is probably best to use an accessible API: NotifyIcon.ShowBalloonTip :

 void Form1_DoubleClick(object sender, EventArgs e) { notifyIcon1.Visible = true; notifyIcon1.ShowBalloonTip(20000, "Information", "This is the text", ToolTipIcon.Info ); } 
+1
source

All Articles