Page 1 of 4

Compilando una rutina de menu

PostPosted: Thu Apr 23, 2015 2:19 pm
by horacio
Colegas, estoy queriendo utilizar una rutina de menus del año 2007. Al compilarlo con harbour correspondiente a la versión FWH 14.12 obtengo varios errores. Me interesa estos menues porque son muy configurables. Pongo aquí la rutina en C que genera el error.

Code: Select all  Expand view

HARBOUR HB_FUN_DEGRADADO()
   {
           RECT rct;

           rct.top      = hb_parni( 2, 1 );
           rct.left     = hb_parni( 2, 2 );
           rct.bottom   = hb_parni( 2, 3 );
           rct.right    = hb_parni( 2, 4 );

           DegardeFill( ( HDC ) hb_parnl( 1 ) , &rct, hb_parnl( 3 ), hb_parnl( 4 ), hb_parl(5) );
   }

 


Y el error es el siguiente

Code: Select all  Expand view

Extra parameter in call to hb_parni in function HB_FUN_DEGRADADO
 


Alguna idea. Desde ya muchas gracias

Saludos

Re: Compilando una rutina de menu

PostPosted: Thu Apr 23, 2015 2:28 pm
by Carlos Mora
cambia hb_parni con más de un parámetro por hb_parvni

rct.top = hb_parvni( 2, 1 );

Re: Compilando una rutina de menu

PostPosted: Thu Apr 23, 2015 3:11 pm
by horacio
Gracias Carlos, funcionó perfectamente> Ahora tengo el siguiente error en otra de las rutinas en C. Aquí el código

Code: Select all  Expand view
#define OEMRESOURCE

#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>

BOOL bStrAt( BYTE bChar, LPSTR szText );
LPSTR StrToken( LPSTR szText, WORD wOcurrence, BYTE bSeparator, LPWORD pwLen );

void WindowBoxIn( HDC hDC, RECT * pRect );
void WndDrawBox( HDC hDC, RECT * rct, HPEN hPUpLeft, HPEN hPBotRit );
void WindowInset( HDC hDC, RECT * pRect );
void WindowRaised( HDC hDC, RECT * pRect );
void DrawBitmap( HDC, HBITMAP, WORD, WORD, WORD, WORD, DWORD );
void DrawMasked( HDC, HBITMAP, WORD, WORD );
void DrawGrayed( HDC, HBITMAP, int, int );
void RectDisable( HDC, LPRECT);
void DegardeFill( HDC hDC, RECT * rori, COLORREF cFrom, COLORREF cTo, int nDegType ) ;
void DegradColor( HDC hDC, RECT * rori, COLORREF cFrom, COLORREF cTo, int nDegType, int iRound ) ;

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

HARBOUR HB_FUN_CREATEMENU( PARAMS )
{
   _retnl( ( LONG ) CreateMenu() );
}

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

HARBOUR HB_FUN_CREATEPOPUPMENU( PARAMS )
{
   _retnl( ( LONG ) CreatePopupMenu() );
}

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

HARBOUR HB_FUN_TRACKPOPUP( PARAMS )
{
  _retl( TrackPopupMenu( ( HMENU ) _parnl( 1 ), _parni( 2 ), _parni( 4 ),
         _parni( 3 ), _parni( 5 ), ( HWND ) _parni( 6 ), NULL ) );
}

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

HARBOUR HB_FUN_ENABLEMENUITEM( PARAMS )
{
   _retl( EnableMenuItem( ( HMENU ) _parnl( 1 ), _parni( 2 ), _parni( 3 ) ) );
}

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

HARBOUR HB_FUN_CHECKMENUITEM( PARAMS )   // ()
{
   _retl( CheckMenuItem( ( HMENU ) _parnl( 1 ), _parni( 2 ), _parni( 3 ) ) );
}

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

HARBOUR HB_FUN_GETMITEMCOUNT( PARAMS )   // ()
{
   _retni( GetMenuItemCount( ( HMENU ) _parnl( 1 ) ) );
}

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

HARBOUR HB_FUN_GETMITEMID( PARAMS )    // hMenu, nPos
{
   _retni( GetMenuItemID( ( HMENU ) _parnl( 1 ), _parni( 2 ) ) );
}

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

HARBOUR HB_FUN_GETSYSTEMMENU( PARAMS )    // ()
{
   _retnl( ( LONG ) GetSystemMenu( ( HWND ) _parnl( 1 ), _parl( 2 ) ) );
}

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

HARBOUR HB_FUN_DESTROYMENU( PARAMS )   //  ()   hMenu
{
   _retl( DestroyMenu( ( HMENU ) _parnl( 1 ) ) );
}

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

HARBOUR HB_FUN_GETSUBMENU( PARAMS )    // hMenu, nPos
{
   _retnl( ( LONG ) GetSubMenu( ( HMENU ) _parnl( 1 ), _parni( 2 ) ) );
}

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

HARBOUR HB_FUN_GETMENUSTRING( PARAMS )    // ()   hMenu, nId, nPosOrValue
{
   BYTE bBuffer[ 200 ];
   WORD wLen = GetMenuString( ( HMENU ) _parnl( 1 ), _parni( 2 ), ( char * ) bBuffer,
                              199, _parni( 3 ) );

   _retclen( ( char * ) bBuffer, wLen );
}

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

HARBOUR HB_FUN_GETMENUSTATE( PARAMS )    // ()   hMenu, nId, nFlags
{
   _retni( GetMenuState( ( HMENU ) _parnl( 1 ), _parni( 2 ), _parni( 3 ) ) );
}

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

