Club Builder - Foros de discusión Club Builder
Foro de C++Builder en español
 
 FAQFAQ   BuscarBuscar   MiembrosMiembros   Grupos de UsuariosGrupos de Usuarios   RegistrarseRegistrarse 
 PerfilPerfil   Entra para ver tus mensajes privadosEntra para ver tus mensajes privados   EntrarEntrar 

Colores dentro del TMenu

 
Publicar nuevo tema   Responder al tema    Foros de discusión -> Consultas
Ver tema anterior :: Ver tema siguiente  
Autor Mensaje
Mensaje    Asunto: Colores dentro del TMenu Responder citando

En el siguiente enlace existe, un ejemplo para poner colores en el TMenu.. al estilo Office XP

http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=16328

pero parece que el autor, olvidó poner todos los archivos si alguien, sabe cual es el problema..

espero que se pueda encontrar la solucion...

saludos...
_________________
Cool
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar email MSN Messenger
Mensaje    Asunto: Responder citando

No es que el autor olvidase poner nada, aunque claro que desmarcando algunos "packages" lo podría haber solucionado.

El problema es que si tenemos algún "package" que no tiene otra persona instalado y seleccionado, aunque no usemos ningún componente del mismo, el Builder lo incluye en el archivo de proyecto, por lo que al intentar compilarlo en una versión donde esos packages no estén instalados pues da estos mensajes de error.

Para solucionarlo, solo tienes que editar con el "Block de notas" por ejemplo, el archivo "Project1.bpr" y borrar las siguientes coincidencias: "Custom.lib", "INDY50.lib" y "DiamondBCB5.lib" y listo, ya puedes abrirlo desde el Builder.

Y bueno, esperemos que Borland algún día solucione estos detallitos...
Volver arriba
Ver perfil de usuario Enviar mensaje privado
Mensaje    Asunto: Responder citando

Hola César. ¿Puedes colgar el código en el foro? No me deja descargarlo.
Gracias, y un saludo.
_________________
Nunca digas "Es imposible" sin intentarlo antes.
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar email
Mensaje    Asunto: Responder citando

He quitado las coincidencias que dice _Leo pero al compilar me sale el error "Unable to open file CUSTOM.LIB" (y eso que lo he quitado).
_________________
¡ADELANTE CON ESTE SUPER FORO!
Volver arriba
Ver perfil de usuario Enviar mensaje privado
Mensaje    Asunto: Responder citando

Listo ahora si funciona....
_________________
Cool
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar email MSN Messenger
Mensaje    Asunto: Responder citando

Esto es el Codigo

Unit.cpp
Código:

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
   : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Example1DrawItem(TObject *Sender, TCanvas *ACanvas,
      TRect &ARect, bool Selected)
{
   TRect FocusRectBorder;
   TRect FocusRectFill;
   TMenuItem *MenuItem = ((TMenuItem*)Sender);

   AnsiString Text = MenuItem->Caption;

   // Color the background behind the text
   ACanvas->Brush->Color = MainMenuBackground;
   ACanvas->FillRect(ARect);

   if(Text == "")
      return;

   if(Selected)
   {
      // Draw the outline of the selection box
      FocusRectBorder = ARect;
      ACanvas->Brush->Color = BorderColor;
      ACanvas->FrameRect(FocusRectBorder);


      // Draw the inside of the selection box
      // Make is a little smaller so it does not erase the outline
      FocusRectFill = ARect;
      FocusRectFill.Top += SideBuffer;
      FocusRectFill.Right -= SideBuffer;
      FocusRectFill.Left += SideBuffer;
      FocusRectFill.Bottom -= SideBuffer;
      ACanvas->Brush->Color = MainMenuHighlightColor;
      ACanvas->FillRect(FocusRectFill);

      // Set the color that we want our text drawn when the item is selected
      ACanvas->Font->Color = MainMenuHighlightTextColor;
   }
   else
   {
      ACanvas->Font->Color = MainMenuTextColor;
   }


   int TextLength;
   TRect TextRect;

   TextLength = Text.Length();
   TextRect = ARect;
   // This determines where the text is drawn.
   TextRect.Left += 5;
   TextRect.Top += 1;

   // Draw the text
   DrawText(ACanvas->Handle,Text.c_str(), TextLength, &TextRect, 0);

}
//---------------------------------------------------------------------------

