Mega Code Archive

 
Categories / Delphi / System
 

Menus like Windows 9x start menu with RX Library

Title: Menus like Windows 9x start menu with RX-Library Question: How can i do a menu like Windows start menu? Answer: 1. You must have installed the RX-Library (www.rxlib.com). 2. Put a TRXPOPUPMENU, call Menu2. 3. Associate the property PopupMenu of the form with the previous menu. 4. Modify the property LeftMargin of Menu2 and put the value 15. 5. Open the event OnDrawMargin and put the following code. procedure TForm1.Menu2DrawMargin(Sender: TMenu; Rect: TRect); var i: Integer; rectangle:TRect; Heightz: Integer; begin Heightz:=0; For i:=0 to Menu2.Items.Count-1 Do Begin GetMenuItemRect (Form1.Handle, Menu2.Handle,i, Rectangle); Heightz:= Heightz +(Rectangle.Bottom-Rectangle.Top); end; GradientFillRect (Menu2.Canvas,Rect,clBlue, clYellow, fdBottomToTop,255); Menu2.Canvas.Brush.Style:=(bsClear); Menu2.Canvas.Font.Name:='Tahoma'; Menu2.Canvas.Font.Style:=[fsBold]; Menu2.Canvas.Font.Size:=10; WriteRotaePlus (Menu2.Canvas,1, Heightz-1, 'IterCom',90); end; Create another function: -------------------------- procedure TForm1. WriteRotaePlus (Canvas: TCanvas; X, Y: Integer; Text: String; Angle: Integer); var lf : TLogFont; tf : TFont; begin with Canvas do begin tf := TFont.Create; tf.Assign(Font); GetObject(tf.Handle, sizeof(lf), @lf); lf.lfEscapement := Angle*10; lf.lfOrientation := Angle*10; tf.Handle := CreateFontIndirect(lf); Canvas.TextFlags:=ETO_OPAQUE; Font.Assign(tf); tf.Free; TextOut(X,Y,Text); end; end; This last function is thanks to (Bernhard Angerer) http://www.delphi3000.com/article.asp?id=262 Of course you can optimize the code, removing the FOR/DO to another side. Here my question: is I possible do this with PopupMenu component? I hope that to you will be of usefulness. Regards.