HARBOUR HB_FUN_DRAWMENUBAR( PARAMS )    // ()    hWnd
{
   DrawMenuBar( ( HWND ) _parnl( 1 ) );
}

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

HARBOUR HB_FUN_HILITEMENUITEM( PARAMS )  // ()  hWnd, hMenu, idItem, nHiliteFlags
{
   _retl( HiliteMenuItem( ( HWND ) _parnl( 1 ), ( HMENU ) _parnl( 2 ),
                          _parni( 3 ), _parni( 4 ) ) );
}

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

HARBOUR HB_FUN_LOADMENU( PARAMS )
{
   _retnl( ( LONG ) LoadMenu( ( HINSTANCE ) _parnl( 1 ),
                     ( LPSTR ) IF( ISCHAR( 2 ), _parc( 2 ),
                                   MAKEINTRESOURCE( _parni( 2 ) ) ) ) );
}

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

HARBOUR HB_FUN_APPENDMENU( PARAMS )
{
   _retl( AppendMenu( ( HMENU ) _parnl( 1 ), ( UINT ) _parnl( 2 ), _parnl( 3 ),
                       IF( ISCHAR( 4 ), _parc( 4 ), ( LPSTR ) _parnl( 4 ) ) ) );
}

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

HARBOUR HB_FUN_SETMENU( PARAMS )
{
   _retl( SetMenu( ( HWND ) _parnl( 1 ), ( HMENU ) _parnl( 2 ) ) );
}

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

HARBOUR HB_FUN_MODIFYMENU( PARAMS )
{
   _retl( ModifyMenu( ( HMENU ) _parnl( 1 ), ( UINT ) _parni( 2 ),
          _parni( 3 ), ( UINT ) _parni( 4 ),
          IF( ISCHAR( 5 ), _parc( 5 ), ( LPSTR ) _parnl( 5 ) ) ) );
}

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

HARBOUR HB_FUN_INSERTMENU( PARAMS ) // ( hMenu, nIdItem, nFlags, nNewItem, cPrompt ) --> lSuccess
{
   _retl( InsertMenu( ( HMENU ) _parnl( 1 ), _parni( 2 ), _parni( 3 ),
                      _parni( 4 ), _parc( 5 ) ) );
}

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

HARBOUR HB_FUN_REMOVEMENU( PARAMS ) // ( hMenu, nItem, nFlags ) --> lSuccess
{
   _retl( RemoveMenu( ( HMENU ) _parnl( 1 ),
                      ( UINT ) _parni( 2 ),
                      ( UINT ) _parni( 3 ) ) );
}

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

