Page 1 of 2

Problema menu con MenuBegin()

PostPosted: Mon Nov 05, 2018 1:03 pm
by Compuin
Saludos

Por alguna razon este menu no funciona aun cuando la sintaxis aparenta estar Ok

Code: Select all  Expand view
#include "FiveWin.ch"

static oWnd

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

function Main()

   local oWndEdit, oBar, oIcon, oImage
   local cName := "Ejemplo de Menu"

   DEFINE WINDOW oWnd FROM 1, 1 TO 20, 70 TITLE "Ventana Principla" ;
      MDI ;
      MENU BuildMenu() ;
      ICON oIcon

   SET MESSAGE OF oWnd TO "Main Window"

   ACTIVATE WINDOW oWnd MAXIMIZED ;
      VALID MsgYesNo( "Salir ?" )

return nil

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

function BuildMenu()

   local oMenu

   oMenu := MenuBegin( .F.,,, .F., .F. )

      MenuAddItem( "&Information",, .F.,,,,,,,,, .F.,,, .F. )
      MenuBegin( .F.,,, .F., .F. )
         MenuAddItem( "&About...",, .F.,, {|oMenuItem|MsgAbout( "FiveWin", "FiveTech" )},,,,,,, .F.,,, .F. )
         MenuAddItem()
         MenuAddItem( "&End...",, .F.,, {|oMenuItem|oWnd:End()},,,,,,, .F.,,, .F. )
      MenuEnd()

      MenuAddItem( "&Child Windows",, .F.,,,,,,,,, .F.,,, .F. )
      MenuBegin( .F.,,, .F., .F. )
         MenuAddItem( "&Tiled",, .F.,, {|oMenuItem|oWnd:Tile()},,,,,,, .F.,,, .F. )
         MenuAddItem( "&Cascade",, .F.,, {|oMenuItem|oWnd:Cascade()},,,,,,, .F.,,, .F. )
      MenuEnd()
   MenuEnd()

return oMenu


Agradezco recomendaciones

Re: Problema menu con MenuBegin()

PostPosted: Mon Nov 05, 2018 1:41 pm
by karinha
Code: Select all  Expand view

#include "FiveWin.ch"

static oWnd

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

function Main()

   local oWndEdit, oBar, oIcon, oImage
   local cName := "Ejemplo de Menu"

   DEFINE WINDOW oWnd FROM 1, 1 TO 20, 70 TITLE "Ventana Principla" ;
      MDI ;
      MENU BuildMenu() ;
      ICON oIcon

   SET MESSAGE OF oWnd TO "Main Window"

   ACTIVATE WINDOW oWnd MAXIMIZED ;
      VALID MsgYesNo( "Salir ?" )

return nil

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

function BuildMenu()

   local oMenu

   /*
   oMenu := MenuBegin( .F.,,, .F., .F. )

      MenuAddItem( "&Information",, .F.,,,,,,,,, .F.,,, .F. )
      MenuBegin( .F.,,, .F., .F. )
         MenuAddItem( "&About...",, .F.,, {|oMenuItem|MsgAbout( "FiveWin", "FiveTech" )},,,,,,, .F.,,, .F. )
         MenuAddItem()
         MenuAddItem( "&End...",, .F.,, {|oMenuItem|oWnd:End()},,,,,,, .F.,,, .F. )
      MenuEnd()

      MenuAddItem( "&Child Windows",, .F.,,,,,,,,, .F.,,, .F. )
      MenuBegin( .F.,,, .F., .F. )
         MenuAddItem( "&Tiled",, .F.,, {|oMenuItem|oWnd:Tile()},,,,,,, .F.,,, .F. )
         MenuAddItem( "&Cascade",, .F.,, {|oMenuItem|oWnd:Cascade()},,,,,,, .F.,,, .F. )
      MenuEnd()
   MenuEnd()
   */


   MENU oMenu 2007

      MENUITEM "&Information"

      MENU
         MENUITEM   "&About..." ;
            ACTION  MsgInfo( "FiveWin Tutorial" + Chr( 13 ) + FWCOPYRIGHT ) ;
            MESSAGE "Information about this application"

         SEPARATOR

         MENUITEM   "&End..."  ;
            ACTION  If( MsgYesNo( "Want to end ?" ), oWnd:End(),) ;
            MESSAGE "End this application"
      ENDMENU

      MENUITEM "&Files"

      MENU
         MENUITEM   "&Customers..." ;
            ACTION  msginfo("just a test") ;
            MESSAGE "Customers maintainance"

         MENUITEM   "&Stock" ;
            ACTION  MsgInfo( "Any option from here" ) ;
            MESSAGE "Stock maintainance"
      ENDMENU

      MENUITEM "&Utils"

      MENU
         MENUITEM   "&Calculator..." ;
            ACTION  WinExec( "Calc" ) ;
            MESSAGE "Run Windows calculator"

         MENUITEM   "C&alendar..." ;
            ACTION  WinExec( "Calendar" ) ;
            MESSAGE "Run Windows calendar"

         MENUITEM   "&Some fun..." ;
            ACTION  WinExec( "Sol" ) ;
            MESSAGE "Play a game..."
      ENDMENU

   ENDMENU

