×
Namespaces

Variants
Actions

完成上下文相关的帮助文档

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

文章
hoolee 在 16 Feb 2009 创建
最后由 hamishwillee 在 15 Dec 2011 编辑

CS000809


  • 开发伙伴平台:

S60 3rd Edition

S60 3rd Edition, FP1

S60 3rd Edition, FP2

S60 5th Edition


  • 详细描述

下面的示例代码演示了如何完成一个程序的上下文相关的帮助文档。


注意,为了使用上下文相关的帮助,你需要从Symbian申请一个被保护的UID给帮助文件(如果你使用一个未被保护的UID,那么程序的帮助文件无法从程序中被启动调用),实际程序的UID3并不需要是受保护号,但是帮助文件的UID确实需要是。


这段示例代码可以通过自签名执行(保护号下的帮助文件不会阻止自签名)


  • 步骤

1、生成一个目录,以供帮助文件使用,如help目录

2、使用cshelp2000.dot文件作为模板,写入相关帮助文件(.rtf),这个文件可以在SDK的目录下(C:\Symbian\9.2\S60_3rd_FP1\Epoc32\cshlpcmp_template\cshelp2000.dot)找到。

3、在文本编辑器中打开rtf文件,并删除Word生成的格式化指令。

{\*\wgrffmtfilter XXXX} in Word version 11.8134.8132, 或

{\*\generator Microsoft Word 10.0.6612;} in Word version 10.0.6612.


4、写出如下XML文件(help\help.xml)

<?xml version="1.0" encoding="UTF-8"?>
<?xml:stylesheet href="\epoc32\tools\cshlpcmp\xsl\CSHproj.xsl"
title="CS Help project" type="text/xsl"?>
<!DOCTYPE cshproj SYSTEM "\epoc32\tools\cshlpcmp\dtd\CSHproj.dtd">
 
<cshproj>
<helpfileUID>0x2000E190</helpfileUID> <!-- From help file -->
<directories>
<input></input>
<output></output>
<working></working>
</directories>
<files>
<source>
<file>help.rtf</file>
</source>
<destination>help.hlp</destination>
<customization>custom.xml</customization>
</files>
</cshproj>

5、写出格式描述用的XML文件(help\custom.xml)

<?xml version="1.0"?>
<!DOCTYPE cshcust SYSTEM "\epoc32\tools\cshlpcmp\dtd\CSHcust.dtd">
<?xml:stylesheet href="\epoc32\tools\cshlpcmp\xsl\cshcust.xsl"
title="CS Help customization" type="text/xsl"?>
 
<cshcust>
<parastyle name="body" font="sansserif" size="10"/>
<parastyle name="note" font="sansserif" size="10" left="20">
<b>Note:</b>
</parastyle>
<body style="body"/>
<titlestyle fontstyle="sansserif" size="10"/>
<listbullet1style bulletchar="8226"/>
<listbullet2style bulletchar="8226"/>
<lists leftindent="20"/>
</cshcust>

6、生成makefile(group\help.mk)文件用来编译帮助文件

makmake :
cshlpcmp ..\help\help.xml
 
ifeq (WINS, $(findstring WINS, $(PLATFORM)))
copy ..\help\help.hlp $(EPOCROOT)\epoc32\$(PLATFORM)\c\resource\help
endif
 
 
clean :
del ..\help\help.hlp
del ..\help\help.hlp.hrh
 
bld :
cshlpcmp ..\help\help.xml
 
ifeq (WINS, $(findstring WINS, $(PLATFORM)))
copy ..\help\help.hlp $(EPOCROOT)\epoc32\$(PLATFORM)\c\resource\help
endif
 
 
freeze lib cleanlib final resource savespace releasables :


注意:当编辑makefile文件时,要使用制表符替代空格,否则你会收到“HELP.MK:27: *** missing separator. Stop”错误信息

7、编辑group\bld.inf用来管理makefile文件

#ifdef EKA2 //3rd edition
gnumakefile help.mk
Application_S60_3rd_ed.mmp
#else //1st and 2nd edition
Application_S60_2nd_ed.mmp
#endif


注意:记住编辑完后执行bldmake bldfiles命令


8、增加帮助文件,以及相关库到mmp文件中(group\[app].mmp)

USERINCLUDE       ..\help
 
SOURCEPATH ..\help
DOCUMENT help.rtf
DOCUMENT help.xml
DOCUMENT custom.xml
 
LIBRARY hlplch.lib // help


9、增加.hlp文件到pkg文件中(sis\[app].pkg)

"..\help\help.hlp" - "!:\resource\help\help.hlp"


10、增加帮助命令(EClientHelp)的常量定义到inc\[app].hrh文件中

// Client enumerate command codes
enum TClientIds
{
EClientHelp = 1 // start value must not be 0
};

11、增加UID到inc\[app]Application.h文件中

const TUid KUidHelpFile = {0x2000E190};  // From the help file


12、增加本地化字符串到本地化数据文件(如data\[app]_loc.l01文件):

#define STRING_r_app_options_help  "Help"

13、增加菜单项到程序资源文件(data\[app].rss)的RESOURCE MENU_PANE段中

MENU_ITEM
{
command = EClientHelp;
txt = STRING_r_app_options_help;
}


14、增加与帮助命令到AppUI(src\[app]AppUi.cpp文件)的HandleCommandL函数中:

#include <hlplch.h>  // HlpLauncher
case EClientHelp:
{
CArrayFix <TCoeHelpContext>* buf = CCoeAppUi::AppHelpContextL();
HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), buf);
break;
}


15、重载HelpContextL函数

(inc\[app]AppUi.h文件)

private: // from CAknAppUi
 
/*
* HelpContextL()
*
* Returns the help context for this application
*
* Returns:
* A pointer to the help context
*
*/
CArrayFix<TCoeHelpContext>* HelpContextL() const;


(inc\[app]AppUi.cpp文件)

#include "[app]Application.h"
#include "help.hlp.hrh"
// ----------------------------------------------------------------------------
// CClientAppUi::HelpContextL()
//
// Return the help context for this application.
// ----------------------------------------------------------------------------
CArrayFix <TCoeHelpContext>* CClientAppUi::HelpContextL() const
{
CArrayFixFlat <TCoeHelpContext>* array =
new (ELeave) CArrayFixFlat <TCoeHelpContext>(1);
CleanupStack::PushL(array);
// KContextApplication below should refer to the context declared in
// help.rtf
array->AppendL(TCoeHelpContext(KUidHelpFile, KContextApplication));
CleanupStack::Pop(array);
return array;
}


16、重载GetHelpContext函数

(inc\[app]AppView.h文件中)

public:
 
/**
* From CoeControl
* Identify the help context so that the framework can look up
* the corresponding help topic
*
* @param aContext The help context
*/
void GetHelpContext(TCoeHelpContext& aContext) const;

(src\[app]AppView.cpp文件)

#include "[app]Application.h"
#include "help.hlp.hrh"
// -----------------------------------------------------------------------------
// CClientAppView::GetHelpContext()
// Gets the control's help context.
// -----------------------------------------------------------------------------
 
void CClientAppView::GetHelpContext(TCoeHelpContext& aContext) const
{
// Get the help context for the application
aContext.iMajor = KUidHelpFile;
 
// KContextApplication below should refer to the context declared in
// help.rtf
aContext.iContext = KContextApplication;
}
This page was last modified on 15 December 2011, at 09:11.
37 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×