HARBOUR HB_FUN_ATMENUDRAWITEM( PARAMS ) // ( pDrawItemStruct, cPrompt, lTop, hBitmap,lSeparator,acolor,lbar )
{
   LPDRAWITEMSTRUCT lpdis = ( LPDRAWITEMSTRUCT ) _parnl( 1 );
   LPSTR szPrompt = _parc( 2 );
   BOOL bTab = bStrAt( 9, szPrompt );
   WORD wLen;
   BOOL lSeparator = _parl( 5 );
   BOOL lBar       = _parl( 7 );
   HPEN hNormal,hOldPen;
   HBRUSH hBrush;
   LOGBRUSH lb;
   RECT rct;
   RECT rctdg;
   RECT rctsep;
   RECT rctshd;
   COLORREF nClrMenu     =  _parnl(6,1);
   COLORREF nClrMenuTxt  =  _parnl(6,2);
   COLORREF nClrBack     =  _parnl(6,3);
   COLORREF nClrTo       =  _parnl(6,4);
   COLORREF nClrHighBai  =  _parnl(6,5);
   COLORREF nClrHighBaf  =  _parnl(6,6);
   COLORREF nClrHighTxt  =  _parnl(6,7);
   COLORREF nClrHighBar  =  _parnl(6,8);

   HBITMAP hBmp = ( HBITMAP ) _parnl( 4 );
   switch( lpdis->itemAction )
   {
      case ODA_DRAWENTIRE:
      case ODA_SELECT:
           lb.lbStyle = BS_SOLID;
           lb.lbColor = nClrMenu;
           hBrush = CreateBrushIndirect( &lb );
           FillRect( lpdis->hDC, &lpdis->rcItem, hBrush );
           DeleteObject( hBrush );

           SetBkColor( lpdis->hDC, nClrMenu );
           SetBkMode( lpdis->hDC, TRANSPARENT );
           SetTextColor( lpdis->hDC, nClrMenuTxt);


           if( lpdis->itemState & ODS_SELECTED &&
               ! ( lpdis->itemState & ODS_GRAYED ) && !lSeparator )
           {
              lb.lbColor = nClrHighBai;
              SetBkColor( lpdis->hDC, nClrHighBai );
              SetTextColor( lpdis->hDC, nClrHighTxt );
              if( !lBar )
                lpdis->rcItem.left += 22;
           }
           else
              lb.lbColor = nClrMenu;


           hBrush = CreateBrushIndirect( &lb );
           FillRect( lpdis->hDC, &lpdis->rcItem, hBrush );
           DeleteObject( hBrush );
           if( lpdis->itemState & ODS_SELECTED &&
              ! ( lpdis->itemState & ODS_GRAYED ) )
           {
             if( !lBar )
                 lpdis->rcItem.left -= 22;
           }

           if(!lBar)
           {
             rct.top    = lpdis->rcItem.top+1;
             rct.left   = lpdis->rcItem.left+1;
             rct.right  = lpdis->rcItem.right-1; //22;
             rct.bottom = lpdis->rcItem.bottom - 2;
           }
           else
           {
             rct.top    = lpdis->rcItem.top+1;
             rct.left   = lpdis->rcItem.left+1;
             rct.right  = lpdis->rcItem.right-4;
             rct.bottom = lpdis->rcItem.bottom - 1;

             rctshd.top    = lpdis->rcItem.top+3;
             rctshd.left   = lpdis->rcItem.right-3;
             rctshd.right  = lpdis->rcItem.right;
             rctshd.bottom = lpdis->rcItem.bottom;

           }

           rctdg.top    = lpdis->rcItem.top-1; //-4
           rctdg.left   = lpdis->rcItem.left;
           rctdg.right  = 22;
           rctdg.bottom = lpdis->rcItem.bottom+1; // - 1;

           if( !lBar )
              DegradColor( lpdis->hDC, &rctdg, nClrBack, nClrTo, 2, 1 ) ;

           if( lpdis->itemState & ODS_SELECTED )
              if( ! ( lpdis->itemState & ODS_GRAYED ) ) //&&
                {
                     hNormal = CreatePen(PS_SOLID,0,nClrHighBar);
                     hOldPen = SelectObject(lpdis->hDC,hNormal);
                     Rectangle(lpdis->hDC,rct.left-1,rct.top-1,rct.right+1,rct.bottom+1);
                     SelectObject(lpdis->hDC,hOldPen);
                     DeleteObject( hNormal );
                     DegradColor( lpdis->hDC, &rct, nClrHighBai, nClrHighBaf, 1, 1 ) ;
                     if(lBar)
                     {
                       lb.lbColor = GetSysColor(16);
                       hBrush = CreateBrushIndirect( &lb );
                       FillRect( lpdis->hDC, &rctshd, hBrush );
                       DeleteObject( hBrush );
                       rctshd.top    = lpdis->rcItem.top;
                       rctshd.left   = lpdis->rcItem.right-3;
                       rctshd.right  = lpdis->rcItem.right;
                       rctshd.bottom = lpdis->rcItem.top+3;
                       lb.lbColor = nClrMenu;
                       hBrush = CreateBrushIndirect( &lb );
                       FillRect( lpdis->hDC, &rctshd, hBrush );
                       DeleteObject( hBrush );

                     }
                }
if(!lBar)
{

           if( lpdis->itemState & ODS_CHECKED )
           {
              HBITMAP hBmp = LoadBitmap( 0, MAKEINTRESOURCE( OBM_CHECK ) );

              if( ! ( lpdis->itemState & ODS_SELECTED ) )
                 DrawMasked( lpdis->hDC, hBmp, lpdis->rcItem.top + 3,
                             lpdis->rcItem.left + 4 );
              else
                 DrawMasked( lpdis->hDC, hBmp, lpdis->rcItem.top + 3,
                             lpdis->rcItem.left + 4 );
              DeleteObject( hBmp );
           }


           if( hBmp  && !( (int) hBmp == 1 )  )
           {
              if( ! ( lpdis->itemState & ODS_CHECKED ) )
                 DrawMasked( lpdis->hDC, hBmp, lpdis->rcItem.top + 3, //ojo
                            lpdis->rcItem.left + 2 );
              else
                 if( ! ( lpdis->itemState & ODS_SELECTED ) )
                    DrawGrayed( lpdis->hDC, hBmp, lpdis->rcItem.top + 3,
                                lpdis->rcItem.left + 2 );
                 else
                    DrawMasked( lpdis->hDC, hBmp, lpdis->rcItem.top + 3,
                                lpdis->rcItem.left + 2 );
           }
}
           if(!lBar)
           {
             lpdis->rcItem.top  += 4;
             lpdis->rcItem.left += 26;
           }
           else
           {
             lpdis->rcItem.top  += 2;
             lpdis->rcItem.left += 3;
           }            
           if( !bTab )
           {
              if( lSeparator )
              {
                 rctsep.top    = lpdis->rcItem.top-1;
                 rctsep.left   = lpdis->rcItem.left;
                 rctsep.right  = lpdis->rcItem.right+5;
                 rctsep.bottom = lpdis->rcItem.bottom - 4;
                 lb.lbStyle = BS_SOLID;
                 lb.lbColor = nClrHighBar ;
                 hBrush = CreateBrushIndirect( &lb );
                 FillRect( lpdis->hDC, &rctsep, hBrush );
                 DeleteObject( hBrush );
              }
              else
              {
              if(!lBar)
                {
                   DrawText( lpdis->hDC, szPrompt, -1, &lpdis->rcItem, DT_LEFT );
                }
                else
                {
                   lpdis->rcItem.left -= 5;
                   DrawText( lpdis->hDC, szPrompt, -1, &lpdis->rcItem, DT_CENTER );
                   lpdis->rcItem.left += 5;
                }
              }
           }
           else
           {
              lpdis->rcItem.right -= 26;
              StrToken( szPrompt, 1, 9, &wLen ); // 32 bits does not fill wLen before
              DrawText( lpdis->hDC, StrToken(szPrompt, 1, 9, &wLen), wLen, &lpdis->rcItem, DT_LEFT );
              StrToken( szPrompt, 2, 9, &wLen ); // 32 bits does not fill wLen before
              DrawText( lpdis->hDC, StrToken(szPrompt, 2, 9, &wLen), wLen, &lpdis->rcItem, DT_RIGHT );
              lpdis->rcItem.right += 26;
           }
           if(!lBar)
           {
             /*
              if( !lSeparator )
                {
                if( lpdis->itemState & ODS_GRAYED )
                   RectDisable( lpdis->hDC, &lpdis->rcItem );
                }
             */

             lpdis->rcItem.top  -= 4;
             lpdis->rcItem.left -= 26;
           }
           else
           {
             lpdis->rcItem.top  -= 2;
             lpdis->rcItem.left -= 4;
           }



           _retl( TRUE );
           break;

      case ODA_FOCUS:
           _retl( FALSE );
           break;
   }
}