return oMenu
 



Saludos.

Re: Problema menu con MenuBegin()

PostPosted: Mon Nov 05, 2018 1:44 pm
by Compuin
karinha wrote:
Code: Select all  Expand view

#include "FiveWin.ch"

static oWnd

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

function Main()

   local oWndEdit, oBar, oIcon, oImage
   local cName := "Ejemplo de Menu"

   DEFINE WINDOW oWnd FROM 1, 1 TO 20, 70 TITLE "Ventana Principla" ;
      MDI ;
      MENU BuildMenu() ;
      ICON oIcon

   SET MESSAGE OF oWnd TO "Main Window"

   ACTIVATE WINDOW oWnd MAXIMIZED ;
      VALID MsgYesNo( "Salir ?" )

return nil

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

function BuildMenu()

   local oMenu

   /*
   oMenu := MenuBegin( .F.,,, .F., .F. )

      MenuAddItem( "&Information",, .F.,,,,,,,,, .F.,,, .F. )
      MenuBegin( .F.,,, .F., .F. )
         MenuAddItem( "&About...",, .F.,, {|oMenuItem|MsgAbout( "FiveWin", "FiveTech" )},,,,,,, .F.,,, .F. )
         MenuAddItem()
         MenuAddItem( "&End...",, .F.,, {|oMenuItem|oWnd:End()},,,,,,, .F.,,, .F. )
      MenuEnd()

      MenuAddItem( "&Child Windows",, .F.,,,,,,,,, .F.,,, .F. )
      MenuBegin( .F.,,, .F., .F. )
         MenuAddItem( "&Tiled",, .F.,, {|oMenuItem|oWnd:Tile()},,,,,,, .F.,,, .F. )
         MenuAddItem( "&Cascade",, .F.,, {|oMenuItem|oWnd:Cascade()},,,,,,, .F.,,, .F. )
      MenuEnd()
   MenuEnd()
   */


   MENU oMenu 2007

      MENUITEM "&Information"

      MENU
         MENUITEM   "&About..." ;
            ACTION  MsgInfo( "FiveWin Tutorial" + Chr( 13 ) + FWCOPYRIGHT ) ;
            MESSAGE "Information about this application"

         SEPARATOR

         MENUITEM   "&End..."  ;
            ACTION  If( MsgYesNo( "Want to end ?" ), oWnd:End(),) ;
            MESSAGE "End this application"
      ENDMENU

      MENUITEM "&Files"

      MENU
         MENUITEM   "&Customers..." ;
            ACTION  msginfo("just a test") ;
            MESSAGE "Customers maintainance"

         MENUITEM   "&Stock" ;
            ACTION  MsgInfo( "Any option from here" ) ;
            MESSAGE "Stock maintainance"
      ENDMENU

      MENUITEM "&Utils"

      MENU
         MENUITEM   "&Calculator..." ;
            ACTION  WinExec( "Calc" ) ;
            MESSAGE "Run Windows calculator"

         MENUITEM   "C&alendar..." ;
            ACTION  WinExec( "Calendar" ) ;
            MESSAGE "Run Windows calendar"

         MENUITEM   "&Some fun..." ;
            ACTION  WinExec( "Sol" ) ;
            MESSAGE "Play a game..."
      ENDMENU

   ENDMENU

