PDA

Ver la Versión Completa : Conectar archivos de ayuda a un programa


GINAUNICA
14-04-2008, 19:27:39
Hola

yo estudiante de ing. ambiental y mi tesis consiste en realizar un programa en Delphi, resulta que tengo incovenientes o en realidad no se como hacerlo. La cuestión es conectar unos archivos de ayudas al programa. Las ayudas las hice con HelpNDoc.

Gracias por su ayuda

juanelo
15-04-2008, 01:20:12
Hola

yo estudiante de ing. ambiental y mi tesis consiste en realizar un programa en Delphi, resulta que tengo incovenientes o en realidad no se como hacerlo. La cuestión es conectar unos archivos de ayudas al programa. Las ayudas las hice con HelpNDoc.

Gracias por su ayuda
Hola GINAUNICA, no indicas si tus archivos de ayuda son *.hlp o *.chm
Saludos

GINAUNICA
15-04-2008, 01:38:39
Hola GINAUNICA, no indicas si tus archivos de ayuda son *.hlp o *.chm
Saludos


Los archivos de ayuda son de tipo .chm

gracias por tu ayuda

juanelo
15-04-2008, 01:43:35
Codigo en C++
#include <vcl.h>
#pragma hdrstop


//---------------------------------------------------------------------------
void UltimoError(HWND ventana)
{
///USES_CONVERSIONS; // For Unicode to ANSI string conversion
HH_LAST_ERROR lasterror ;
memset(&lasterror,0,sizeof(HH_LAST_ERROR));
HWND hwnd = ChmHelp(
ventana,
NULL,
HH_GET_LAST_ERROR,
reinterpret_cast<DWORD>(&lasterror)) ;
// Make sure that HH_GET_LAST_ERROR succeeded.
if (hwnd != 0)
{
// Only report an error if we found one:
if (FAILED(lasterror.hr))
{
// Is there a text message to display...
AnsiString cadError=AnsiString(lasterror.description);
MessageBox(ventana, cadError.c_str(), "Help Error", MB_OK) ;
}
}
}
//---------------------------------------------------------------------------
bool _export EjecutaChmHelp(HWND hdlWindow,AnsiString strAyuda, short ACommand, unsigned int Additional)
{
char* ptrChm=NULL;
bool result =true;

if (!hdlOcx)
{
hdlOcx= LoadLibrary("HHCTRL.OCX");
if (!hdlOcx)
{
MessageBox(hdlWindow, "No se ha podido cargar el componente de ayuda (HHCTRL.OCX).", "Help Error", MB_OK) ;
return false;
}
}
HWND hldResult=0;
HH_FTS_QUERY busqueda ;
AnsiString archChm= strAyuda;

if (!ChmHelp)
{
ChmHelp =(TChmHelp)GetProcAddress(hdlOcx,"HtmlHelpA");
if (!ChmHelp)
{
MessageBox(hdlWindow, "No se encuentra la función para lanzar el ayuda (HtmlHelpA).", "Help Error", MB_OK) ;
return false;
}
}
///obtenemos el nombre del archivo en formato chm
switch(ACommand)
{
case HELP_INDEX:
case HELP_CONTEXT:
case HELP_CONTEXTPOPUP :
if (!Additional)
{
ptrChm=strdup((archChm+"::/principal.htm").c_str());
hldResult=ChmHelp(hdlWindow,ptrChm,HH_DISPLAY_TOC,NULL);
}
else
{
ptrChm=strdup((archChm+ "::/"+IntToStr(Additional)+".htm").c_str());
hldResult=ChmHelp(hdlWindow,ptrChm,HH_DISPLAY_TOC,NULL);
}
break;
case HELP_PARTIALKEY:
ptrChm=strdup(archChm.c_str());
///iniciamos los parámetros para la busqueda.
busqueda.cbStruct = sizeof(HH_FTS_QUERY) ;
busqueda.fUniCodeStrings = FALSE ;
busqueda.pszSearchQuery = "";
busqueda.iProximity = HH_FTS_DEFAULT_PROXIMITY ;
busqueda.fStemmedSearch = FALSE ;
busqueda.fTitleOnly = FALSE ;
busqueda.fExecute = FALSE ;
busqueda.pszWindow = NULL ;
hldResult=ChmHelp(hdlWindow,ptrChm,HH_DISPLAY_SEARCH,(DWORD)&busqueda);
///fin de inicialización de parámetros.
break;
case HELP_FINDER:
ptrChm=strdup(archChm.c_str());
if (Additional>0)
hldResult=ChmHelp(hdlWindow,ptrChm,HH_DISPLAY_INDEX,(DWORD)(IntToStr(Additional)).c_str());
else
hldResult=ChmHelp(hdlWindow,ptrChm,HH_DISPLAY_INDEX,(DWORD)"");
break;
default :
break;
}
if (!hldResult)
UltimoError(hdlWindow);
if (ptrChm)
{
delete[] ptrChm;
ptrChm=NULL;
}
return (hldResult!=0);
}
//---------------------------------------------------------------------------
void _export LiberaComponenteDeAyuda(void)
{
if(hdlOcx)
{
FreeLibrary(hdlOcx);
hdlOcx=NULL;
}
}
//---------------------------------------------------------------------------