• 将某个MenuItem移动至右侧,即Help sytle.


    调用时

    1 //右侧显示
    2
    3 SetMainMenuAlignment(MainMenu1, True);
    4
    5 //左侧显示
    6
    7 SetMainMenuAlignment(MainMenu1, False);

      
    不多说了....这个东西貌似也没什么实际用途...无聊写着玩吧..

     1 //============================无敌分割线=====================
    2
    3 //将某个MenuItem(包括其右侧所有MenuItem),移动至右侧
    4
    5 procedure SetMenuItemAlignment(MainMenu: TMainMenu; MenuItem: TMenuItem; const ToRightSide: Boolean);
    6 var
    7 aForm: TForm;
    8 Flags: Integer;
    9 begin
    10 if MainMenu.Items.IndexOf(MenuItem) < 0 then
    11 Exit;
    12 if not (MainMenu.Owner is TCustomForm) then
    13 Exit;
    14 aForm := MainMenu.Owner as TForm;
    15 if ToRightSide then
    16 Flags := MF_BYPOSITION or MF_HELP
    17 else
    18 Flags := MF_BYPOSITION;
    19 try
    20 ModifyMenu(MainMenu.Handle, MenuItem.MenuIndex, Flags, MenuItem.Handle, PChar(MenuItem.Caption));
    21 finally
    22 Windows.SetMenu(aForm.Handle, MainMenu.Handle);
    23 end;
    24 end;
    25
    26
    27
    28
    29
    30 //将Menu显示在右侧
    31
    32 procedure SetMainMenuAlignment(Menu: TMainMenu; const ToRightSide: Boolean);
    33 var
    34 i: Integer;
    35 aForm: TForm;
    36 Flags: Integer;
    37 begin
    38 if not (Menu.Owner is TCustomForm) then
    39 Exit;
    40 aForm := Menu.Owner as TForm;
    41 if Menu.Items.Count <= 0 then
    42 Exit;
    43 if ToRightSide then
    44 Flags := MF_BYPOSITION or MF_HELP
    45 else
    46 Flags := MF_BYPOSITION;
    47 try
    48 ModifyMenu(Menu.Handle, 0, Flags, Menu.Items[0].Handle, PChar(Menu.Items[0].Caption));
    49 finally
    50 Windows.SetMenu(aForm.Handle, Menu.Handle);
    51 end;
    52 end;

      

  • 相关阅读:
    poj2828 Buy Tickets
    bzoj2724: [Violet 6]蒲公英
    0x41 并查集
    poj1733 Parity game
    poj2976 Dropping tests
    poj1704 Georgia and Bob
    bzoj4517: [Sdoi2016]排列计数
    poj2947Widget Factory
    0x3A 博弈论之SG函数
    我国已累计招收培养14万余名博士后
  • 原文地址:https://www.cnblogs.com/solokey/p/2113320.html
Copyright © 2020-2023  润新知