return oMenu
 



Saludos.


Karinha

Gracias

No es posible hacerlo de la forma que pedi?

Re: Problema menu con MenuBegin()

PostPosted: Mon Nov 05, 2018 2:05 pm
by karinha
Asta donde yo sepa, és posible en una listbox ó en un dialogo. No en una Window.

Pero...

Code: Select all  Expand view

    //-> ListBox
    REDEFINE LISTBOX oLbx FIELDS                                    ;
             (DbClientes:cAlias)->RAZ_MATRIC                      , ;
             (DbClientes:cAlias)->DEST_NOME                       , ;
             (DbClientes:cAlias)->END                             , ;
             (DbClientes:cAlias)->BAI                             , ;
             (DbClientes:cAlias)->CID                             , ;
             (DbClientes:cAlias)->CEP                             , ;
             (DbClientes:cAlias)->TEL                             , ;
             (DbClientes:cAlias)->TEL2                            , ;
             (DbClientes:cAlias)->TEL3                              ;
             HEADERS ( OemToAnsi( "C¢digo/Cnpj/Cpf" ) )           , ;
                     ( OemToAnsi( "Nome/RazÆo Social=> "          + ;
                     "<Click> Mouse Direito<Menu>" ) )            , ;
                     ( OemToAnsi( "Endere‡o"        ) )           , ;
                     ( OemToAnsi( "Bairro"          ) )           , ;
                     ( OemToAnsi( "Cidade"          ) )           , ;
                     ( OemToAnsi( "Cep"             ) )           , ;
                     ( OemToAnsi( "Telefone"        ) )           , ;
                     ( OemToAnsi( "Telefone"        ) )           , ;
                     ( OemToAnsi( "Telefone"        ) )             ;
             FIELDSIZES 130, 480, 480, 200, 200, 100, 150, 150, 150 ;
             COLOR CLR_BROWN, CLR_LGREEN                            ;
             FONT oFont                                             ;
             CURSOR oHand                                           ;
             UPDATE                                                 ;
             ID 101                                                 ;
             OF oDlg                                                ;
             ON DBLCLICK( Click()                                 , ;
                          GETCLIENTES( .F., DbClientes, DbCabec,    ;
                                            DbPaieMae, DeOndeVem ), ;
             oLbx:SetFocus(), oLbx:Refresh(), oLbx:DrawSelect() )



    // Esta em Contabil.Prg \samples\account
    oLbx:bRClicked := { | nRow, nCol, nFlags |                            ;
         ( oMenu := MenuBegin( .T. )                                    , ;
           MenuAddItem( ( OemToAnsi( "Incluir Cliente" ) ),, .F.,       , ;
               { | oMenuItem | ( Click(), GetClientes( .T., DbClientes,   ;
                                            DbCabec,    ;
                                            DbPaieMae, DeOndeVem ), ;
                   oLbx:Refresh(), oLbx:SetFocus() ) },                 , ;
                   "COMPUTADOR",,,,, .F.,,, .F. )                       , ;
           MenuAddItem()                                                , ;
           MenuAddItem( ( OemToAnsi( "Excluir Cliente" ) ),, .F.,       , ;
               { | oMenuItem | ( Click(), ApagarCli( DbClientes, DbCabec, ;
                                                     DbPaieMae, DeOndeVem ), ;
                   oLbx:GoUp(), oLbx:Refresh(), oLbx:SetFocus() ) },    , ;
                   "B_FAC",,,,, .F.,,, .F. )                            , ;
           MenuAddItem()                                                , ;
           MenuAddItem( ( OemToAnsi( "Alterar Cliente" ) ),, .F.,       , ;
               { | oMenuItem | ( Click(), GetClientes( .F., DbClientes,   ;
                                            DbCabec,    ;
                                            DbPaieMae, DeOndeVem ), ;
                   oLbx:Refresh(), oLbx:SetFocus() ) },                 , ;
                   "WORD16",,,,, .F.,,, .F. )                           , ;
           MenuAddItem()                                                , ;
           MenuAddItem( ( OemToAnsi( " Buscar Por Matr¡cula" ) ),, .F., , ;
               { | oMenuItem | ( Click(), FiltrarM( DbClientes, oLbx    , ;
                                                    nOpcaoRadio )       , ;
                   oLbx:Refresh(), oLbx:SetFocus() ) },                 , ;
                   "B_ECT",,,,, .F.,,, .F. )                            , ;
           MenuAddItem()                                                , ;
           MenuAddItem( ( OemToAnsi( "Buscar Por Nome" ) ),, .F.,       , ;
               { | oMenuItem | ( Click(), FiltrarN( DbClientes, oLbx    , ;
                                                    nOpcaoRadio)        , ;
                   oLbx:Refresh(), oLbx:SetFocus() ) },                 , ;
                   "B_SOB",,,,, .F.,,, .F. )                            , ;
           MenuAddItem()                                                , ;
           MenuAddItem( ( OemToAnsi( "Buscar Por Apelido" ) ),, .F.,    , ;
               { | oMenuItem | ( Click(), FilArtis( DbClientes, oLbx    , ;
                                                    nOpcaoRadio )       , ;
                   oLbx:Refresh(), oLbx:SetFocus() ) },                 , ;
                   "B_COR",,,,, .F.,,, .F. )                            , ;
           MenuAddItem()                                                , ;
           MenuAddItem( ( OemToAnsi( "Buscar Por Cic_Cpf" ) ),, .F.,    , ;
               { | oMenuItem | ( Click(), FilCpf( DbClientes, oLbx )    , ;
                   oLbx:Refresh(), oLbx:SetFocus() ) },                 , ;
                   "B_NOM",,,,, .F.,,, .F. )                            , ;
           MenuAddItem()                                                , ;
           MenuAddItem( ( OemToAnsi( "Imprimir Clientes" ) ),, .F.,     , ;
               { | oMenuItem | ( Click(), Imprimir( lAppend, DbClientes,  ;
                                            DbCabec,    ;
                                            DbPaieMae, DeOndeVem )    , ;
                   oLbx:Refresh(), oLbx:SetFocus() ) },                 , ;
                   "BTNIMPUSO",,,,, .F.,,, .F. )                        , ;
           MenuAddItem()                                                , ;
           MenuAddItem( "Saida",, .F.,,{ | oMenuItem |                    ;
               ( Click(), oLbx:oWnd:End() ) },,                           ;
               "SAIDA16X16",,,,, .F.,,, .F. )                           , ;
           MenuEnd()                                                    , ;
    oMenu:Activate( nRow, nCol, oDlg ) ) }
 