//----------------------------------------------------------------------------//
/*
#ifdef __HARBOUR__
   CLIPPER MENUMEASUREITEM( PARAMS ) // ( pMeasureItemStruct, nLen )
#else
   CLIPPER MENUMEASUR( PARAMS ) // EITEM( pMeasureItemStruct, nLen )
#endif
{
   LPMEASUREITEMSTRUCT lp = ( LPMEASUREITEMSTRUCT ) _parnl( 1 );
   lp->itemWidth  = _parni( 2 );
   lp->itemHeight = GetSystemMetrics( SM_CYMENU ); //18
}
*/

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

HARBOUR HB_FUN_GETMEAITEM( PARAMS ) // ( pMeasureItemStruct ) --> nMenuItemID
{
   LPMEASUREITEMSTRUCT lp = ( LPMEASUREITEMSTRUCT ) _parnl( 1 );

   _retnl( lp->itemID );
}

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

HARBOUR HB_FUN_GETDRAWITEM( PARAMS ) // ( pDrawItemStruct ) --> nMenuItemID
{
   LPDRAWITEMSTRUCT lpdis = ( LPDRAWITEMSTRUCT ) _parnl( 1 );

   _retnl( lpdis->itemID );
}

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

HARBOUR HB_FUN_GETDRAWMENU( PARAMS ) // ( pDrawItemStruct ) --> hMenu
{
   LPDRAWITEMSTRUCT lpdis = ( LPDRAWITEMSTRUCT ) _parnl( 1 );

   _retnl( ( LONG ) lpdis->hwndItem );
}

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

HARBOUR HB_FUN_ISMENU( PARAMS )
{
   _retl( IsMenu( ( HMENU ) _parnl( 1 ) ) );
}

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

HB_FUNC( _GETMENUID)
{
    _retnl((LONG)GetMenu((HWND)_parnl(1)));
}

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

HB_FUNC ( _COLORMENU )
{
   HMENU      iMenu;
   MENUINFO   iMenuInfo ;
   COLORREF lColor = _parnl(2);
   BOOL  lSubMenu = _parl(3);
   HWND  himage ;

   himage = (HWND)LoadImage(0,_parc(4),IMAGE_BITMAP ,0,0,LR_LOADFROMFILE | LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT );

   if (himage==NULL)
     {
       himage = (HWND)LoadImage(GetModuleHandle(NULL),_parc(4),IMAGE_BITMAP ,0,0, LR_LOADMAP3DCOLORS    | LR_LOADTRANSPARENT );
     }
   iMenu              = GetMenu((HWND) _parnl(1));
   GetMenuInfo(iMenu, &iMenuInfo);
   iMenuInfo.cbSize   = sizeof(MENUINFO);
   iMenuInfo.dwStyle  = GetWindowLongPtr( (HWND) _parnl(1), GWL_STYLE );

   if (lSubMenu)
    {
      iMenuInfo.fMask    = MIM_BACKGROUND | MIM_APPLYTOSUBMENUS ;
    }
   else
    {
      iMenuInfo.fMask    = MIM_BACKGROUND;
    }

   if (himage==NULL)
    {
       iMenuInfo.hbrBack = CreateSolidBrush(lColor);
    }
   else
    {
       iMenuInfo.hbrBack = CreatePatternBrush( (HBITMAP) himage);
    }

   SetMenuInfo(iMenu, &iMenuInfo);
   DrawMenuBar((HWND) _parnl(1));

}

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

HB_FUNC ( _COLORSUBMENU )
{
   HMENU      iMenu;
   MENUINFO   iMenuInfo ;
   COLORREF lColor = _parnl(2);
   iMenu              = GetMenu((HWND) _parnl(1));
   GetMenuInfo(iMenu, &iMenuInfo);
   iMenuInfo.cbSize   = sizeof(MENUINFO);
   iMenuInfo.fMask    = MIM_BACKGROUND | MIM_APPLYTOSUBMENUS;
   iMenuInfo.hbrBack  = CreateSolidBrush(lColor);
   SetMenuInfo(iMenu, &iMenuInfo);
//   DrawMenuBar((HWND) _parnl(1));
}

//----------------------------------------------------------------------------//
HB_FUNC( CHGMENUMEA ) // pMeasureItemStruct, nWidth, nHeight
{
   LPMEASUREITEMSTRUCT lp = ( LPMEASUREITEMSTRUCT ) _parnl( 1 );
   lp->itemWidth  = _parni( 2 ) ;
   lp->itemHeight = _parni( 3 ) ;
}

