!!!顷家荡产!!! 如何调用HtmlHelp() API实现全文查找? (30分)

  • 主题发起人 坏蛋是我
  • 开始时间

坏蛋是我

Unregistered / Unconfirmed
GUEST, unregistred user!
比如如下代码:
HH_FTS_QUERY q;
char helpFile[]="E://WIN95DDK.CHM";
memset(&q, 0, sizeof(HH_FTS_QUERY));
q.cbStruct = sizeof(HH_FTS_QUERY);
q.fUniCodeStrings = FALSE;
q.pszSearchQuery = "DDK";
q.iProximity = HH_FTS_DEFAULT_PROXIMITY;
q.fStemmedSearch = FALSE;
q.fTitleOnly = FALSE;
q.fExecute = TRUE;
q.pszWindow = NULL;
HtmlHelp(NULL, (LPCSTR)helpFile, HH_DISPLAY_SEARCH,(DWORD)&q);
运行时输入框出现‘DDK’字符串,但是没有列出主题,为什么?
另外,我如何获得查找结果呢?比如所在页面,相关上下文?(这个最重要!!!!)
我只有这么多分了!分不够的话我在CSDN上面倒有7000多分。。。
万分感谢!
谢谢!
 
哪有html workshop得api下载?
 
我不说。。。除非你告诉我答案我才会告诉你^_^
 
我连api都没有
你觉得我象知道答案的么
:)
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
const
HH_DISPLAY_TOC = $0001;
HH_DISPLAY_TOPIC = $0000;
HH_CLOSE_ALL = $0012;
HH_DISPLAY_INDEX = $0002;
HH_HELP_CONTEXT = $000F;
HH_DISPLAY_SEARCH= $0003;
HH_DISPLAY_TEXT_POPUP = $000E;
type
HH_FTS_Query = record
cbStruct : integer;
// sizeof structure
fUniCodeStrings : bool;
// true if all strings are unicode
pszSearchQuery : PChar;
// string with the search query
iProximity : longint;
// word proximity
fStemmedSearch : bool;
// true for stemmed search only
fTitleOnly : bool;
// true for title search only
fExecute : bool;
// true to initiate the search
pszWindow : PChar;
// window to display in
end;
// HH_FTS_Query
HH_POPUP = record
cbStruct: integer;
// sizeof this structure
hinst: longint;
// instance handle for string resource
idString: UINT;
// string resource id, or text id if pszFile is specified in HtmlHelp call
pszText: LPCTSTR;
// used if idString is zero
pt: TPOINT;
// top center of popup window
clrForeground: COLORREF;
// use -1 for default
clrBackground: COLORREF;
// use -1 for default
rcMargins: TRECT;
// amount of space between edges of window and text, -1 for each member to ignore
pszFont: LPCTSTR;
// facename, point size, char set, BOLD ITALIC UNDERLINE
end;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.DFM}
function HtmlHelp(hwndCaller: HWND;
pszFile: PChar;
uCommand: UINT;
dwData: PDWORD): HWND;
stdcall;
external 'hhctrl.ocx' Name 'HtmlHelpA';
procedure TForm1.Button1Click(Sender: TObject);
begin
{
调用缺省主题帮助
此调用方式用于没有上下文ID号的情形,dwData可指定一个在CHM文件内的缺省htm文件,
也可取Nil,这是HtmlHelp API最基本的一种用法。
}
HtmlHelp(handle,pchar('help.chm'),HH_DISPLAY_TOPIC,PDWORD(pchar('article.htm')));
//或:HtmlHelp(handle,pchar('help.chm'),HH_DISPLAY_TOPIC,nil);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
{
调用关键字帮助
此调用方式中dwData取索引文件(.hhk)中存在的关键字。
}
HtmlHelp(handle,pchar('help.chm'),HH_DISPLAY_INDEX,PDWORD(pchar('ambaSio')));
end;

procedure TForm1.Button3Click(Sender: TObject);
var
dw: DWORD;
begin
{
调用上下文敏感帮助
此调用方式用于含有映射信息的CHM文件, dwData取映射表中存在的ID号。
}
dw := 10;
HtmlHelp(handle,pchar('>help.chm'),HH_HELP_CONTEXT,PDWORD(@dw));
//这种方式我没试出来,可能是我的chm文件不含映射信息的缘故。
end;