void __fastcall TForm1::MyDrawItem(TObject* Sender, TCanvas* ACanvas,
   const TRect &ARect, bool Selected)
{
   int TopPos, TextLength;
   AnsiString Text;
   TRect TempRect;
   TRect VerticalRect;
   TRect FocusRectBorder;
   TRect FocusRectFill;
   TRect TextRect;

   TMenuItem *MenuItem = ((TMenuItem*)Sender);

   Text = MenuItem->Caption;

   // Draw the Background erases anything that was there before.
   ACanvas->Brush->Color = MenuColor;
   ACanvas->FillRect(ARect);

   // Draw any seperator lines
   if(Text==BLANK_LINE)
   {
      // Draw the Vertical Bar
      VerticalRect = ARect;
      VerticalRect.Top -= SideBuffer;
      VerticalRect.Right = VerticalWidth;
      VerticalRect.Bottom += SideBuffer;
      ACanvas->Brush->Color = VerticalColor;
      ACanvas->FillRect(VerticalRect);

      // Draw the Blank Line
      ACanvas->MoveTo(VerticalWidth,ARect.Top+ARect.Height()/2);
      ACanvas->LineTo(ARect.Right,ARect.Top+ARect.Height()/2);
      return;
   }

   // This is for non seperator lines

   TextLength = Text.Length();

   if(Selected)
   {
      // Have to draw the vertical bar section to fill in the area that is not
      // covered by the selection rect
      VerticalRect = ARect;
      VerticalRect.Top -= SideBuffer;
      VerticalRect.Right = VerticalWidth;
      VerticalRect.Bottom += SideBuffer;
      ACanvas->Brush->Color = VerticalColor;
      ACanvas->FillRect(VerticalRect);

      if(MenuItem->Enabled)
      {
         // The item is selected and enabled

         // Draw the focus rect outline border
         FocusRectBorder = ARect;
         FocusRectBorder.Left += FocusRectLeftIndent - SideBuffer;
         FocusRectBorder.Right -= FocusRectRightIndent - SideBuffer;
         ACanvas->Brush->Color = BorderColor;
         ACanvas->FrameRect(FocusRectBorder);


         // Fill in the focus rect.  Making it a little smaller so as to not
         // draw over the outline
         FocusRectFill = ARect;
         FocusRectFill.Right -= FocusRectRightIndent;
         FocusRectFill.Left += FocusRectLeftIndent;
         FocusRectFill.Bottom -= SideBuffer;
         FocusRectFill.Top += SideBuffer;
         ACanvas->Brush->Color = HighlightColor;
         ACanvas->FillRect(FocusRectFill);

         // Set the way we want to draw our text
         ACanvas->Font->Color = HighlightTextColor;
         ACanvas->Font->Style = TFontStyles() << fsBold;
      }
      else
      {
         // Menu item is not enabled so do not draw any selection
         // rect and change the text color to reflect its unenabled state
         // NOTE: The icon is still drawn normally and not disabled
         ACanvas->Font->Style = TFontStyles();
         ACanvas->Brush->Color = NormalTextBackground;
         ACanvas->Font->Color = DisabledTextColor;
      }

   }
   else
   {
      // Fill in the vertical area
      VerticalRect = ARect;
      VerticalRect.Top -= SideBuffer;
      VerticalRect.Right = VerticalWidth;
      VerticalRect.Bottom += SideBuffer;
      ACanvas->Brush->Color = VerticalColor;
      ACanvas->FillRect(VerticalRect);

      // Set the text background color and font based on if it is enabled or not
      if(MenuItem->Enabled)
      {
         ACanvas->Brush->Color = NormalTextBackground;
         ACanvas->Font->Color = NormalTextColor;
      }
      else
      {
         ACanvas->Brush->Color = NormalTextBackground;
         ACanvas->Font->Color = DisabledTextColor;
      }

   }

   // Calculate out the Rect we want to draw our text in
   TextRect = ARect;
   TextRect.Left += LeftTextPos;
   if(Offset > 0)
      TextRect.Top += Offset/2 + SideBuffer;
   else
      TextRect.Top += 2 + SideBuffer;

   TextRect.Top += SideBuffer;

   // Draw any menu item icons
   if(Menu->Images != NULL)
   {
      Icon = new TIcon();
      Menu->Images->GetIcon(MenuItem->ImageIndex,Icon);
      ACanvas->Draw(5,ARect.Top+ItemOffset+1,Icon);
      delete Icon;
   }

   // Draw the text
   DrawText(ACanvas->Handle,Text.c_str(), TextLength, &TextRect, 0);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::MyExpandItemWidth(TObject *Sender,
   TCanvas *ACanvas, int &Width, int &Height)
{
   Width += MenuIncreaseWidth;
   Height += Offset;
   MenuItemHeight = Height;
   ItemOffset = Offset/2;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
   Custom=TColor(RGB(185,239,245));
   MainMenuBackground = clSilver;
   MainMenuHighlightColor = Custom;
   MainMenuTextColor = clBlack;
   MainMenuTextBackground = clSilver;
   MainMenuHighlightTextColor = clBlack;
   VerticalColor = clSilver;
   MenuColor = clWhite;
   HighlightColor = Custom;
   BorderColor = clBlack;
   NormalTextColor = clBlack;
   NormalTextBackground = clWhite;
   HighlightTextColor = clBlack;
   DisabledTextColor = clSilver;
   VerticalWidth = 26;
   FocusRectRightIndent = 3;
   FocusRectLeftIndent = 3;
   LeftTextPos = 35;
   SideBuffer = 1;

   if(Menu->Images == NULL)
      MenuIncreaseWidth = 100;
   else
      MenuIncreaseWidth = 50;

   Offset = 5;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Example1Click(TObject *Sender)
{
   TMenuItem *MenuItem = ((TMenuItem*)Sender);
   if(MenuItem->Count > 0)
   {
      for(int i=0; i <= MenuItem->Count-1; i++)
      {
         MenuItem->Items[i]->OnMeasureItem = MyExpandItemWidth;
         MenuItem->Items[i]->OnDrawItem = MyDrawItem;
         if(MenuItem->Items[i]->Count > 0)
         {
            for(int x=0; x <= MenuItem->Items[i]->Count-1; x++)
            {
               MenuItem->Items[i]->Items[x]->OnMeasureItem = MyExpandItemWidth;
               MenuItem->Items[i]->Items[x]->OnDrawItem = MyDrawItem;
            }
         }
      }
   }
}
//---------------------------------------------------------------------------

y Este es la Unit.h
Código:

//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Menus.hpp>
#include <ImgList.hpp>
//---------------------------------------------------------------------------
const AnsiString BLANK_LINE="-";


class TForm1 : public TForm
{
__published:   // IDE-managed Components
   TMainMenu *MainMenu1;
   TMenuItem *Example1;
   TMenuItem *MenuItemOne1;
   TMenuItem *objectMenuItemOne1TMenuItem1;
   TMenuItem *MenuItemThree1;
   TMenuItem *MenuItemFour1;
   TMenuItem *MenuItemFive1;
   TMenuItem *MenuItemSix1;
   TMenuItem *MenuItemSeven1;
   TMenuItem *MenuItemEight1;
   TMenuItem *MenuItemNine1;
   TMenuItem *MenuItemTen1;
   TMenuItem *SubMenuItemExample1;
   TMenuItem *SubMenuOne1;
   TMenuItem *SubMenuTwo1;
   TMenuItem *SubMenuThree1;
   TMenuItem *SubMenuFour1;
   TMenuItem *SubMenuFive1;
   TImageList *ImageList1;
   TMenuItem *N1;
   TMenuItem *N2;
    TMenuItem *hola1;
    TMenuItem *primero1;
    TMenuItem *segundo1;
   void __fastcall Example1Click(TObject *Sender);
   void __fastcall Example1DrawItem(TObject *Sender, TCanvas *ACanvas,
          TRect &ARect, bool Selected);
   void __fastcall FormCreate(TObject *Sender);

private:   // User declarations
   TColor MainMenuBackground;
   TColor MainMenuHighlightColor;
   TColor MainMenuTextColor;
   TColor MainMenuTextBackground;
   TColor MainMenuHighlightTextColor;
   TColor Custom;
   TColor VerticalColor;
   TColor MenuColor;
   TColor HighlightColor;
   TColor BorderColor;
   TColor NormalTextColor;
   TColor NormalTextBackground;
   TColor HighlightTextColor;
   TColor DisabledTextColor;
   int VerticalWidth;
   int FocusRectRightIndent;
   int FocusRectLeftIndent;
   int LeftTextPos;
   int SideBuffer;
   int MenuIncreaseWidth;
   int Offset;

   int MenuItemHeight;
   int ItemOffset;
   TIcon *Icon;
   Graphics::TBitmap *Image;

protected:
   void __fastcall MyExpandItemWidth(TObject *Sender, TCanvas *ACanvas,
      int &Width, int &Height);
   void __fastcall MyDrawItem(TObject* Sender, TCanvas* ACanvas,
   const TRect &ARect, bool Selected);

public:      // User declarations
   __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif


si alguien le sirve pues esta listo...
_________________
Cool
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar email MSN Messenger
Mensaje    Asunto: Responder citando

Hola a todos,

Cesar, no consigo que me funcione este codigo.
Pregunta tonta: ¿Le falta algo?.

Hay una parte que no entiendo:
Código:

MenuItem->Items[i]->OnDrawItem = MyDrawItem;

Si MyDrawItem es una funcion, porque no se pone: MyDrawItem(); (con sus valores...)

Otra cosa, he puesto un breakpoint al comienzo de esta funcion (MyDrawItem) y nunca pasa por aqui. ???
Pasa lo mismo con: MyExpandItemWidth.

En fin, seguire mirando a haber si funciona. Un saludo y gracias.
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar email
Mensaje    Asunto: Responder citando

Bien al Final tuve que remodificar los metodos.. este esta correcto, pruebalo y checalo

DENTRO DEL .CPP
Código:

//CODIGO PARA EL MENU TIPO XP. REALIAZADO EN EL FORO, Y
// COMPUESTO POR CESAR. CUAUHTEMOC SALAZAR GONZALEZ.
#include <vcl.h>
#pragma hdrstop

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
 EstiloXPCES(this);
}
//--------------------------EstiloXPCES-----------------------------------------
//funcion para asigar los eventos de los menus
// tanto para OnDrawItem, OnMeasuerItem
//------------------------------------------------------------------------------
void __fastcall TForm1::EstiloXPCES(TForm *FormXPCES){
// variables para el estilo
// buscar los menus dentro del form
// si hay un menu, reasignamos los eventos
// a las nuevas funciones.. opcion a los demas botones...
    for (int iCC = 0; iCC < FormXPCES->ComponentCount-1; iCC++){
        if( FormXPCES->Components[iCC]->InheritsFrom(__classid(TMenuItem))){
            TMenuItem *MenuItem = dynamic_cast<TMenuItem*>(FormXPCES->Components[iCC]);
            MenuItem->OnDrawItem = DrawItemXPCES;
            MenuItem->OnMeasureItem = MeasureItemXPCES;
            if(MenuItem->Count > 0){
                for(int i=0; i <= MenuItem->Count-1; i++){
                    MenuItem->Items[i]->OnDrawItem = DrawItemXPCES;
                    MenuItem->Items[i]->OnMeasureItem = MeasureItemXPCES;
                    if(MenuItem->Items[i]->Count > 0){
                        for(int x=0; x <= MenuItem->Items[i]->Count-1; x++){
                            MenuItem->Items[i]->Items[x]->OnDrawItem = DrawItemXPCES;
                            MenuItem->Items[i]->Items[x]->OnMeasureItem = MeasureItemXPCES;
                        }
                    }
                }
            }


        }
    }
}
//-----------------------------OnDrawItemXPCES----------------------------------
void __fastcall TForm1::DrawItemXPCES(TObject* Sender, TCanvas* ACanvas,const TRect &ARect, bool Selected)
{
    AnsiString Txt;
    Graphics::TBitmap *B; // = new Graphics::TBitmap();
    TRect IConRect, TextRect;
    TColor FBackColor, FIconBackColor, FSelectedBkColor;
    TColor FFontColor, FSelectedFontColor,FDisabledFontColor, FSeparatorColor, FCheckedColor ;

    TCanvas *CanvasTmp;
    TRect RectTmp;
    TColor c1,c2;
    int Rf,Gf,Bf;
    int Rd,Gd,Bd;
    int cR, cG, cB;
    float nTonos;
    float incremento ;
    //-------------------
    int i, X1, X2;
    int TextFormat;
    bool HasImgLstBitmap;
    TMenuItem  *FMenuItem = ((TMenuItem*)Sender);
    TMenu *FMenu = FMenuItem->Parent->GetParentMenu();
    //----------------------fin de la variables-----------------------
    FIconBackColor        = (TColor) 0x00d7dcdf; // color icono barra CESAR
    FBackColor            = (TColor) 0x00F7F8F9; //color fondo CESAR
//    FSelectedBkColor      = (TColor) 0x00d2bdb6; // Color barra Seleccion CESAR
    FSelectedBkColor      = (TColor) 0x00ffcccc; // Color barra Seleccion CESAR
    FFontColor            = clBlack;   // LETRA SIN SELECCIONAR
    FSelectedFontColor    = clNavy; // letra seleccionada
    FDisabledFontColor    = clGray; //ESTADO DESHABILITADO..
    FSeparatorColor       = clGray ; //color separador
    FCheckedColor         = clGray; // DESHABILITADO CON CHECKED
//--------------------------
    ACanvas->Brush->Color = FBackColor;
    ACanvas->FillRect(ARect);

//--------------
    if (FMenu->IsRightToLeft()){
      X1 = ARect.Right-20;
      X2 = ARect.Right;
    }else{
      X1 = ARect.Left;
      X2 = ARect.Left + 20;
    }
//--------------
    // RECTANGULO DEL MENU.. ES DECIR EL TEXTO
    TextRect = ARect;
    // RECTANGULO DEL MENU.. ES DECIR EL ICONO
    IConRect = Rect(X1, ARect.Top, X2, ARect.Bottom);
//-------------- PINTA LA ZONA BLANCA DE FONDO
    Txt = " " + FMenuItem->Caption;
    B = new Graphics::TBitmap();
    B->Transparent = True;
    B->TransparentMode = tmAuto;
    HasImgLstBitmap = false;
    if ((FMenuItem->Parent->GetParentMenu()->Images != NULL) || (FMenuItem->Parent->SubMenuImages != NULL)){
        if (FMenuItem->ImageIndex != -1)
            HasImgLstBitmap = true;
        else
            HasImgLstBitmap = false;
    }
//------------------------------
    if (HasImgLstBitmap){
         if (FMenuItem->Parent->SubMenuImages != NULL)
            FMenuItem->Parent->SubMenuImages->GetBitmap(FMenuItem->ImageIndex, B);
         else
            FMenuItem->Parent->GetParentMenu()->Images->GetBitmap(FMenuItem->ImageIndex, B);

    }else{
        if (FMenuItem->Bitmap->Width > 0)
            B->Assign((Graphics::TBitmap*)FMenuItem->Bitmap);
    }
//---------------------------------
    if (FMenu->IsRightToLeft()){
        X1 = ARect.Left;
        X2 = ARect.Right-25;
    }else{
        X1 = ARect.Left+25;
        X2 = ARect.Right;
    }
//---------------------------------
    TextRect = Rect(X1, ARect.Top, X2, ARect.Bottom);
    ACanvas->Pen->Color   = FBackColor;
    ACanvas->Brush->Color = FBackColor;
    ACanvas->FillRect(TextRect);

//--------------
   TColor FSelectedBkColor2 = FBackColor;
    bool bPasa=false;
    if(FMenu->InheritsFrom(__classid(TMainMenu))){
        for(int  i=0; i< FMenuItem->GetParentMenu()->Items->Count;i++){
            if( FMenuItem->GetParentMenu()->Items[i].Parent ){
                ACanvas->Brush->Color = FBackColor;
                ACanvas->FillRect(ARect);
                if (FMenuItem->ImageIndex > -1 && FMenuItem->Bitmap->Width < 0){
                    TextRect = ARect;
                    ACanvas->FillRect(TextRect);
                    bPasa=true;
                    break;
                }
            }
        }
    }
//--------------
    if (bPasa){
        ACanvas->Brush->Color = FSelectedBkColor2;// FIconBackColor;
        ACanvas->FillRect(IConRect);
    }
//--------------  PINTA EL DEGRADADO
        ACanvas->Brush->Color = FIconBackColor; //cesar
        ACanvas->Brush->Color = FBackColor; //cesar
        RectTmp = IConRect; // para pintar el degradado
        ACanvas->FillRect(RectTmp);
        // LADO DERECHO
        c2 = static_cast<TColor>( ColorToRGB((TColor) 0x00d2bdb6) );
        c1 = static_cast<TColor>( ColorToRGB((TColor) 0x00F7F8F9) );
        Rf = GetRValue(c1);
        Gf = GetGValue(c1);
        Bf = GetBValue(c1);
        Rd = GetRValue(c2)-Rf;
        Gd = GetGValue(c2)-Gf;
        Bd = GetBValue(c2)-Bf;
        nTonos = 750;
        incremento = incremento = (float) nTonos / RectTmp.Width();
        for (int i=RectTmp.Left; i<=RectTmp.Width()-3; ++i){
            cR = Rf + MulDiv(incremento*i, Rd, nTonos);
            cG = Gf + MulDiv(incremento*i, Gd, nTonos);
            cB = Bf + MulDiv(incremento*i, Bd, nTonos);
            ACanvas->Brush->Color = (TColor) RGB(cR, cG, cB);
            ACanvas->Pen->Color   = (TColor) RGB(cR, cG, cB);
            ACanvas->MoveTo(RectTmp.left+i, RectTmp.top);
            ACanvas->LineTo(RectTmp.left+i, RectTmp.Bottom);
        }

//-------------- PINTA LA BARRA DE SELEECION
    if (FMenuItem->Enabled)
        ACanvas->Font->Color = FFontColor;
    else
        ACanvas->Font->Color = FDisabledFontColor;
//--------------
    if (Selected){
        TRect Barra = TextRect;
        Barra.Left -= 25;
        ACanvas->Brush->Style = bsSolid;
        ACanvas->Brush->Color = FSelectedBkColor;
        ACanvas->FillRect(Barra);
        ACanvas->Pen->Color   = FSelectedFontColor;
        ACanvas->Brush->Color = FSelectedBkColor;
        ACanvas->Brush->Style = bsClear;
        ACanvas->RoundRect(Barra.Left, Barra.top, Barra.Right,Barra.Bottom, 5, 5);
        if (FMenuItem->Enabled){
            ACanvas->Brush->Color = FSelectedBkColor;
            ACanvas->Brush->Style = bsSolid;
            ACanvas->Font->Color = FSelectedFontColor;
        }
    }
//-------------- PINTA LA IMAGEN DEL CHECKED
    X1 = IConRect.Left + 2;
//--------------
    if (B !=NULL)
        ACanvas->Draw(X1, IConRect.top + 2, B);
//--------------
    if (FMenuItem->Checked){
        ACanvas->Pen->Color = FCheckedColor;
        ACanvas->Brush->Style = bsClear;
        ACanvas->RoundRect(IConRect.Left, IConRect.top, IConRect.Right,IConRect.Bottom, 5, 5);
     // CUANDO ESTA SELECCIONADO O NO, UN CHECKED
        ACanvas->TextOutA(IConRect.Left+8, IConRect.top+1,"»");
     }
//--------------LINEA DE SEPARACION DE MENU
    if (!FMenuItem->IsLine()){
        SetBkMode(ACanvas->Handle, TRANSPARENT);
// ESTABLECER LA FUENTE DEL TEXTO.
        ACanvas->Font->Name = "Arial";
        //--------------
        if (FMenu->IsRightToLeft()){
            ACanvas->Font->Charset = ARABIC_CHARSET;
            TextFormat = DT_RIGHT + DT_RTLREADING;
        }else
            TextFormat = 0;
        //--------------
        if (FMenuItem->Default){
              TextRect.Left++;
              TextRect.Right++;
              TextRect.Top++;
              ACanvas->Font->Color = clGray;
              DrawTextEx(ACanvas->Handle,Txt.c_str(),Txt.Length(),&TextRect, TextFormat, NULL);
              TextRect.Left--;
              TextRect.Right--;
              TextRect.Top--;
              ACanvas->Font->Color = FFontColor;
        }
        //--------------
        DrawTextEx(ACanvas->Handle,Txt.c_str(),Txt.Length(),&TextRect, TextFormat, NULL);
        Txt = ShortCutToText(FMenuItem->ShortCut) +  " ";
        //--------------
        if (FMenu->IsRightToLeft())
            TextFormat = DT_LEFT;
        else
            TextFormat = DT_RIGHT;
        //--------------
        DrawTextEx(ACanvas->Handle,Txt.c_str(),Txt.Length(),&TextRect, TextFormat, NULL);
    }else{
        ACanvas->Pen->Color = FSeparatorColor;
        ACanvas->MoveTo(ARect.Left + 26,TextRect.Top +int((TextRect.Bottom - TextRect.Top) / 2));
        ACanvas->LineTo(ARect.Right - 2,TextRect.Top +int((TextRect.Bottom - TextRect.Top) / 2));
    }
//----------------------------------------------
    delete B;

}
//-----------------------------MeasureItemXPCES---------------------------------
void __fastcall TForm1::MeasureItemXPCES(TObject *Sender,TCanvas *ACanvas, int &Width, int &Height){
    Width+=20;
}
//-------------



Y ESTO VA DENTRO DEL .HPP

Código:

class TForm1 : public TForm
{
__published:   // IDE-managed Components
  TImageList *ImageList1;
  TPopupMenu *PopupMenu1;
  TMenuItem *Undo1;
  TMenuItem *N3;
  TMenuItem *Cut1;
  TMenuItem *Copy1;
  TMenuItem *Paste1;
    TMainMenu *MainMenu1;
    TMenuItem *Formato1;
    TMenuItem *Edit1;
    TMenuItem *Replace1;
    TMenuItem *Find1;
    TMenuItem *N2;
    TMenuItem *Paste2;
    TMenuItem *Copy2;
    TMenuItem *Cut2;
    TMenuItem *N4;
    TMenuItem *Undo2;
    TMenuItem *Help1;
    TMenuItem *About1;
    TMenuItem *HowtoUseHelp1;
    TMenuItem *SearchforHelpOn1;
    TMenuItem *Contents1;
    TMenuItem *File1;
    TMenuItem *Exit1;
    TMenuItem *N5;
    TMenuItem *PrintSetup1;
    TMenuItem *Print1;
    TMenuItem *N7;
    TMenuItem *SaveAs1;
    TMenuItem *Save1;
    TMenuItem *Open1;
    TMenuItem *New1;
    TMenuItem *Cerrar1;
    TMenuItem *N8;
    TMenuItem *fuente1;
private:   // User declarations
//-----------aqui debe ir
    void __fastcall DrawItemXPCES(TObject* Sender, TCanvas* ACanvas,const TRect &ARect, bool Selected);
    void __fastcall EstiloXPCES(TForm *FormXPCES);
    void __fastcall MeasureItemXPCES(TObject *Sender,TCanvas *ACanvas, int &Width, int &Height);

public:      // User declarations
    AnsiString FileNombre;
  __fastcall TForm1(TComponent* Owner);

};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------


Revisa bien, por que puede que se te este pasndo algo..
saludos
_________________
Cool
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar email MSN Messenger
Mensaje    Asunto: Responder citando

Gracias Cesar.

He probado este ultimo codigo, y me sigue sin funcionar Crying or Very sad

Utilizo la version 6 del Builder (por si esta informacion te sirve de algo)

Sigo detectando que no pasa por la funcion: DrawItemXPCES. He colocado un breakpoint dentro de esta funcion, para saber cuando se ejecuta y nada.

Esta bien copiado (copy y paste).

Lo unico que tengo es en un form, un MainMenu.

No se. Me estoy volviendo loco. En fin seguiremos....

Bueno Cesar un saludo y gracias.
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar email
Mensaje    Asunto: Responder citando

Enviame tu codigo, para ver que esta pasando
_________________
Cool
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar email MSN Messenger
Mensaje    Asunto: Responder citando

Estoy tratando de usar el código final que está en este hilo puesto por César, pero hay algo que o no está bien definido o no veo. Me está mostrando los menús así:

Es evidente que la presentación es incorrecta ya que las opciones principales aparecen desplazadas a la derecha y, además, la anchira de los ítemes es demasiado pequeña. ¿Cómo puedo arreglarlo?
_________________
Un saludo

Necesitamos tu ayuda: Envía AI al 27595 (Coste 1,20 euros + IVA)
Volver arriba
Ver perfil de usuario Enviar mensaje privado Enviar email
Mostrar mensajes de anteriores:   
Cambiar a:  
No puedes publicar temas nuevos en este foro
No puedes responder a temas en este foro
No puedes editar tus mensajes en este foro
No puedes borrar tus mensajes en este foro
No puedes votar en las encuestas de este foro


Hosting WordPress Indedmedia desde 3,99 €
© 2002–2026 Club Builder · Funciona con phpBB.