HB_FUNC( GETDRAWISR ) // ( pDrawitemstruct )
{
   LPDRAWITEMSTRUCT lp = ( LPDRAWITEMSTRUCT ) _parnl( 1 );

   _reta( 12 );

   _storni( lp->CtlType      ,    -1, 1  );
   _storni( lp->CtlID        ,    -1, 2  );
   _storni( lp->itemID       ,    -1, 3  );
   _storni( lp->itemAction   ,    -1, 4  );
   _storni( lp->itemState    ,    -1, 5  );
   _storni( ( LONG ) lp->hwndItem     ,    -1, 6  );
   _storni( ( LONG ) lp->hDC          ,    -1, 7  );
   _storni( lp->rcItem.top   ,    -1, 8  );
   _storni( lp->rcItem.left  ,    -1, 9  );
   _storni( lp->rcItem.bottom,    -1, 10 );
   _storni( lp->rcItem.right ,    -1, 11 );
   _stornd( lp->itemData     ,    -1, 12 );

}

HB_FUNC( GETMEAUSUR ) // ( pMeasureItemStruct )
{
   LPMEASUREITEMSTRUCT lp = ( LPMEASUREITEMSTRUCT ) _parnl( 1 );

   _reta( 6 );

   _storni( lp->CtlType      ,    -1, 1  );
   _storni( lp->CtlID        ,    -1, 2  );
   _storni( lp->itemID       ,    -1, 3  );
   _storni( lp->itemWidth    ,    -1, 4  );
   _storni( lp->itemHeight   ,    -1, 5  );
   _stornd( lp->itemData     ,    -1, 12 );

}

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

 


Y obtengo este error
Code: Select all  Expand view


HARBOUR HB_FUN_CREATEMENU( PARAMS )
{
   _retnl( ( LONG ) CreateMenu() );
}

Declaration syntax error

 


Muchas gracias

Re: Compilando una rutina de menu

PostPosted: Thu Apr 23, 2015 3:21 pm
by Carlos Mora
Probá poner
Code: Select all  Expand view
hb_retnl
en lugar de
Code: Select all  Expand view
_retnl


tambien me resulta extraña la declaracion del tipo

Code: Select all  Expand view
HARBOUR HB_FUN_CREATEMENU( PARAMS )


creo que eso podría reescribirse al estilo del nuevo harbour, como en las funciones siguientes:

Code: Select all  Expand view

HB_FUNC( CREATEMENU ) //
 

Re: Compilando una rutina de menu

PostPosted: Thu Apr 23, 2015 3:53 pm
by horacio
Carlos, No es eso, Creo que la declaración de la función está mal pero no entiendo porqué, ya que en otra rutina en C están declaradas de la misma forma y no genera error. Alguna otra idea ???

Gracias

Re: Compilando una rutina de menu

PostPosted: Thu Apr 23, 2015 11:05 pm
by Pablo César
Horacio, cuando termines, puedes postear la imagen de pantalla para ver como queda ?

Re: Compilando una rutina de menu

PostPosted: Fri Apr 24, 2015 1:47 pm
by horacio
Pablo, este es un ejemplo compilado con xHarbour 0.99.60 y FWH 2.7

Image

Esperemos poder hacerlo operativo para las nuevas versiones de FWH.
Saludos

Re: Compilando una rutina de menu

PostPosted: Fri Apr 24, 2015 4:39 pm
by joseluisysturiz
horacio wrote:Pablo, este es un ejemplo compilado con xHarbour 0.99.60 y FWH 2.7

Image

Esperemos poder hacerlo operativo para las nuevas versiones de FWH.
Saludos

Horacio, podrias dar una pequeña idea de lo que hace y si podrias postear el codigo? estoy creando un menu configurable desde tabla para personalizar por nivel de usuario, es algo como esto que haces.? gracias...saludos... :shock:

Re: Compilando una rutina de menu

PostPosted: Fri Apr 24, 2015 5:07 pm
by horacio
Jose Luis, Este menú es muy configurable en cuanto a los colores. No recuerdo donde lo obtuve. Estoy liado con el código, sobre todo las rutinas en C que no logro compilarlas. Dame un correo donde pueda enviarte los fuentes.

Saludos

Re: Compilando una rutina de menu

PostPosted: Fri Apr 24, 2015 5:38 pm
by joseluisysturiz
horacio wrote:Jose Luis, Este menú es muy configurable en cuanto a los colores. No recuerdo donde lo obtuve. Estoy liado con el código, sobre todo las rutinas en C que no logro compilarlas. Dame un correo donde pueda enviarte los fuentes.

Saludos

joseluisysturiz@yahoo.com gracias, saludos... :shock:

Re: Compilando una rutina de menu

PostPosted: Fri Apr 24, 2015 6:52 pm
by cnavarro
Horacio, puedes poner un pequeño .prg de como se usa?

Re: Compilando una rutina de menu

PostPosted: Fri Apr 24, 2015 7:22 pm
by horacio
Aqui un ejemplo

Code: Select all  Expand view
#include "FiveWin.ch"
#include "Splitter.ch"
#INCLUDE "MENU.CH"

static oWnd, oTree
static oMru1, oMru2, oMru3
Static cColorPan
//----------------------------------------------------------------------------//