Saludos.

Re: Problema menu con MenuBegin()

PostPosted: Mon Nov 05, 2018 2:22 pm
by cnavarro
Asi

Code: Select all  Expand view


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

function BuildMenu()

   local oMenu

   oMenu := ; //MenuBegin( .F.,,, .F., .F. )
   MenuBegin( .F., , , .F., .F., , ;
              , , , , , , , , , , .F., .F., .F., .F. )

      MenuAddItem( "&Information",, .F.,,,,,,,,, .F.,,, .F. )
      //MenuBegin( .F.,,, .F., .F. )
      MenuBegin( .F., , , .F., .F., , ;
              , , , , , , , , , , .F., .F., .F., .F. )
         MenuAddItem( "&About...",, .F.,, {|oMenuItem|MsgAbout( "FiveWin", "FiveTech" )},,,,,,, .F.,,, .F. )
         MenuAddItem()
         MenuAddItem( "&End...",, .F.,, {|oMenuItem|oWnd:End()},,,,,,, .F.,,, .F. )
      MenuEnd()

      MenuAddItem( "&Child Windows",, .F.,,,,,,,,, .F.,,, .F. )
      //MenuBegin( .F.,,, .F., .F. )
      MenuBegin( .F., , , .F., .F., , ;
              , , , , , , , , , ,.F. , .F., .F., .F. )
         MenuAddItem( "&Tiled",, .F.,, {|oMenuItem|oWnd:Tile()},,,,,,, .F.,,, .F. )
         MenuAddItem( "&Cascade",, .F.,, {|oMenuItem|oWnd:Cascade()},,,,,,, .F.,,, .F. )
      MenuEnd()

   MenuEnd()

