Interfaz TDI con HMG 3.5
Posted: Mon Sep 28, 2026 12:29 am
Saludos amigos:
¿ Alguién ha logrado hacer una interfaz tipo TDI con HMG 3.5 ? Estoy intentando hacer un menú lateral tipo acordeón (con ayuda de Copilot
) pero tanto Copilot como Gemini confunden demasiado las versiones y me entregan códigos combinados de HMG oficial con HMG extended e incluso de OOHG
Aun estoy en el esqueleto inicial ya que es primera vez que intento esto:
Y este es el codigo:
Pero no hace nada cuando hago click en alguna de las opciones principales
Solo por si acaso adjunto los .prg faltantes.
Cualquier sugerencia será agradecida. Saludos y un abrazo.
¿ Alguién ha logrado hacer una interfaz tipo TDI con HMG 3.5 ? Estoy intentando hacer un menú lateral tipo acordeón (con ayuda de Copilot
Aun estoy en el esqueleto inicial ya que es primera vez que intento esto:
Y este es el codigo:
Code: Select all
#include "hmg.ch"
#include "inipublic.prg"
#include "config.prg"
SET AUTOPEN Off
SET BELL Off
SET BROWSESYNC On
SET CODEPAGE TO SPANISH
SET CONSOLE Off
SET CURSOR Off
SET DATE TO BRIT
SET DELETED On
SET DELIMITERS Off
SET ECHO Off
SET EPOCH TO 1990
SET MULTIPLE Off WARNING
SET NAVIGATION EXTENDED
SET SAFETY Off
SET SCOREBOARD Off
SET SOFTSEEK On
SET TALK Off
SET WRAP On
FUNCTION Main()
REQUEST HB_LANG_ESWIN
REQUEST HB_CODEPAGE_ESWIN
REQUEST DBFCDX
RDDSETDEFAULT("DBFCDX")
HB_LANGSELECT( "ES" )
HB_SetCodePage("ESWIN")
SET DATE TO BRIT
DECLARE WINDOW MainWin
DECLARE WINDOW pnlLeft
DECLARE WINDOW pnlCenter
DECLARE WINDOW pnlRight
IniPublic()
LoadConfig()
nMainWidth := GetDesktopWidth()
nMainHeight := GetDesktopHeight() - 30
nLeftWidth := nMainWidth * nPctLeft / 100
nCenterWidth := nMainWidth * nPctCenter / 100
nRightWidth := nMainWidth * nPctRight / 100
nColPnlCenter := nLeftWidth
nColPnlRight := nLeftWidth + nCenterWidth
DEFINE WINDOW MainWin ;
AT 0,0 ;
WIDTH nMainWidth HEIGHT nMainHeight ;
MAIN ;
TITLE "INFOFARMA TDI" ;
NOMAXIMIZE NOSIZE
DEFINE WINDOW pnlLeft ;
ROW 0 ;
COL 0 ;
WIDTH nLeftWidth ;
HEIGHT nMainHeight ;
WINDOWTYPE PANEL ;
BACKCOLOR aColorBack ;
ONMOUSEMOVE MenuHover()
END WINDOW
DEFINE WINDOW pnlCenter ;
ROW 0 COL nColPnlCenter ;
WIDTH nCenterWidth ;
HEIGHT nMainHeight ;
WINDOWTYPE PANEL ;
BACKCOLOR aColorPanel
END WINDOW
DEFINE WINDOW pnlRight ;
ROW 0 COL nColPnlRight ;
WIDTH nRightWidth ;
HEIGHT nMainHeight ;
WINDOWTYPE PANEL ;
BACKCOLOR aColorBack
END WINDOW
InitMenuData()
RedrawLeftMenu()
END WINDOW
MainWin.Center
MainWin.Activate
RETURN NIL
//==================================================================
// Inicialización de la estructura de datos del menú
//==================================================================
PROCEDURE InitMenuData()
aMenuEstructura := { ;
{ "id" => "Admin", "titulo" => "Administradores", "items" => { ;
{ "id" => "lblItem_Articulos", "caption" => "Artículos", "msg" => "abre el módulo de artículos" }, ;
{ "id" => "lblItem_Tipos", "caption" => "Tipos", "msg" => "abre el módulo de tipos" }, ;
{ "id" => "lblItem_Marcas", "caption" => "Marcas", "msg" => "abre el módulo de marcas" }, ;
{ "id" => "lblItem_DCIs", "caption" => "DCIs", "msg" => "abre el módulo de DCIs" }, ;
{ "id" => "lblItem_Proveedores", "caption" => "Proveedores", "msg" => "abre el módulo de proveedores" }, ;
{ "id" => "lblItem_Clientes", "caption" => "Clientes", "msg" => "abre el módulo de clientes" }, ;
{ "id" => "lblItem_Usuarios", "caption" => "Usuarios", "msg" => "abre el módulo de usuarios" }, ;
{ "id" => "lblItem_Movimientos", "caption" => "Movimientos", "msg" => "abre el módulo de movimientos" }, ;
{ "id" => "lblItem_CfgVisual", "caption" => "Configuración Visual", "msg" => "abre configuración visual" }, ;
{ "id" => "lblItem_Temas", "caption" => "Temas", "msg" => "abre temas" } ;
} }, ;
{ "id" => "Compras", "titulo" => "Compras", "items" => { ;
{ "id" => "lblItem_Facturas", "caption" => "Facturas", "msg" => "abre facturas" }, ;
{ "id" => "lblItem_Faltantes", "caption" => "Faltantes", "msg" => "abre faltantes" }, ;
{ "id" => "lblItem_Precios", "caption" => "Precios", "msg" => "abre precios" }, ;
{ "id" => "lblItem_Pagos", "caption" => "Pagos", "msg" => "abre pagos" } ;
} }, ;
{ "id" => "Ventas", "titulo" => "Ventas", "items" => { ;
{ "id" => "lblItem_Ventas", "caption" => "Ventas", "msg" => "abre ventas" }, ;
{ "id" => "lblItem_NCs", "caption" => "Notas de Crédito", "msg" => "abre notas de crédito" }, ;
{ "id" => "lblItem_Cobros", "caption" => "Cobros", "msg" => "abre cobros" } ;
} }, ;
{ "id" => "Servicios", "titulo" => "Servicios", "items" => { ;
{ "id" => "lblItem_Cargos", "caption" => "Cargos/Descargos", "msg" => "abre cargos/descargos" }, ;
{ "id" => "lblItem_Kardex", "caption" => "Kardex", "msg" => "abre kardex" }, ;
{ "id" => "lblItem_Observatorio", "caption" => "Observatorio", "msg" => "abre observatorio" }, ;
{ "id" => "lblItem_Controlados", "caption" => "Controlados", "msg" => "abre controlados" } ;
} } ;
}
RETURN
//==================================================================
// Construcción / Redibujado dinámico del Menú Lateral
//==================================================================
PROCEDURE RedrawLeftMenu()
LOCAL nW, nY, i, j
LOCAL hSec, hSub
LOCAL nTitleHeight := 38
LOCAL nItemHeight := 28
LOCAL cTitId, cSubId
// 1. Eliminar controles previamente creados en pnlLeft
FOR i := 1 TO LEN( aControlesCreados )
IF _IsControlDefined( aControlesCreados[i], "MainWin" )
DoMethod( "MainWin", aControlesCreados[i], "RELEASE" )
ENDIF
NEXT
aControlesCreados := {}
hMenuItems := hb_Hash()
nW := nLeftWidth - ( nMenuLeftMargin * 2 )
nY := 0
// 2. Iterar secciones principales
FOR i := 1 TO LEN( aMenuEstructura )
hSec := aMenuEstructura[i]
cTitId := "lblTit_" + hSec["id"]
AddMenuTitle( cTitId, hSec["titulo"], nY, nW, nTitleHeight, hSec["id"] )
AADD( aControlesCreados, cTitId )
nY += nTitleHeight
// Si la sección actual está activa, desplegar sus subelementos
IF cSeccionActiva == hSec["id"]
FOR j := 1 TO LEN( hSec["items"] )
hSub := hSec["items"][j]
cSubId := hSub["id"]
AddMenuItem( cSubId, " " + hSub["caption"], nY, nW, nItemHeight, hSub["msg"] )
AADD( aControlesCreados, cSubId )
nY += nItemHeight
NEXT
ENDIF
NEXT
RETURN
//==================================================================
// Control de apertura/cierre de secciones (Efecto Acordeón)
//==================================================================
PROCEDURE ToggleSeccion( cSecId )
IF cSeccionActiva == cSecId
cSeccionActiva := "" // Si se vuelve a hacer clic en la abierta, se cierra
ELSE
cSeccionActiva := cSecId // Abre la nueva y automáticamente cierra las demás
ENDIF
RestoreHover()
cMenuHover := ""
RedrawLeftMenu()
RETURN
//==================================================================
// Métodos de Creación y Eventos
//==================================================================
PROCEDURE AddMenuTitle( LblName, cText, nY, nW, nH, cSecId )
@ nY, nMenuLeftMargin LABEL &LblName OF pnlLeft ;
VALUE cText ;
WIDTH nW HEIGHT nH ;
FONT cMenuFontName SIZE ( nMenuFontSize + 1 ) BOLD ;
FONTCOLOR aMenuTitleFore ;
BACKCOLOR aMenuTitleBack ;
ACTION ToggleSeccion( cSecId )
hMenuItems[ LblName ] := { ;
"name" => LblName, ;
"row" => nY, ;
"col" => nMenuLeftMargin, ;
"width" => nW, ;
"height" => nH, ;
"fore" => aMenuTitleFore, ;
"back" => aMenuTitleBack, ;
"hoverFore" => {255,255,255}, ;
"hoverBack" => {60,90,140} }
RETURN
PROCEDURE AddMenuItem( LblName, cText, nY, nW, nH, cMsg )
@ nY, nMenuLeftMargin LABEL &LblName OF pnlLeft ;
VALUE cText ;
WIDTH nW HEIGHT nH ;
FONT cMenuFontName SIZE nMenuFontSize ;
FONTCOLOR aMenuItemsFore ;
BACKCOLOR aMenuItemsBack ;
ACTION MsgInfo( cMsg )
hMenuItems[ LblName ] := { ;
"name" => LblName, ;
"row" => nY, ;
"col" => nMenuLeftMargin, ;
"width" => nW, ;
"height" => nH, ;
"fore" => aMenuItemsFore, ;
"back" => aMenuItemsBack, ;
"hoverFore" => {255,255,255}, ;
"hoverBack" => {80,120,180} }
RETURN
PROCEDURE MenuHover()
LOCAL nRow := 0
LOCAL nCol := 0
LOCAL cName
LOCAL hItem
LOCAL aKeys
LOCAL i
IF EMPTY( hMenuItems )
RETURN
ENDIF
aKeys := HB_HKeys( hMenuItems )
HMG_GetCursorPos( pnlLeft.Handle, @nRow, @nCol )
FOR i = 1 TO LEN( aKeys )
cName := aKeys[i]
hItem := hMenuItems[ cName ]
IF nRow >= hItem["row"] .AND. ;
nRow <= hItem["row"] + hItem["height"] .AND. ;
nCol >= hItem["col"] .AND. ;
nCol <= hItem["col"] + hItem["width"]
IF cMenuHover != cName
RestoreHover()
ApplyHover( cName )
cMenuHover := cName
ENDIF
RETURN
ENDIF
NEXT
RestoreHover()
cMenuHover := ""
RETURN
PROCEDURE ApplyHover( cName )
LOCAL hItem
IF !EMPTY( cName ) .AND. HB_HHasKey( hMenuItems, cName )
hItem := hMenuItems[ cName ]
SetProperty( "MainWin", hItem["name"], "BACKCOLOR", hItem["hoverBack"] )
SetProperty( "MainWin", hItem["name"], "FONTCOLOR", hItem["hoverFore"] )
ENDIF
RETURN
PROCEDURE RestoreHover()
LOCAL hItem
IF !EMPTY( cMenuHover ) .AND. HB_HHasKey( hMenuItems, cMenuHover )
hItem := hMenuItems[ cMenuHover ]
IF _IsControlDefined( hItem["name"], "MainWin" )
SetProperty( "MainWin", hItem["name"], "BACKCOLOR", hItem["back"] )
SetProperty( "MainWin", hItem["name"], "FONTCOLOR", hItem["fore"] )
ENDIF
ENDIF
RETURN
Solo por si acaso adjunto los .prg faltantes.
Cualquier sugerencia será agradecida. Saludos y un abrazo.