function Main()

   local oBar, oItem1, oItem2, oImageList, oSplit
   local oMenuNew, oSay
   Local cClrDegrIni,cClrDegrFin
   Local cClrSelIni,cClrSelFin,cClrSelTxt,cClrSelBor
   Local cClrMenu,cClrMenuTxt

      cClrDegrFin := LightColor(60,getsysColor(2))
      cClrDegrIni:= LightColor(230,cClrDegrFin)
      cColorPan  := LightColor(150,cClrDegrFin)
      cClrMenu:= CLR_WHITE
      cClrMenuTxt:= CLR_BLACK
      cClrSelFin:= RGB(128,128,192)
      cClrSelIni:= RGB(128,128,192)
      cClrSelTxt:= CLR_BLACK
      cClrSelBor:= CLR_BLACK
      cClrDegrFin := LightColor(60,RGB(160,160,80))
      cClrDegrIni:= LightColor(230,cClrDegrFin)
     

   DEFINE WINDOW oWnd FROM 3, 6 TO 20, 70 MDI ;
      TITLE " Ejemplo de Menus" ;
      MENU BuildMenu()

   DEFINE BUTTONBAR oBar SIZE 24, 27 OF oWnd _3D

   MENU oMenuNew POPUP ;
        COLORMENU    cClrMenu,cClrMenuTxt ;
        COLORBMP     cClrDegrFin,cClrDegrIni;  
        COLORSELECT  cClrSelIni,cClrSelFin,cClrSelTxt ;
        COLORSEPARATOR cClrSelBor

      MENUITEM "New &Dialog" RESOURCE "Dialog"
      MENUITEM "New &Bitmap"
      MENUITEM "New &Bitmap"
      MENUITEM "New &Bitmap"
      SEPARATOR
      MENUITEM "New &Icon"   RESOURCE "Icon"
   ENDMENU

   DEFINE BUTTON OF oBar  ;
      TOOLTIP "New" NOBORDER RESOURCE "New" MENU oMenuNew

   DEFINE BUTTON OF oBar  ;
      TOOLTIP "Open" NOBORDER RESOURCE "Open"

   DEFINE BUTTON OF oBar  ;
      TOOLTIP "Save" NOBORDER RESOURCE "Save"

   DEFINE BUTTON OF oBar GROUP ;
      TOOLTIP "Exit" NOBORDER RESOURCE "Exit" ACTION oWnd:End()


   SET MESSAGE OF oWnd TO "Ready" NOINSET CLOCK DATE KEYBOARD

   ACTIVATE WINDOW oWnd ;
      ON INIT ( _colorMenu(ownd:hwnd,cColorPan,.t.) );
      VALID MsgYesNo( "Want to end ?" )

return nil

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

function BuildMenu()

   local oMenu
