Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Right aligned menubar

Posted on 2004-08-24
3
177 Views
Last Modified: 2010-08-05
Please help me:

How can I make Form1.MainMenu stick to right, without changing the BiDiMode of Form1. I mean any thing is ok but MainMenu1.

More Detail: I'm in XP with Delphi7 and like to run my application in any version of Windows.
0
Comment
Question by:szayeri
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 85 total points
ID: 11883513
var
  MenuItemInfo: TMenuItemInfo;
  Buffer: array[ 0..79 ] of Char;
begin
  MenuItemInfo.cbSize := 44; // Required for Windows 95
  MenuItemInfo.fMask := MIIM_TYPE;
  MenuItemInfo.dwTypeData := Buffer;
  MenuItemInfo.cch := SizeOf( Buffer );
  if GetMenuItemInfo( MainMenu1.Handle, MainMenu1.Items.IndexOf( Edit1 ), True, MenuItemInfo ) then begin
    MenuItemInfo.fType := MenuItemInfo.fType or MFT_RIGHTJUSTIFY;
    SetMenuItemInfo( MainMenu1.Handle, MainMenu1.Items.IndexOf( Edit1 ), True, MenuItemInfo );
  end;
end;

MainMenu1 is my main menu, Edit1 is the second menu-item in the top.
0
 

Author Comment

by:szayeri
ID: 11889794
Dear Workshop Alex

Thank You. Your code works fine but there is some questions remaining:
1) How can I force menu items to be redrawn in order to make them appear at right? They are actually right aligned but their position before redrawing does not say so.
2) when I rename Edit1 every thing goes back. why is it so and how much can I trust in this code in special conditions (renaming, changing menuindex, closing form and so on)?
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 11929292
The problem with my solution is that while you explicitly tell the menu to be right-alighned once, the TMemu component isn't really aware of this yet. Thus, when the TMenu recreates the menu for whatever reason, (like renaming) it will bring the menu back to it's original position. Basically, you should inherit a new component from TMainMenu and add the functionality for this new right-alignment property, which is not an easy job. This new component could then respond to changes in the menu and make sure the MFT_RIGHTJUSTIFY is set for a specific menuitem.
Basically, the whole secret behind right-aligned menus is just this flag...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question