全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1370
推到 Plurk!
推到 Facebook!

请高手帮忙--关于BCB调用帮助--WM_HELP的问题

尚未結案
yinjiajun
一般會員


發表:4
回覆:14
積分:3
註冊:2005-02-02

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-08-11 13:42:55 IP:211.162.xxx.xxx 未訂閱
由于BCB和Delphi默认都只支持很旧的Windows Help,不支持新的CHM Help,为了能在我的程序中使用CHM格式的Help,我先使用implib hhctrl.lib hhctrl.ocx(这个文件安装在%system32%中)把这个lib拷贝到我的工程文件夹;然后安装了MS的Windows Html Help WorkShop软件,把它的htmlhelp.h拷贝到我的工程文件夹。 然后,在我的工程中添加hhctrl.lib,只要#include <htmlhelp.h>,那么,就可以使用CHM系列帮助的API了。 我发现:当窗体上某一控件(已设置HelpContext)获取焦点时,按F1键时,TApplication的OnHelp事件根本就不执行,因此我只有截取系统的WM_HELP消息了,如下: //.h文件中 protected: BEGIN_MESSAGE_MAP VCL_MESSAGE_HANDLER(WM_HELP, Messages::TMessage, MyWinHelp) END_MESSAGE_MAP(TForm) void __fastcall MyWinHelp(Messages::TMessage &Message); //.cpp文件中 void __fastcall TMainForm::MyWinHelp(Messages::TMessage &Message) { HELPINFO *HI = (HELPINFO*)Message.LParam; HtmlHelp(Application->Handle,(ExtractFilePath(Application->ExeName) "Help.chm").c_str(),HH_HELP_CONTEXT,HI->dwContextId); } 我理解错误,我以为WM_HELP消息的LParam(是LPHELPINFO类型的指针)中的dwContextID就是当前焦点处的控件上设置的HelpContext的值,但是事实上不是,我跟踪过,它的值一直是0。 那么,解决问题的办法就只有一种了,就是通过LParam(LPHELPINFO类型指针)的hItemHandle成员来获取这个控件的HelpContext了,那么,请教:如何通过一个控件句柄获得一个TComponent(子类)类型的这个控件?
yinjiajun
一般會員


發表:4
回覆:14
積分:3
註冊:2005-02-02

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-08-11 13:49:24 IP:211.162.xxx.xxx 未訂閱
附: (1)HELPINFO The HELPINFO structure contains information about an item for which context-sensitive help has been requested. typedef struct tagHELPINFO { // hi UINT cbSize; int iContextType int iCtrlId; HANDLE hItemHandle; DWORD dwContextId; POINT MousePos; } HELPINFO, FAR *LPHELPINFO; Members cbSize Specifies the structure size, in bytes. iContextType Specifies the type of context for which help is requested. This member can be one of the following values: Value Meaning HELPINFO_MENUITEM Help requested for a menu item HELPINFO_WINDOW Help requested for a control or window iCtrlId Specifies the identifier of the window or control if iContextType is HELPINFO_WINDOW. Specifies the identifier of the menu item if iContextType is HELPINFO_MENUITEM. hItemHandle Identifies the child window or control if iContextType is HELPINFO_WINDOW. Identifies the associated menu if iContextType is HELPINFO_MENUITEM. dwContextId Specifies the help context identifier of the window or control. MousePos Specifies a POINT structure that contains the screen coordinates of the mouse cursor. This is useful for providing help based on the position of the mouse cursor. (2)WM_HELP The WM_HELP message indicates that the user pressed the F1 key. If a menu is active when F1 is pressed, WM_HELP is sent to the window associated with the menu; otherwise, WM_HELP is sent to the window that has the keyboard focus. If no Window has the keyboard focus, WM_HELP is sent to the currently active window. WM_HELP lphi = (LPHELPINFO) lParam; Parameters lphi Pointer to a HELPINFO structure that contains information about the menu item, control, dialog box, or window for which help is requested. Return Values Returns TRUE. Remarks The DefWindowProc function passes WM_HELP to the parent window of a child window or to the owner of a top-level window.
系統時間:2024-04-19 19:52:02
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!