Local cClrDegrIni,cClrDegrFin
Local cClrSelIni,cClrSelFin,cClrSelTxt,cClrSelBor
Local cClrMenu,cClrMenuTxt
Local cPrompt := "                              "

      cClrDegrFin := LightColor(60,getsysColor(2))
      cClrDegrIni:= LightColor(230,cClrDegrFin)
      cColorPan  := LightColor(150,cClrDegrFin)
      cClrMenu:= GetSysColor(2) //RGB(224,255,255)
      cClrMenuTxt:= CLR_BLACK
      cClrSelFin:= RGB(255,238,194)
      cClrSelIni:= RGB(255,238,194)
      cClrSelTxt:= CLR_BLACK
      cClrSelBor:= CLR_BLACK

   MENU oMenu MENUBAR;
        COLORMENU    cColorPan,cClrMenuTxt ;
        COLORBMP     cClrDegrFin,cClrDegrIni;
        COLORSELECT  cClrDegrIni,cClrDegrFin,cClrSelTxt;
        COLORSEPARATOR cClrDegrFin

      MENUITEM "&Archivos" RESOURCE "new"

      MENU ;
        COLORMENU    cClrMenu,cClrMenuTxt;
        COLORBMP     cClrDegrFin,cClrDegrIni;
        COLORSELECT  cClrSelIni,cClrSelFin,cClrSelTxt;
        COLORSEPARATOR cClrSelBor

         MENUITEM "&Nuevo item Mru"  RESOURCE "new" ;
            ACTION ( MsgGet( "Write something", "Whatever...", @cPrompt ),;
                     oMru1:Save( cPrompt ) )

         MENUITEM "&Open" RESOURCE "Open" ;
            ACTION ( _colorSUbMenu(ownd:hwnd,getsysColor(2)) )

         MENUITEM "&New"  RESOURCE "new" ;
            ACTION ( _colorMenu(ownd:hwnd,RGB(163,194,245),.f.) )

         MENUITEM "&Child"  RESOURCE "new" ;
            ACTION ( child1() )

         MENUITEM "&New"  RESOURCE "new itemmm" DISABLED;


         MRU oMru1 ;
            FILENAME ".\TestMru.ini" ;     // .INI to manipulate. '\.' for local
            SECTION  "MRU-Customer" ;      // The name of the INI section
            ACTION   MsgInfo( cMruItem ) ; // cMruItem is automatically provided
            MESSAGE  "Show this item..." ; // The message for all of them
            SIZE     10                    
 
         SEPARATOR

         MENUITEM "&Limpiar la Lista MRU" ACTION oMru1:Clear()

         MENUITEM "&Salve como..." RESOURCE "save"

            cClrDegrFin := RGB(0,128,64) //LightColor(60,getsysColor(2))
            cClrDegrIni:= LightColor(230,cClrDegrFin)
            cClrMenu:= RGB(147,220,171)
            cClrMenuTxt:= CLR_BLACK
            cClrSelIni:= RGB(149,202,255)
            cClrSelFin:= RGB(149,202,255)
            cClrSelTxt:= CLR_BLACK
            cClrSelBor:= CLR_BLACK

            MENU ;
              COLORMENU    cClrMenu,cClrMenuTxt;
              COLORBMP     cClrDegrFin,cClrDegrIni;
              COLORSELECT  cClrSelIni,cClrSelFin,cClrSelTxt;
              COLORSEPARATOR cClrSelBor

               MENUITEM "&Nuevo item"  RESOURCE "new" ;
                   ACTION ( _colorMenu(ownd:hwnd,RGB(163,194,245),.f.) ) //WHEN .F.
               MENUITEM "&Open" RESOURCE "Open" ;
                   ACTION ( _colorSUbMenu(ownd:hwnd,getsysColor(2)) )

               MENUITEM "&New hdgjh sdagjhgsda"  RESOURCE "new"
               SEPARATOR
               MENUITEM "&Nuevo proceso"  
               MENUITEM "&Abri"    
               MENUITEM "&Nuevo" CHECK
               MENUITEM "&Open"    
               SEPARATOR
               MENUITEM "&Salve como..." RESOURCE "save"
            ENDMENU
         SEPARATOR
         MENUITEM "&Salir..." ACTION oWnd:End() RESOURCE "Exit"
      ENDMENU

      MENUITEM "&Editar"

      cClrDegrFin := RGB(96,149,174)
      cClrDegrIni := LightColor(230,cClrDegrFin)
      cClrMenu    := RGB(147,220,171)
      cClrMenuTxt := CLR_BLACK
      cClrSelIni  := RGB(255,238,194)
      cClrSelFin  := RGB(255,238,294)
      cClrSelTxt  := CLR_BLACK
      cClrSelBor  := CLR_BLACK

      MENU ;
            COLORMENU    cClrMenu,cClrMenuTxt;
            COLORBMP     cClrDegrFin,cClrDegrIni;
            COLORSELECT  cClrSelIni,cClrSelFin,cClrSelTxt;
            COLORSEPARATOR cClrSelBor
         MENUITEM "&Nuevo"  CHECK
         MENUITEM "&Open"    
         MENUITEM "&1" RESOURCE "save"  DISABLED
         MENUITEM "&2"    WHEN .F.
         MENUITEM "&3"    
         MENUITEM "&4"    
         MENUITEM "&5"    
         SEPARATOR
         MENUITEM "&Salve como..." RESOURCE "save"
      ENDMENU

      MENUITEM "&Modifcar"

      cClrDegrFin := RGB(96,149,174)
      cClrDegrIni := RGB(96,149,174)
      cClrMenu    := CLR_YELLOW
      cClrMenuTxt := CLR_BLACK
      cClrSelIni  := RGB(255,238,194)
      cClrSelFin  := RGB(255,238,294)
      cClrSelTxt  := CLR_BLACK
      cClrSelBor  := CLR_BLACK

      MENU  ;
              COLORMENU    cClrMenu,cClrMenuTxt;
              COLORBMP     cClrDegrFin,cClrDegrIni;
              COLORSELECT  cClrSelIni,cClrSelFin,cClrSelTxt;
              COLORSEPARATOR cClrSelBor
         MENUITEM "&Nuevo proceso"  
         MENUITEM "&Abri"    
         MENUITEM "&Nuevo" CHECK
         MENUITEM "&Open"    
         SEPARATOR
         MENUITEM "&Nuevo proceso"  
         MENUITEM "&Abri"    
         MENUITEM "&Nuevo" CHECK
         MENUITEM "&Open"    
         SEPARATOR
         MENUITEM "&Salve como..." RESOURCE "save"
      ENDMENU

      oMenu:AddHelp( "FiveWin Resources Editor", "FiveTech 1993-2000" )
   ENDMENU

return oMenu

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


function Child1()

   local oWndChild, oDlg, oBtn
   local cName := "Testing..."
   Local cAlias := "A"+ALLTRIM(cTempFile())
   LOCAl oBar


   DEFINE  WINDOW oWndChild MDI; // OF oWnd ;
      MENU BuildMenu() ;

   DEFINE  BUTTONBAR oBar OF oWndChild SIZE 24,26 3D

   DEFINE  BUTTON OF oBar TOOLTIP "Salir";
           MESSAGE "Ventana de MDI" ACTION oWndChild:End()

  // oWndChild:bKeyDown := {|nkey,nFlag| IIF(nKey == 27, oWndChild:End(), .T.)}

   ACTIVATE WINDOW oWndChild ;
      ON INIT ( _colorMenu(owndChild:hwnd,cColorPan,.t.) );
      valiD(msgyesno("¨Salimos?"))


return nil
 


Saludos

Re: Compilando una rutina de menu

PostPosted: Fri Apr 24, 2015 7:36 pm
by horacio
Jose Luis, me olvide de adjuntar el .ch. Aqui lo posteo

Code: Select all  Expand view
#ifndef _MENU_CH
#define _MENU_CH

//----------------------------------------------------------------------------//
// Creating PullDown Menus from source code

#xcommand MENU [ <oObjMenu> ] ;
             [ <popup: POPUP> ] ;
             [ COLORMENU  <nClrMenu> ,<nClrMenutxt> ] ;
             [ COLORBMP  <nClrBkBa> ,<nClrToBa> ] ;
             [ COLORSELECT  <nClrHiLi> ,<nClrHiLf> ,<nClrHitx> ] ;
             [ COLORSEPARATOR  <nClrHiBr> ] ;
             [ <lMenuBar: MENUBAR> ] ;
       => ;
          [ <oObjMenu> := ] MenuBegin( <.popup.>,,,<nClrMenu>, <nClrMenutxt>, <nClrBkBa>, <nClrToBa>,<nClrHiLi> ,<nClrHiLf> ,<nClrHitx>,<nClrHiBr>,<.lMenuBar.> )

