15
Show mnemonics in .rc dialog designer
public class C : VisualCommanderExt.ICommand
{
public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
Interop.EnumChildWindows((System.IntPtr)DTE.MainWindow.HWnd, WindowEnumProc, 0);
}
public static bool WindowEnumProc(System.IntPtr hwnd, int lParam)
{
System.IntPtr p = Interop.GetParent(hwnd);
if (GetClassName(p) == "#32770")
{
System.UInt32 WM_UPDATEUISTATE = 0x0128;
int UISF_HIDEACCEL = 2;
int UIS_INITIALIZE = 3;
Interop.SendMessage(hwnd, WM_UPDATEUISTATE, (System.IntPtr)(UISF_HIDEACCEL | (UIS_INITIALIZE << 16)), System.IntPtr.Zero);
}
return true;
}
public static string GetClassName(System.IntPtr wnd)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Capacity = 256;
Interop.GetClassName(wnd, sb, sb.Capacity);
return sb.ToString();
}
}
class Interop
{
public delegate bool WindowEnumDelegate(System.IntPtr hwnd, int lParam);
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern int EnumChildWindows(System.IntPtr hwnd,
WindowEnumDelegate del,
int lParam);
[System.Runtime.InteropServices.DllImport("user32.dll")]
static public extern int GetClassName(System.IntPtr hwnd, System.Text.StringBuilder lpClassName, int nMaxCount);
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern System.IntPtr GetParent(System.IntPtr hWnd);
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern System.IntPtr SendMessage(System.IntPtr hWnd, System.UInt32 Msg, System.IntPtr wParam, System.IntPtr lParam);
}
Command
CS
v4.0
true