procedure TForm1.Button4Click(Sender: TObject);
var
query: HH_FTS_Query;
begin
{
调用全文搜索帮助
}
with query do
begin
cbStruct := sizeof(HH_FTS_Query);
fUniCodeStrings := false;
iProximity := 1;
fStemmedSearch := true;
fExecute := true;
fTitleOnly := false;
pszWindow := 'MainWin';
pszSearchQuery := nil;
end;
HtmlHelp(handle,pchar('help.chm'),HH_DISPLAY_SEARCH,PDWORD(@query));
end;

procedure TForm1.Button5Click(Sender: TObject);
var
popup: HH_POPUP;
begin
{
调用弹出式帮助
PszFile通常取NULL,也可以指定一个CHM和一个在该CHM文件中的TEXT文件,DwData用
于指定一个指向HH_POPUP结构的指针。
}
with popup do
begin
cbStruct := sizeof(HH_POPUP);
hinst:= 0;
idString:=1;
pszText:=nil;
//pt:= pt;
GetCursorPos(pt);
clrForeground:=COLORREF(-1);
clrBackground:=COLORREF(-1);
rcMargins.Left := 0;
rcMargins.Top := 0;
rcMargins.Right := 25;
rcMargins.Bottom := 25;
pszFont:=LPCTSTR('BOLD');

end;
HtmlHelp(handle,pchar('test.chm'),HH_DISPLAY_TEXT_POPUP,PDWORD(@popup));
//这个我也没搞太明白,能出现Popup,但无帮助内容。
end;

end.
 
谢谢!但是我试过了,问题没有解决!我的代码如下:
//调用全文搜索帮助
procedure TMainForm.SearchBtnClick(Sender: TObject);
var
query: HH_FTS_Query;
begin
with query do
begin
cbStruct := sizeof(HH_FTS_Query);
fUniCodeStrings := false;
pszSearchQuery := 'qq';
iProximity := 1;
fStemmedSearch := true;
fExecute := true;
fTitleOnly := true;
pszWindow := nil;
end;
HtmlHelp(handle,pchar('E:/qq.chm'),HH_DISPLAY_SEARCH,PDWORD(@query));
end;
 
运行结果:qq.chm文件跳出来了!输入框并没有初始化成我想查找的词(pszSearchQuery := 'qq';)
当然也没有查询结果。。。
为什么?
 
我是了很久,还是没结果。。。
 
高兴!散分!不好意思,我就这么一点(快破产了),请笑纳!
多谢各位的捧场!
今天解决了一个大问题,高兴,结贴,散分!
 
这个MS已经承认是BUG了。。不能实现完全搜索。。5555555555
BUG: HTML Help: HH_DISPLAY_SEARCH API Command do
es Not Perform a Search
适用于
This article was previously published under Q241381
SYMPTOMS
According to the HTML Help Workshop online do
cumentation, the HH_DISPLAY_SEARCH API command displays the Search tab in the navigation pane of the HTML Help Viewer. If the HH_FTS_QUERY structure member, fExecute, is "TRUE", a search is performed for the term that is specified in the pszSearchQuery parameter. In reality, the structure members are ignored and the search is not performed.
CAUSE
This problem is caused by a bug in the HTML Help control.
RESOLUTION
It is not possible to start a full-text search from the HTML Help API.
STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the begin
ning of this article.
MORE INFORMATION
You can use the HH_DISPLAY_SEARCH command in the following example to display the search tab;
however a search is not performed: HH_FTS_QUERY q ;
q.cbStruct = sizeof(HH_FTS_QUERY) ;
q.fUniCodeStrings = FALSE ;
q.pszSearchQuery = "culture";
q.iProximity = HH_FTS_DEFAULT_PROXIMITY ;
q.fStemmedSearch = FALSE :
q.fTitleOnly = FALSE ;
q.fExecute = FALSE ;
q.pszWindow = NULL ;

HtmlHelp(hwnd,"cat.chm",HH_DISPLAY_SEARCH,(DWORD)&q);

 
我正在为这个问题抓狂,希望“坏蛋是我”兄弟拉我一把,告知您是如何解决问题的。
我可以把所有分数送上,谢谢拉。
 
顶部