Delphi 2009アプリケーションで状況依存ヘルプを実装しています。 1つのケースを除いて正常に動作します。私はメインメニューにあり、どのメニュー項目が開いているのか分かりません。ユーザーは、[ファイル]メニューを開いているし、そのオープンプレスF1ながら、その後、私は、[ファイル]メニューの[私の助けを持っていきます場合、私は何をしたいのかどのメニューアイテムがDelphiで開いているかをどのように教えていますか?
です。彼らは、[編集]メニューを開いてF1キーを押す場合は、その後、私は、[編集]メニューの[私の助けを持っていき、など
次のように私は、ユーザーのF1キーを押すのを処理するためにApplicationEventsHelpを使用しています:
function MainForm.ApplicationEvents1Help(Command: Word; Data: Integer;
var CallHelp: Boolean): Boolean;
begin
if Command = HELP_COMMAND then begin
Application.HelpSystem.ShowTopicHelp(PChar(Data), Application.CurrentHelpFile);
CallHelp := false;
end;
Result := true;
end;
を私が言及したように、これはメインメニューを除くすべてのために働く。私は、彼らがメニューを同定するかどうかを確認するために、アクティブ制御を識別
FindVCLWindow(Mouse.CursorPos)
および他のそのような方法を使用して試してみたが、彼らはしていないようです。
F1キーを押したときに開いているメニュー項目(ある場合)を知る方法はありますか?
ご協力いただきありがとうございました。
私の最終的な解決策を文書化するだけで、システムはそれがどのコントロールであるかを判断することに特に優れていないことが判明し、不適切なデータをApplicationEventsHelpに渡して不適切なヘルプページを表示します。
受け入れられた回答のメニューを処理するためのソリューションを試して使用した後、正しいヘルプ項目を表示するためにどのコントロールを使用したのかを特定するのが最善であることがわかりました。私はHelpKeywordプロパティを使用せず、ハードコーディングしました。コードは明確で、動作します。また、私のRVEditウィンドウのヘルプを持って、あなたがいるドキュメントのセクションに応じて別のヘルプページを表示します(私のCurCursorIDはそれを教えてくれます)。私は正しいように私の7つのメインメニューでのMenuItemのHelpContextプロパティに17を介して11を入れなければならなかったの
function TLogoAppForm.ApplicationEvents1Help(Command: Word; Data: Integer;
var CallHelp: Boolean): Boolean;
var
HelpKeyword: string;
SType: string;
begin
if Command = HELP_COMMAND then begin
if PtInRect(RVEdit.ClientRect, RVEdit.ScreenToClient(Mouse.CursorPos)) then begin
if CurCursorID = 'H' then HelpKeyword := 'RefTopReport'
else if CurCursorID = 'T' then HelpKeyword := 'RefTableContents'
else if CurCursorID = '~HNAME' then HelpKeyword := 'RefIndexNames'
else if copy(CurCursorID, 1, 2) = 'N+' then HelpKeyword := 'RefIndexNames'
else if CurCursorID = 'B' then HelpKeyword := 'RefBottomReport'
else if CurCursorID <> '' then HelpKeyword := 'RefInformationArea'
else HelpKeyword := 'RefEverythingReport';
Application.HelpSystem.ShowTopicHelp(HelpKeyword, Application.CurrentHelpFile);
end
else if PtInRect(ElTree.ClientRect, ElTree.ScreenToClient(Mouse.CursorPos)) then
Application.HelpSystem.ShowTopicHelp('RefTreeView', Application.CurrentHelpFile)
else if PtInRect(TopToolbar.ClientRect, TopToolbar.ScreenToClient(Mouse.CursorPos)) then
Application.HelpSystem.ShowTopicHelp('RefTopToolbar', Application.CurrentHelpFile)
else if PtInRect(BottomToolbar.ClientRect, BottomToolbar.ScreenToClient(Mouse.CursorPos)) then
Application.HelpSystem.ShowTopicHelp('RefBottomToolbar', Application.CurrentHelpFile)
else
Application.HelpSystem.ShowTopicHelp('RefMainWindow', Application.CurrentHelpFile);
CallHelp := false;
end
else if Command = HELP_CONTEXTPOPUP then begin
case Data of
0: HelpKeyword := 'RefMenuBar';
11: HelpKeyword := 'RefFileMenu';
12: HelpKeyword := 'RefEditMenu';
13: HelpKeyword := 'RefSearchMenu';
14: HelpKeyword := 'RefNavigateMenu';
15: HelpKeyword := 'RefViewMenu';
16: HelpKeyword := 'RefOrganizeMenu';
17: HelpKeyword := 'RefHelpMenu';
else HelpKeyword := '';
end;
if HelpKeyword <> '' then begin
Application.HelpSystem.ShowTopicHelp(HelpKeyword, Application.CurrentHelpFile);
CallHelp := false;
end;
end;
Result := true;
end;
:私はここに、行ったようにこれをしたい人のため
はどのようにありますあなたがいたメニューに応じてヘルプが表示されます。メニュー項目の検出は、この質問への回答が私に提供された助けとなります。
このコードは、(HelpContext番号の代わりにHelpKeywordsを使用して)簡単に実行でき、Delphi XEおよびFireMonkeyに変換した後でも機能しているというのがうれしいことです。
:あなたは
HelpContext
プロパティを使用するためにバインドされているので、(ここではデルファイ7で)メニュー項目は、
HelpType
とHelpKeyword
特性を有していません。 FindVCLControlは使用しないでください。コントロールとアクションのためのHelpContextを設定します。それだけです。 –@David - FindVCLControlは私がkludgeとして働くと思った1つのアイデアでした。私はそのアプローチに満足していなかったし、それはとにかく動作しませんでした - それが私がこの質問をした理由です。答えは – lkessler