return oMenu


 

Re: Problema menu con MenuBegin()

PostPosted: Mon Nov 05, 2018 2:24 pm
by Compuin
cnavarro wrote:Asi

Code: Select all  Expand view


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

function BuildMenu()

   local oMenu

   oMenu := ; //MenuBegin( .F.,,, .F., .F. )
   MenuBegin( .F., , , .F., .F., , ;
              , , , , , , , , , , .F., .F., .F., .F. )

      MenuAddItem( "&Information",, .F.,,,,,,,,, .F.,,, .F. )
      //MenuBegin( .F.,,, .F., .F. )
      MenuBegin( .F., , , .F., .F., , ;
              , , , , , , , , , , .F., .F., .F., .F. )
         MenuAddItem( "&About...",, .F.,, {|oMenuItem|MsgAbout( "FiveWin", "FiveTech" )},,,,,,, .F.,,, .F. )
         MenuAddItem()
         MenuAddItem( "&End...",, .F.,, {|oMenuItem|oWnd:End()},,,,,,, .F.,,, .F. )
      MenuEnd()

      MenuAddItem( "&Child Windows",, .F.,,,,,,,,, .F.,,, .F. )
      //MenuBegin( .F.,,, .F., .F. )
      MenuBegin( .F., , , .F., .F., , ;
              , , , , , , , , , ,.F. , .F., .F., .F. )
         MenuAddItem( "&Tiled",, .F.,, {|oMenuItem|oWnd:Tile()},,,,,,, .F.,,, .F. )
         MenuAddItem( "&Cascade",, .F.,, {|oMenuItem|oWnd:Cascade()},,,,,,, .F.,,, .F. )
      MenuEnd()

   MenuEnd()

return oMenu


 


Perfecto!

Funciona ! Muchas gracias Cristobal !

Re: Problema menu con MenuBegin()

PostPosted: Mon Nov 05, 2018 2:38 pm
by cnavarro
Me alegro
A las antiguas funciones, se les han añadido muchos más parámetros para utilizar las nuevas características que se han añadido a los menus
Te recomiendo que si no utilizas los comandos, mires las definiciones de las funciones en PDMENU.PRG, así verás donde te da el error, y sabrás qué parámetro has de pasar a la function para que no te dé error.

Re: Problema menu con MenuBegin()

PostPosted: Mon Nov 05, 2018 2:39 pm
by Compuin
cnavarro wrote:Me alegro
A las antiguas funciones, se les han añadido muchos más parámetros para utilizar las nuevas características que se han añadido a los menus
Te recomiendo que si no utilizas los comandos, mires las definiciones de las funciones en PDMENU.PRG, así verás donde te da el error, y sabrás qué parámetro has de pasar a la function para que no te dé error.


Si, es lo que he estado viendo. Tengo un menu con estas caracteristicas el cual debo migrar y por alli me esta generando el error

Una vez mas, muchas gracias

Re: Problema menu con MenuBegin()

PostPosted: Mon Nov 05, 2018 2:46 pm
by nageswaragunupudi
You are always safe in using command syntax.
While there nothing you gain by using translated functions directly, but on the other hand, you will get compatibility issues in future versions.

Re: Problema menu con MenuBegin()

PostPosted: Mon Nov 05, 2018 2:50 pm
by karinha
nageswaragunupudi wrote:You are always safe in using command syntax.
While there nothing you gain by using translated functions directly, but on the other hand, you will get compatibility issues in future versions.



Totalmente de acuerdo con el mister Nages.

Saludos.

Re: Problema menu con MenuBegin()

PostPosted: Mon Nov 05, 2018 2:51 pm
by Compuin
nageswaragunupudi wrote:You are always safe in using command syntax.
While there nothing you gain by using translated functions directly, but on the other hand, you will get compatibility issues in future versions.


You're rigth Mr. Rao

I came back from a old menu with this function which is not possible to upgrade directly with FWH17. I need to make some changes to bring up to day

Thanks for the advise

Re: Problema menu con MenuBegin()

PostPosted: Tue Nov 06, 2018 6:48 pm
by cnavarro
Si usted quiere utilizar en su programa las funciones, lo más sencillo es hacer un pequeño ejemplo con comandos con el tipo de menu que necesitas, y compilar con el parámetro adecuado ( /p ) para generar el .ppo. Ahi tienes la function perfectamente formalizada.

Re: Problema menu con MenuBegin()

PostPosted: Tue Nov 06, 2018 6:50 pm
by Compuin
Gracias

Y cual es el parametro de compilacion ?

Re: Problema menu con MenuBegin()

PostPosted: Tue Nov 06, 2018 6:51 pm
by Compuin
cnavarro wrote:Si usted quiere utilizar en su programa las funciones, lo más sencillo es hacer un pequeño ejemplo con comandos con el tipo de menu que necesitas, y compilar con el parámetro adecuado para generar el .ppo. Ahi tienes la function perfectamente formalizada.



Gracias

Y cual es el parametro de compilacion ?

Re: Problema menu con MenuBegin()

PostPosted: Tue Nov 06, 2018 6:59 pm
by karinha
/w0 /p -> generate pre-processed output (.ppo)

Code: Select all  Expand view

xHarbour 1.2.3 Intl. (SimpLex) (Build 20170215)
Copyright 1999-2017, http://www.xharbour.org http://www.harbour-project.org/

Syntax:  C:\XHBBCC72\bin\harbour.exe <file[s][.prg]> [options]

Options:  /a               automatic memvar declaration
          /b               debug info
          /build           display detailed version info
          /credits         display credits
          /d<id>[=<val>]   #define <id>
          /es[<level>]     set exit severity
          /ex              create public function list (.xbx)
          /g<type>         output type generated is <type> (see below)
          /gc[<type>]      output type: C source (.c) (default)
                           <type>: 0=compact 1=normal 2=verbose (default)
                                   3=generate real C code
          /go              output type: Platform dependant object module
          /gh              output type: Harbour Portable Object (.hrb)
          /i<path>         #include file search path
          /j[<file>]       output i18n support [to <file>] to .hil
          /k               compilation mode (type -k? for more data)
          /l               suppress line number information
          /m               compile module only
          /n[<type>]       no implicit starting procedure (default)
                           <type>: 0=no implicit starting procedure
                                   1=no starting procedure at all
                                   2=force application starting procedure
          /o<path>         object file drive and/or path
          /p[o<path>]      generate pre-processed output (.ppo) file in <path>
          /pt[o<path>]     generate pre-processor trace (.ppt) file in <path>
          /q               quiet
          /q0              quiet and don't display program header
          /s               syntax check only
          /u[[+]<file>]    use command def set in <file> (or none)
          /undef:<id>      #undef <id>
          /v               variables are assumed M->
          /vd              external functions are assumed as dynamic functions
          /w[<level>]      set warning level number (0..3, default 1)
          /x[<prefix>]     set symbol init function name prefix (for .c only)
          /z               suppress shortcutting (.and. & .or.)
          @<file>          compile list of modules in <file>


Saludos.