使用代码寻找MDI程序的模式窗口(100分)

  • 主题发起人 主题发起人 kanbor
  • 开始时间 开始时间
K

kanbor

Unregistered / Unconfirmed
GUEST, unregistred user!
我在实现帮助功能时的问题,比如:<br>MDI程序中运行到一个模式窗口,我按下“F1”寻求帮助,我在系统中注册了一个热键,并捕捉热键的功能:<br>procedure TMainFm.HotKeyDown(var Msg: Tmessage);<br>var<br>&nbsp; s: string;<br>begin<br>&nbsp; //如果是模式窗口<br>&nbsp; // ???????<br><br>&nbsp; <br>&nbsp; // 如果是MDI子窗口<br>&nbsp; if Application.Active and<br>&nbsp; &nbsp; (Msg.LparamLo = 0) and (Msg.LParamHi = VK_F1) then // 假设热键为F1<br>&nbsp; begin<br>&nbsp; &nbsp; s := ActiveMDIChild.Caption + '.htm';<br>&nbsp; &nbsp; ShowChmHelp(s);<br>&nbsp; end;<br>end;<br>上面的模式窗口现在实现不了,请高手帮忙。
 
模式窗口窗口运行时是不是已经阻塞了主窗口?这样的话也就是说 在模式窗口运行时 procedure TMainFm.HotKeyDown(var Msg: Tmessage);<br>这个过程根本就没运行。没试过,猜的。
 
在TMainFm窗体中放入TApplicationEvents组件<br>使用ONShortCut事件<br>你可以使用下面代码了解窗体状态<br>procedure TMainFm.ApplicationEvents1ShortCut(var Msg: TWMKey;<br>&nbsp; var Handled: Boolean);<br>var i:integer;<br>&nbsp; s:string;<br>begin<br>if msg.CharCode = VK_F1 then<br>begin<br>s:='';<br>for i:=0 to application.ComponentCount -1 do<br>&nbsp; if application.Components is Tform then<br>&nbsp; &nbsp; if Tform(application.Components).Active then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; s:=s+Tform(application.Components).Caption;<br>&nbsp; &nbsp; &nbsp; if fsModal in Tform(application.Components).FormState then<br>&nbsp; &nbsp; &nbsp; &nbsp; s:=s+'[fsModal]';<br>&nbsp; &nbsp; &nbsp; if fsCreatedMDIChild in Tform(application.Components).FormState then<br>&nbsp; &nbsp; &nbsp; &nbsp; s:=s+'[fsCreatedMDIChild]';<br>&nbsp; &nbsp; &nbsp; self.Caption :=s;<br><br>&nbsp; &nbsp; &nbsp; //break;<br>&nbsp; &nbsp; end;<br>end;<br>end;
 
用了别的办法来解决这个问题,谢谢参与!
 
后退
顶部