Solved

Color on the MainMenu

Posted on 2001-07-12
11
2,532 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi cmd execution 6 60
add combobox item based on numbers 9 144
Dev Express grid collapse 2 45
Delphi Seattle StructureView color 1 5
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…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

803 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