Total Commander里Help菜单在菜单栏右对齐的效果的实现方法
Total Commander里Help菜单在菜单栏右对齐的效果是什么原理,用C#怎么做?
如图:
谢谢 游民一族 的指点,终于找到方法了。
[StructLayout(LayoutKind.Sequential)]
public class MenuItemInfo
{
public Int32 cbSize;
public Int32 fMask;
public Int32 fType;
public Int32 fState;
public Int32 wID;
public IntPtr hSubMenu;
public IntPtr hbmpChecked;
public IntPtr hbmpUnchecked;
public IntPtr dwItemData;
public string dwTypeData;
public Int32 cch;
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool GetMenuItemInfo(
HandleRef menuHandle,
Int32 itemIndex,
bool byPosition,
[In, Out]MenuItemInfo menuItemInfo);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool SetMenuItemInfo(
HandleRef menuHandle,
Int32 itemIndex,
bool byPosition,
MenuItemInfo menuItemInfo);
const Int32 MIIM_FTYPE = 0x00000100;
const Int32 MFT_RIGHTJUSTIFY = 0x00004000;
public static void RightJustifyMenuItem(MenuItem menuItem)
{
HandleRef menuHandle = new HandleRef(menuItem.Parent, menuItem.Parent.Handle);
MenuItemInfo menuItemInfo = new MenuItemInfo();
menuItemInfo.cbSize = Marshal.SizeOf(typeof(MenuItemInfo));
menuItemInfo.fMask = MIIM_FTYPE;
GetMenuItemInfo(menuHandle, menuItem.Index, true, menuItemInfo);
 
public class MenuItemInfo
{
public Int32 cbSize;
public Int32 fMask;
public Int32 fType;
public Int32 fState;
public Int32 wID;
public IntPtr hSubMenu;
public IntPtr hbmpChecked;
public IntPtr hbmpUnchecked;
public IntPtr dwItemData;
public string dwTypeData;
public Int32 cch;
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool GetMenuItemInfo(
HandleRef menuHandle,
Int32 itemIndex,
bool byPosition,
[In, Out]MenuItemInfo menuItemInfo);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool SetMenuItemInfo(
HandleRef menuHandle,
Int32 itemIndex,
bool byPosition,
MenuItemInfo menuItemInfo);
const Int32 MIIM_FTYPE = 0x00000100;
const Int32 MFT_RIGHTJUSTIFY = 0x00004000;
public static void RightJustifyMenuItem(MenuItem menuItem)
{
HandleRef menuHandle = new HandleRef(menuItem.Parent, menuItem.Parent.Handle);
MenuItemInfo menuItemInfo = new MenuItemInfo();
menuItemInfo.cbSize = Marshal.SizeOf(typeof(MenuItemInfo));
menuItemInfo.fMask = MIIM_FTYPE;
GetMenuItemInfo(menuHandle, menuItem.Index, true, menuItemInfo);
 
补充:软件开发 , C# ,