Solved

Color on the MainMenu

Posted on 2001-07-12
11
2,590 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
  • 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
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!

 
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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Help on project with Soap 10 61
Adoquery sql  left join does not work 25 103
How to convert memory stream to PDF file 6 169
Delphi...Split view - idea? 1 113
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

685 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