//---------------------------------------------------------------------------
// HTMLヘルプを表示する関数
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "htmlhelp.h"
#include "HHelp.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
//---------------------------------------------------------------------------
Htmlhelp::Htmlhelp(void){
  Handle = LoadLibrary("HHCTRL.OCX");
  if(Handle==NULL) {
    ShowMessage("HHCTRL.OCXが見つかりません");
    return;
  }
}
//---------------------------------------------------------------------------
Htmlhelp::~Htmlhelp(void){
  FreeLibrary(Handle);
}
//---------------------------------------------------------------------------
void
Htmlhelp::ShowHtmlHelp(HWND handle,char *helpfile) {
  typedef HWND (WINAPI *FPHH) (HWND, LPCSTR, UINT, DWORD);
  if(Handle == NULL){
    return;
  }
  FPHH htmlHelp = (FPHH)GetProcAddress(Handle,"HtmlHelpA");
  if(htmlHelp==NULL){
    ShowMessage("HtmlHelpAが見つかりません");
    return;
  }
  htmlHelp(handle,helpfile, HH_DISPLAY_TOPIC, NULL);
}
//---------------------------------------------------------------------------
void
Htmlhelp::ShowHtmlHelpSearch(HWND handle,char *helpfile,char *keyword) {
  typedef HWND (WINAPI *FPHH) (HWND, LPCSTR, UINT,DWORD);
  if(Handle == NULL){
    return;
  }
  FPHH htmlHelp= (FPHH)GetProcAddress(Handle,"HtmlHelpA");
  if(htmlHelp==NULL){
    ShowMessage("HtmlHelpAが見つかりません");
    return;
  }
  HH_AKLINK link;
  link.cbStruct =     sizeof(HH_AKLINK) ;
  link.fReserved =    FALSE ;
  link.pszKeywords =  keyword;
  link.pszUrl =       NULL ;
  link.pszMsgText =   NULL ;
  link.pszMsgTitle =  NULL ;
  link.pszWindow =    NULL ;
  link.fIndexOnFail = TRUE ;
  htmlHelp(handle,helpfile, HH_KEYWORD_LOOKUP, (DWORD)&link);
}
//---------------------------------------------------------------------------
