zoukankan      html  css  js  c++  java
  • 将某个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;

      

  • 相关阅读:
    Python3之random模块常用方法
    Go语言学习笔记(九)之数组
    Go语言学习笔记之简单的几个排序
    Go语言学习笔记(八)
    Python3之logging模块
    Go语言学习笔记(六)
    123. Best Time to Buy and Sell Stock III(js)
    122. Best Time to Buy and Sell Stock II(js)
    121. Best Time to Buy and Sell Stock(js)
    120. Triangle(js)
  • 原文地址:https://www.cnblogs.com/solokey/p/2113320.html
Copyright © 2011-2022 走看看