Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to split up a TPopupMenu into columns at runtime Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
30-Aug-02
Category
VCL-Menu
Language
Delphi 2.x
Views
93
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I have a PopupMenu, which contains a lot of menu items. Sometimes the user can't 
see all menus on the screen. The same problem occurs with MainMenu. How I can split 
PopupMenu at runtime that it will be all visible on the screen?

Answer:

TMenuItem has a Break property which you can use to split a menu up into columns. 
The following procedure lets you specify the number of items you want in each 
column:


1   procedure FormatMenu(item: TMenuItem; maxrows: integer);
2   var
3     ix: integer;
4     item2: TMenuItem;
5   begin
6     for ix := 1 to item.Count - 1 do {ignore first}
7     begin
8       item2 := item.Items[ix];
9       if ix mod maxrows = 0 then
10        item2.Break := mbBreak
11      else
12        item2.Break := mbNone;
13    end;
14  end;
15  
16  
17  //You call it like:
18  
19  
20  FormatMenu(PopupMenu.Items, 4);



If instead of an absolute number, you want a specific number of columns, say three:


21  count := PopupMenu.Items.Count div 3;
22  if PopupMenu.Items.Count mod 3 > 0 then
23    inc(count);
24  FormatMenu(PopupMenu.Items, count);


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC