i want to place a small form above the notification icons in left-to-right interface the icons to the right of the screen in right-to-left interface the icons to the left of the screen i want the code for that to work on xp and win7 please
5 Answers
Is this what you're looking for?
private static bool IsRightToLeft()
{
return CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft;
}

- 70,509
- 14
- 132
- 163
The flag you're looking for is WS_EX_LAYOUTRTL
(400000 hexadecimal). You get this flag by calling GetWindowLong(FindWindow(L"HHTaskBar", NULL), GWL_EXSTYLE)
.

- 173,980
- 10
- 155
- 350
Any System.Windows.Forms.Control
support such check: Control.RightToLeft
.

- 98,240
- 88
- 296
- 433
-
1It's actually an underlying property of all windows, and you don't want it from a random window. You want the RTL proeprty from the taskbar window. – MSalters Nov 23 '10 at 13:35
Stuart Dunkeld that dosnt help , CultureInfo has nothing to do with the interface if i could locate the location of the start button (on the taskbar) that would help
If you insist you can find the position and size of the Windows start button. To do that, first add this inside your class:
[DllImport("user32.dll")]
private static extern bool GetWindowRect(IntPtr hwnd, ref Rectangle rectangle);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, IntPtr className, string lpszWindow);
Then use such code.. in this example I show its width but you can read its Left/Right location as well:
IntPtr hwndTaskBarWin = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", null);
IntPtr hwndStartButton = FindWindowEx(hwndTaskBarWin, IntPtr.Zero, "Button", null);
if (hwndStartButton.Equals(IntPtr.Zero))
{
//Maybe Vista/Windows7?
hwndStartButton = FindWindowEx(IntPtr.Zero, IntPtr.Zero, (IntPtr)0xC017, null);
}
if (hwndStartButton.Equals(IntPtr.Zero))
{
MessageBox.Show("Sorry, can't find the Start button/orb");
}
else
{
Rectangle rect = Rectangle.Empty;
if (GetWindowRect(hwndStartButton, ref rect))
MessageBox.Show("Start button width: " + rect.Width);
}
Tested successfully under XP and Windows7, the Vista/7 trick credit goes to Waylon Flynn in his answer to this question.

- 1
- 1

- 66,030
- 26
- 140
- 208