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
Right-align a menu item (2) 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
23-Oct-02
Category
VCL-Menu
Language
Delphi 2.x
Views
51
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

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:
1   
2   procedure TForm1.MainMenu1Change(Sender: TObject; Source: TMenuItem; Rebuild:
3     Boolean);
4   var
5     XHandle: HMENU;
6     XMenuItemInfo: TMenuItemInfo;
7     XBuffer: array[0..79] of Char;
8   begin
9     XHandle := TMainMenu(Sender).Handle;
10    XMenuItemInfo.cbSize := 44;
11    XMenuItemInfo.fMask := MIIM_TYPE;
12    XMenuItemInfo.dwTypeData := XBuffer;
13    XMenuItemInfo.cch := SizeOf(XBuffer);
14    if GetMenuItemInfo(XHandle, 0, true, XMenuItemInfo) then
15    begin
16      XMenuItemInfo.fType := XMenuItemInfo.fType or MFT_RIGHTORDER or 
17  MFT_RIGHTJUSTIFY;
18      XMenuItemInfo.fMask := MIIM_TYPE;
19      SetMenuItemInfo(XHandle, 0, true, XMenuItemInfo);
20    end;
21  end;


			
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