2007. július 28., szombat
Right-align a menu item (2)
Problem/Question/Abstract:
I want to write a TMenu component where all items and sub menus are right justified.
Answer:
You can change the item's justification, if you add the MFT_RIGHTJUSTIFY constant to the item's type (fType member of the TMenuItemInfo structure). You can do it in the main menu's OnChange event handler. Here's an example:
procedure TForm1.MainMenu1Change(Sender: TObject; Source: TMenuItem; Rebuild:
Boolean);
var
XHandle: HMENU;
XMenuItemInfo: TMenuItemInfo;
XBuffer: array[0..79] of Char;
begin
XHandle := TMainMenu(Sender).Handle;
XMenuItemInfo.cbSize := 44;
XMenuItemInfo.fMask := MIIM_TYPE;
XMenuItemInfo.dwTypeData := XBuffer;
XMenuItemInfo.cch := SizeOf(XBuffer);
if GetMenuItemInfo(XHandle, 0, true, XMenuItemInfo) then
begin
XMenuItemInfo.fType := XMenuItemInfo.fType or MFT_RIGHTORDER or MFT_RIGHTJUSTIFY;
XMenuItemInfo.fMask := MIIM_TYPE;
SetMenuItemInfo(XHandle, 0, true, XMenuItemInfo);
end;
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése