Problemas con Menu en tiempo de ejecucion

Problemas con Menu en tiempo de ejecucion

Postby wilsongamboa » Mon Jan 23, 2006 4:45 am

buenas noches compañeros

Defino la ventana principal y un menu donde las opciones estan desabilitadas en base a un array

Dentro de la ventana tengo un Tree donde al escoger uno, se debe de habilitar las opciones del menu, he probado esto sin resultado alguno

oWnd:SetMenU ( HagaMenuHabilitado() )

Haga menuhabilitado devuelve un objeto menu habilitando todas las opiones

oWnd:oMenu:DelItems()
oWnd:oMenu:Reset()
oWnd:SetMenu ( HagaMenuHabilitado() )
oWnd:Refresh()

Y nada , el menu sigue desabilitado

Nota la ventana no es MDI ya que en MDI no me funciona el Tree en la ventana

Alguna idea???
gracias x todo y espero haberme explicado

Saludos
Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
User avatar
wilsongamboa
 
Posts: 548
Joined: Wed Oct 19, 2005 6:41 pm
Location: Quito - Ecuador

Postby Antonio Linares » Mon Jan 23, 2006 9:18 am

Wilson,

Puedes por favor proporcionar un ejemplo pequeño y completo que podamos construir aqui para probarlo ? gracias.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41318
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby wilsongamboa » Mon Jan 23, 2006 1:09 pm

Antonio este es lo mas reducido, al final te listo el contenido del archivo Bugmenu.rc que solo tiene dos bitmaps de los samples de Fh
el prg se llama Bugmenu.prg

Uso Fwh 2.7 + xHarbour (Ultima version)

#include 'fivewin.ch'
#include 'hbclass.ch'
#define SISTEMA 'José - Rol For Windows Versión 1.0 - Multiuser'

#define MNU_RL_11 1
#define MNU_RL_12 2
#define MNU_RL_13 3
#define MNU_RL_14 4
#define MNU_RL_15 5
#define MNU_RL_16 6
#define MNU_RL_17 7
#define MNU_RL_18 8
#define MNU_RL_19 9
#define MNU_RL_1A 10
#define MNU_RL_1B 11
#define MNU_RL_1C 12
#define MNU_RL_1D 13
#define MNU_RL_1E 14
#define MNU_RL_1F 15
#define MNU_RL_1G 16
#define MNU_RL_1H 17
#define MNU_RL_1I 18
#define MNU_RL_1J 19
#define MNU_RL_21 20
#define MNU_RL_22 21
#define MNU_RL_23 22
#define MNU_RL_24 23
#define MNU_RL_25 24
#define MNU_RL_26 25
#define MNU_RL_27 26
#define MNU_RL_28 27
#define MNU_RL_29 28
#define MNU_RL_2A 29
#define MNU_RL_2B 30
#define MNU_RL_2C 31
#define MNU_RL_31 32
#define MNU_RL_32 33
#define MNU_RL_33 34
#define MNU_RL_34 35
#define MNU_RL_35 36
#define MNU_RL_36 37
#define MNU_RL_37 38
#define MNU_RL_38 39

Memvar oNewRol

Function Main( NumEmpre )

Local oAmbiente

IF Empty( NumEmpre )
NumEmpre := '1'
End

NumEmpre := Val( NumEmpre )

IF Empty( NumEmpre )
MsgInfo('No indico correctamente el número de empresa de trabajo', SISTEMA)
RETURN Nil
End

oAmbiente:= tWg_Ambiente_Rol():New(NumEmpre)

If oAmbiente:lQuit
MsgInfo('ha habido un error y no se ejecutara la aplicación'+CRLF+;
'Consulte al administrador del sistema o llame al' +CRLF+;
'099550421-023443605 o email swrite@uio.satnet.net', SISTEMA)
Return Nil
End

Public oNewRol := tNewRol():New()
//rescato lo generado en ambiente
oNewrol:aEmpresas := aClone( oAmbiente:aEmpresas )

oNewrol:Activate() //genero el la ventana el menu y el timer



Return Nil


*********************************************************
* Clase para gestionar el rol de pagos
*********************************************************
Class tNewrol

Data oWnd
Data oBrw
Data oFont
Data oProgress
Data cTitle Init SISTEMA
Data lYaEmpre Init .F.
Data oMenu
Data aEmpresas
Data aDir
Data aCaminos
Data aPerms Init Array(100)
Data oFont

Method New() Constructor
Method MakeMenu()
Method Activate()
Method Timer ( oWnd )
Method Timer1( oWnd )
Method PongaElTree(oSay)
METHOD MyClick(nRow, nCol, oTree)
Method Close()

EndClass



*********************************************************
*
*********************************************************
METHOD New( ) CLASS tNewRol

::aPerms := Afill( ::aPerms , .F. )

Return Self

*********************************************************
*
*********************************************************
METHOD Activate( ) CLASS tNewRol
Local oSelf := Self
LOCAL oFont
LOCAL oIcon
Local oBmp


DEFINE Font ::oFont Name 'Arial' Bold SIZE 0,-11

Define Window oSelf:oWnd Title oSelf:cTitle Menu oSelf:MakeMenu() COLOR CLR_BLACK, nrgb(128,200,240)

::PongaElTree( )

Activate Window oSelf:oWnd Maximized On Init oSelf:Timer( oSelf:oWnd )


Return Self

*********************************************************
*
*********************************************************
Method PongaElTree() Class tNewRol

Local oSelf := Self
Local oImageList := TImageList():New()
Local oBmp1 := TBitmap():Define( "folder" ,, oSelf:oWnd )
Local oBmp2 := TBitmap():Define( "fldMask" ,, oSelf:oWnd )
Local i := 0
LOCAL oTree
Local oMsgEmp

oImageList:Add( oBmp1, oBmp2 )

oTree = TTreeView():New( 2, 0, oSelf:oWnd, CLR_BLACK ,nrgb(128,200,240), .T., .F., 300, 350, 'Proyectos' )

oTree:bLDblClick := { | nRow, nCol, nKeyFlags | oSelf:MyClick( nRow, nCol, oTree ) }

oTree:SetImageList( oImageList )

While ++i <= Len( oSelf:aEmpresas )
oTree:Add( oSelf:aEmpresas[i] ) ///
END

SET MESSAGE OF oSelf:oWnd TO '' NOINSET CLOCK DATE KEYBOARD

DEFINE MSGITEM oMsgEmp OF oSelf:oWnd:oMsgBar ;
SIZE 310 ;
COLOR CLR_HBLUE ;
PROMPT ""


::oProgress := TProgress():New(4, 5, oSelf:oWnd:oMsgBar,0,,,.t.,.f.,180,14.7)


Return Self

METHOD MyClick(nRow, nCol, oTree) CLASS tNewrol


local oItem
Local nAt
Local oUser
local n, lWhen
local oItem1

oItem := oTree:HitTest( nRow, nCol )

if oItem != NIL
nAt := Ascan( ::aEmpresas, oItem:cPrompt )

aFill( ::aPerms, .T. )
::oWnd:SetMenu( ::MakeMenu() )
::oWnd:Refresh()
::oWnd:Settext( SISTEMA + 'Proy ' + oItem:cPrompt + ' Estación ' + NetName() )

else
MsgInfo( "No Hallado!", SISTEMA )
endif

RETURN Self


*********************************************************
*
*********************************************************
METHOD Timer( oWnd ) CLASS tNewRol

local oIco, oTimer, oSelf := Self

/*
static nFrame := 1
@ 0.3, 60 ICON oIco RESOURCE "ICON1" OF oWnd BORDER
DEFINE TIMER oTimer OF oWnd ;
INTERVAL 400 ;
ACTION ( nFrame := If( ++nFrame > 20, 1, nFrame ) , ;
oIco:SetName( "ICON" + AllTrim( Str( int(nFrame) ) ) ),;
oSelf:Timer1( oSelf:oWnd ) )
*/
DEFINE TIMER oTimer OF oWnd ;
INTERVAL 400 ;
ACTION ( oSelf:Timer1( oSelf:oWnd ) )

ACTIVATE TIMER oTimer

Return Self


*********************************************************
*
*********************************************************
METHOD Timer1( oWnd ) CLASS tNewRol

Return Self


*********************************************************
*
*********************************************************
METHOD MakeMenu( ) CLASS tNewRol

Local ctext := ''
Local nCount
Local oSelf := Self

MENU oSelf:oMenu
MENUITEM "&Ingresos a Tablas"
MENU
MENUITEM '&1.- Archivo de Empleados' ACTION MsgInfo('hola') WHEN oSelf:aPerms[MNU_RL_11] .And. oSelf:lYaEmpre
MENUITEM '&2.- Archivo de Rubros' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_12] .And. oSelf:lYaEmpre
MENUITEM '&3.- Archivo de tablas del Iess' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_13] .And. oSelf:lYaEmpre
MENUITEM '&4.- Tablas del Impuesto a la Renta' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_14] .And. oSelf:lYaEmpre
MENUITEM '&5.- Información del Proyecto' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_15] .And. oSelf:lYaEmpre
MENUITEM '&6.- Tabla de Bancos' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_16] .And. oSelf:lYaEmpre
MENUITEM '&7.- Tabla de Departamentos' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_17] .And. oSelf:lYaEmpre
MENUITEM '&8.- Tabla de Horas extras' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_18] .And. oSelf:lYaEmpre
MENUITEM '&9.- Procesar el Pre-Rol' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_19] .And. oSelf:lYaEmpre
MENUITEM '&A.- Ingreso de Movimientos Manuales a Rol' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_1A] .And. oSelf:lYaEmpre
MENUITEM '&B.- Borrado de rubros del Pre-Rol' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_1B] .And. oSelf:lYaEmpre
MENUITEM '&C.- Cierre de Un Período en Pre-Rol' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_1C] .And. oSelf:lYaEmpre
MENUITEM '&D.- Cierre de Período en Rol Definitivo' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_1D] .And. oSelf:lYaEmpre
MENUITEM '&E.- Abrir Periodo de pre-rol ya cerrado' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_1E] .And. oSelf:lYaEmpre
MENUITEM '&F.- Contabilización de un período de rol' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_1F] .And. oSelf:lYaEmpre
MENUITEM '&G.- Reliquidar un Rubro en roles cerrados' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_1G] .And. oSelf:lYaEmpre
MENUITEM '&H.- Tabla de Números Patronales' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_1H] .And. oSelf:lYaEmpre
MENUITEM "&I.- Tabla de Varios Números" ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_1I] .And. oSelf:lYaEmpre
MENUITEM '&J.- Reporte Ajuste Impuesto a la Renta' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_1J] .And. oSelf:lYaEmpre
SEPARATOR
MENUITEM "&Salir" ACTION oSelf:Close()
ENDMENU
MENUITEM "&Listados y Reportes"
MENU
MENUITEM '&1.- Archivo de Empleados' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_21] .And. oSelf:lYaEmpre
MENUITEM '&2.- Imprimir Recibos de Roles' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_22] .And. oSelf:lYaEmpre
MENUITEM '&3.- Impresión de Planillas del Iess' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_23] .And. oSelf:lYaEmpre
MENUITEM '&4.- Rol Condensado' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_24] .And. oSelf:lYaEmpre
MENUITEM '&5.- DisKette al Banco' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_25] .And. oSelf:lYaEmpre
MENUITEM '&6.- Reporte al Banco' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_26] .And. oSelf:lYaEmpre
MENUITEM '&7.- Decimo Tercero, Cuarto, Quinto Sueldo' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_27] .And. oSelf:lYaEmpre
MENUITEM '&8.- Reporte de Historico' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_28] .And. oSelf:lYaEmpre
MENUITEM '&9.- Utilidades' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_29] .And. oSelf:lYaEmpre
MENUITEM '&A.- Reporte de Liquidaciones a Personal' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_2A] .And. oSelf:lYaEmpre
MENUITEM '&B.- Fondos de reserva' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_2B] .And. oSelf:lYaEmpre
MENUITEM '&C.- Reporte de Roles formulables' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_2C] .And. oSelf:lYaEmpre
ENDMENU
MENUITEM "&Mantenimiento"
MENU
MENUITEM '&1.- Sacar Respaldos de Datos' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_31] .And. oSelf:lYaEmpre
MENUITEM '&2.- Manejo de Usuarios' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_32] .And. oSelf:lYaEmpre
MENUITEM '&3.- Reindexación de Archivos' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_33] .And. oSelf:lYaEmpre
MENUITEM '&4.- Auditoría Informática' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_34] .And. oSelf:lYaEmpre
MENUITEM '&5.- Generador de Reportes de Archivo único' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_35] .And. oSelf:lYaEmpre
MENUITEM '&6.- Borrado de un período' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_36] .And. oSelf:lYaEmpre
MENUITEM '&7.- Cargar Horas extras y dias tr. de disk' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_37] .And. oSelf:lYaEmpre
MENUITEM '&8.- Cheques desde Roles' ACTION MsgInfo('Hola') WHEN oSelf:aPerms[MNU_RL_38] .And. oSelf:lYaEmpre
MENUITEM '&9.- Configurar Impresora' ACTION PrinterSetUp() //WHEN lYaEmpre
ENDMENU
ENDMENU


RETURN oSelf:oMenu


Method Close() Class tNewrol

::oWnd():End()
::oFont := Nil
DbCloseAll()
Quit

Return Nil


********************************************************************
* Clase Para Inicializar ambiente de trabajajo
********************************************************************

Class tWg_Ambiente_Rol

Data GLB_Work Init ''
Data lQuit Init .F.
Data aEmpresas Init {}
Data aDir Init {}
Data aCaminos Init {}
Method New() Constructor

EndClass


/*********************************************


**********************************************/
Method New( nNumEmpresa) Class tWg_Ambiente_Rol

Local Cnt := 0
Local aTmp
Local aTmp1
LOCAL i

For i:= 1 To 100

AADD( ::aEmpresas, 'Empresa ' + StrZero(i,3) )

Next

Return Self



///////////////////// Inicio Archivo BugMenu.Rc ///////////////

/*
folder BITMAP "c:\fwh27\bitmaps\16x16\folder.bmp"
fldMask BITMAP "c:\fwh27\bitmaps\16x16\fldmask.bmp"

*/
////////////////////Final /////////////////////////


Gracias x Tu Ayuda

Saludos
Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
User avatar
wilsongamboa
 
Posts: 548
Joined: Wed Oct 19, 2005 6:41 pm
Location: Quito - Ecuador

Postby Antonio Linares » Mon Jan 23, 2006 1:17 pm

Wilson,

Esto es lo más reducido posible ? :)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41318
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Jan 23, 2006 1:29 pm

Wilson,

No hace falta que crees el menú de nuevo (solo he echado un vistazo al código), para eso está la claúsula WHEN de los menuitems. Cambiando una determinada condición, algunos items estarán activos y otros no.

Eso es lo que necesitas ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41318
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby wilsongamboa » Mon Jan 23, 2006 1:39 pm

Antonio, el ejemplo que te envie compila sin errores

Ahora como lo que cambio es ::aPerms

He probado de todo

::oWnd:Omenu:Refresh()
Pero nada

Si compilas el ejemplo vas a mirar lo que te indico
Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
User avatar
wilsongamboa
 
Posts: 548
Joined: Wed Oct 19, 2005 6:41 pm
Location: Quito - Ecuador

Postby wilsongamboa » Mon Jan 23, 2006 1:58 pm

Antonio
por si acaso ::lYaEmpre := .T.

Tampoco hace que se active el menu

Saludos
Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
User avatar
wilsongamboa
 
Posts: 548
Joined: Wed Oct 19, 2005 6:41 pm
Location: Quito - Ecuador

Postby wilsongamboa » Tue Jan 24, 2006 11:24 am

Antonio y _ gracias
El problema no era ni Fwh ni xHarbour sino Yo
No estaba activada una variable en momento de escoger
Gracias y perdon por hacerles perder el tiempo
por cierto funciona de maravilla y no se requiere definir nuevamente el menu, basta con

::oWnd:oMenu:Refresh()

Saludos
Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
User avatar
wilsongamboa
 
Posts: 548
Joined: Wed Oct 19, 2005 6:41 pm
Location: Quito - Ecuador

Postby Antonio Linares » Tue Jan 24, 2006 2:53 pm

Wilson,

Me alegro de que lo hayas solucionado :)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41318
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 8 guests