#xcommand MENUITEM [ <oMenuItem> PROMPT ] [<cPrompt>] ;
             [ MESSAGE <cMsg> ] ;
             [ <checked: CHECK, CHECKED, MARK> ] ;
             [ <enable: ENABLED, DISABLED> ] ;
             [ <file: FILE, FILENAME, DISK> <cBmpFile> ] ;
             [ <resource: RESOURCE, RESNAME, NAME> <cResName> ] ;
             [ ACTION <uAction,...> ] ;
             [ BLOCK <bAction> ] ;
             [ <of: OF, MENU, SYSMENU> <oMenu> ] ;
             [ ACCELERATOR <nState>, <nVirtKey> ] ;
             [ <help: HELP> ] ;
             [ <HelpId: HELP ID, HELPID> <nHelpId> ] ;
             [ WHEN <uWhen> ] ;
             [ <Degrade: DEGRADE> ] ;
             [ <break: BREAK> ] ;
       => ;
          [ <oMenuItem> := ] MenuAddItem( <cPrompt>, <cMsg>,;
             <.checked.>, [ Upper(<(enable)>) == "ENABLED" ],;
             [\{|oMenuItem|<uAction>\}],;
             <cBmpFile>, <cResName>, <oMenu>, <bAction>, <nState>, <nVirtKey>,;
             <.help.>, <nHelpId>, [<{uWhen}>], <.break.> , <.Degrade.>,.f. )

#xcommand MRU <oMru> ;
             [ <Ini: INI, ININAME, FILENAME, NAME, DISK> <cIniFile> ] ;
             [ SECTION <cSection> ] ;
             [ <size: SIZE, ITEMS> <nItems> ] ;
             [ MESSAGE <cMsg> ] ;
             [ ACTION <uAction> ] ;
       => ;
          <oMru> := TMru():New( <cIniFile>, <cSection>, <nItems>, <cMsg>,;
             [{|cMruItem,oMenuItem|<uAction>}] )

#xcommand SEPARATOR [<oMenuItem>] => [<oMenuItem>:=] MenuAddItem(,,,,,,,,,,,,,,,,.t.)

#xcommand ENDMENU => MenuEnd()

//----------------------------------------------------------------------------//
// Creating PullDown Menus from resources

#xcommand DEFINE MENU <oMenu> ;
             [ <res: RESOURCE, NAME, RESNAME> <cResName> ] ;
             [ <popup: POPUP> ] ;
       => ;
          <oMenu> := TMenu():ReDefine( <cResName>, <.popup.> )

#xcommand REDEFINE MENUITEM [ <oMenuItem> PROMPT ] [<cPrompt>] ;
             [ ID <nId> <of: OF, MENU> <oMenu> ] ;
             [ ACTION <uAction> ] ;
             [ BLOCK  <bAction> ] ;
             [ MESSAGE <cMsg> ] ;
             [ <checked: CHECK, CHECKED, MARK> ] ;
             [ <enable: ENABLED, DISABLED> ] ;
             [ <file: FILE, FILENAME, DISK> <cBmpFile> ] ;
             [ <resource: RESOURCE, RESNAME, NAME> <cResName> ] ;
             [ ACCELERATOR <nState>, <nVirtKey> ] ;
             [ <HelpId: HELP ID, HELPID> <nHelpId> ] ;
             [ WHEN <uWhen> ] ;
       => ;
          [ <oMenuItem> := ] TMenuItem():ReDefine( <cPrompt>, <cMsg>,;
             <.checked.>, [ Upper(<(enable)>) == "ENABLED" ], <{uAction}>,;
             <cBmpFile>, <cResName>, <oMenu>, <bAction>, <nId>,;
             <nState>, <nVirtKey>, <nHelpId>, [<{uWhen}>] )

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

#xcommand DEFINE MENU <oMenu> OF <oWnd> ;
       => ;
          <oMenu> := TMenu():New( .f., <oWnd> )

#xcommand SET MENU OF <oWnd> TO <oMenu> => <oWnd>:SetMenu( <oMenu> )

//----------------------------------------------------------------------------//
// PopUps Management

#xcommand ACTIVATE <menu:POPUP,MENU> <oMenu> ;
             [ AT <nRow>, <nCol> ] ;
             [ <of: OF, WINDOW, DIALOG> <oWnd> ] ;
       => ;
          <oMenu>:Activate( <nRow>, <nCol>, <oWnd> )

//----------------------------------------------------------------------------//
// Using Window System Menu

#xcommand REDEFINE SYSMENU [<oMenu>] ;
             [ <of: OF, WINDOW, DIALOG> <oWnd> ] ;
       => ;
          [<oMenu> :=] MenuBegin( .f., .t., <oWnd> )

#xcommand ENDSYSMENU => MenuEnd()

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

#endif
 


Avisame si te llego el mail que te mande.
Saludos

Compilando una rutina de menu

PostPosted: Fri Apr 24, 2015 7:47 pm
by Pablo César
Muy bueno Horacio. Felicitaciones y muchas gracias por compartir.

Re: Compilando una rutina de menu

PostPosted: Fri Apr 24, 2015 7:52 pm
by horacio
Aclaro que esto no es un desarrollo mio, como dije lo baje de algun lado que no recuerdo y no encuentro por ningun lado los creditos. Me gustaria poder echarlo a andar.

Saludos