2010-11-23 10 views
0

je veux placer un petit formulaire au-dessus des icônes de notification dans l'interface de gauche à droite les icônes à droite de l'écran dans l'interface de droite à gauche les icônes à gauche de l'écran je veux le code pour que cela fonctionne sur xp et win7 s'il vous plaîtcomment détecter une interface Windows droite à gauche C#?

+0

Vous aurez plus de chance avec quelque chose comme ça sur stackoverflow.com –

Répondre

2

Est-ce ce que vous cherchez?

private static bool IsRightToLeft() 
{ 
    return CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft; 
} 
0

Tout soutien System.Windows.Forms.Control tel contrôle: Control.RightToLeft.

MSDN

+1

C'est en fait une propriété sous-jacente de toutes les fenêtres, et vous ne le voulez pas d'une fenêtre aléatoire. Vous voulez le proeprty RTL de la fenêtre de la barre des tâches. – MSalters

0

Stuart Dunkeld que dosnt aide, CultureInfo n'a rien à voir avec l'interface si je pouvais localiser l'emplacement du bouton de démarrage (sur la barre des tâches) qui aiderait

2

Le drapeau vous recherchez est WS_EX_LAYOUTRTL (400000 hexadécimal). Vous obtenez ce drapeau en appelant GetWindowLong(FindWindow(L"HHTaskBar", NULL), GWL_EXSTYLE).

0

Si vous insistez, vous pouvez trouver la position et la taille du bouton de démarrage de Windows. Pour ce faire, ajoutez d'abord ce dans votre classe:

[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); 

Ensuite, utilisez ce code .. dans cet exemple, je montre sa largeur, mais vous pouvez lire son emplacement gauche/droite ainsi:

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); 
} 

Testé avec succès sous XP et Windows7, le crédit d'astuce Vista/7 va à Waylon Flynn dans sa réponse au this question.