0

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 Answers5

2

Is this what you're looking for?

private static bool IsRightToLeft()
{
     return CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft;
} 
stuartd
  • 70,509
  • 14
  • 132
  • 163
2

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).

MSalters
  • 173,980
  • 10
  • 155
  • 350
0

Any System.Windows.Forms.Control support such check: Control.RightToLeft.

MSDN

abatishchev
  • 98,240
  • 88
  • 296
  • 433
  • 1
    It'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
0

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

0

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.

Community
  • 1
  • 1
Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208