Mega Code Archive

 
Categories / Delphi / Examples
 

TMainMenu tip

Title: TMainMenu tip Question: Tip about MainMenu Answer: (* Many applications have own MainMenu, MainMenu is very useful component, where are items to control your application,one of them is "Help" item. In some cases, you need to place this item at the RIGHT of an application, and make it splitted from all other.In this case, you can use this code: *) {Place it probably to OnCreate Event-if your main menu is static.} {Here is Help item splitted after button click} {Help Item we would like to make splitted from all other has name "Help1"} {*****************************************************************************} procedure TForm1.Button1Click(Sender: TObject); Var I: TMenuItemInfo; B: Array[0..79] of Char; begin ZeroMemory(@I, SizeOf(I)); with I do begin cbSize := 44; fMask := MIIM_TYPE; dwTypeData := B; cch := SizeOf(B); end; if GetMenuItemInfo(MainMenu1.Handle,Help1.MenuIndex,True, I) then begin I.fType := I.fType or MFT_RIGHTJUSTIFY; if SetMenuItemInfo(MainMenu1.Handle,Help1.MenuIndex, True, I) then DrawMenuBar(MainMenu1.WindowHandle); end; end; {*****************************************************************************} Ivan Sivak @Sizesoft