Solved

Color on the MainMenu

Posted on 2001-07-12
11
2,642 Views
Last Modified: 2012-05-05
Who can I change the color of the TMainMenu, without using Windows, but define some own colors?
0
Comment
Question by:easysoft_studios
[X]
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
  • 4
  • 2
  • 2
  • +2
11 Comments
 
LVL 1

Expert Comment

by:alx512
ID: 6279822
I think you need to change the Menus.pas and include it to your project.
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6279961
Hi easysoft_studio,

not sure what you mean "without using Windows", but change color of TMainMenu not difficult in code.

type
  TForm1 = class(TForm)
    .....
    procedure FormCreate(Sender: TObject);
  public
    procedure DrawMenuItem(Sender: TObject; ACanvas: TCanvas;
      ARect: TRect; Selected: Boolean);
  end;

...

procedure TForm1.DrawMenuItem(Sender: TObject; ACanvas: TCanvas;
  ARect: TRect; Selected: Boolean);
var
  S: String;
begin
  with ACanvas do
  begin
    S := TMenuItem(Sender).Caption;
    if Selected then
      Brush.Color := clHighLight
    else
      Brush.Color := clLime;
    FillRect(ARect);
    DrawText(ACanvas.Handle, PChar(S), Length(S), ARect, DT_SINGLELINE or DT_VCENTER);
  end;

end;

procedure AllOnDrawTo(M: TMenuItem; P: TMenuDrawItemEvent);
var
  I: Integer;
begin
  M.OnDrawItem := P;
  for I := 0 to M.Count-1 do
    AllOnDrawTo(M.Items[I], P);
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  I: Integer;
begin
  for I := 0 to MM.Items.Count -1 do
    AllOnDrawTo(MM.Items[I], DrawMenuItem);
end;

-----------
Igor.
0
 

Author Comment

by:easysoft_studios
ID: 6280050
ITugay >> what I mean with the Windows colors, is the schemes, the user can set, so buttons, menuitems, fonts have the color/font the user want to. This have nothing to do with Delphi!


Sorry, but the code, only colors the itemes, not the whole MainMenu. That's what i'm looking for.


alx512 >> how should that help?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:ITugay
ID: 6280112
Do you mean that rest of the top of the form should be colored too?

just add this line to DrawMenuItem procedure. MenuIndex = nnn - number of top menuitems-1. Let say if you have "File Edit View" then nn = 2.

    // this line fill rest of the top of the form
    if (Parent = nil) and (TMenuItem(Sender).MenuIndex = 1) and not Selected then
      ARect.Right := Width;

    FillRect(ARect);
    DrawText(ACanvas.Handle, PChar(S), Length(S), ARect, DT_SINGLELINE or DT_VCENTER);
  end;

end;
0
 
LVL 17

Accepted Solution

by:
inthe earned 100 total points
ID: 6280116
hi,
component to make your menu look and feel like windows xp menus:
http://www.shagrouni.com/english/software/xpmenu.html

this is a example similar to what Igor gave:
http://www.delphi.about.com/library/weekly/aa100300a.htm
0
 
LVL 1

Expert Comment

by:alx512
ID: 6280136
Do you have a Delpthi source?
Copy menus.pas from source directory to your project dir.
Add it to the project. Then open it and do some modification like this:

if not Selected then
  begin
    OffsetRect(Rect, 1, 1);
    Font.Color := clBtnHighlight; // change to your color
    DrawText(Handle, PChar(Text), Length(Text), Rect, Flags);
    OffsetRect(Rect, -1, -1);
  end;
  if Selected and (ColorToRGB(clHighlight) = ColorToRGB(clBtnShadow)) then
  Font.Color := clBtnHighlight else // change to your color
  Font.Color := clBtnShadow; // change to your color
end;
DrawText(Handle, PChar(Text), Length(Text), Rect, Flags);
0
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6281872
I have a TCoolMenu Object. it has so exciting properties.like : font,color,backgroun picture,... for Delphi 3.
please give me your email. I will send it to you.becouse its source has  2852 lines and it needs another obeject too. therefor i thinks that is better i send it.

best regards
hamed
0
 

Author Comment

by:easysoft_studios
ID: 6281985
h_mohsenian >> my e-mail: easysoft_studios@hotmail.com
0
 
LVL 1

Expert Comment

by:h_mohsenian
ID: 6282152
I sent it to u.i hope it can be usefull for u.

best regards
hamed
0
 

Author Comment

by:easysoft_studios
ID: 6283782
I give the points to inthe for the xpmenu link. It *ucking cool!!
0
 

Author Comment

by:easysoft_studios
ID: 6283792
very nice component! It's *ucking cool!!!

Thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

724 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