Ver Mensaje Individual
  #4  
Antiguo 15-04-2008
Avatar de juanelo
juanelo juanelo is offline
Miembro
 
Registrado: sep 2007
Posts: 1.084
Reputación: 18
juanelo Va por buen camino
Codigo en C++
Código Delphi [-]
#include 
#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(&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;
   }
}
//---------------------------------------------------------------------------
Responder Con Cita