?
Solved

Color on the MainMenu

Posted on 2001-07-12
11
Medium Priority
?
2,693 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 300 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

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month9 days, 5 hours left to enroll

764 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