读书人

急 ! ! ! ! ! ! ! !请问关于d

发布时间: 2012-02-09 18:22:27 作者: rapoo

急! ! !急! ! !急! ! !急! ! !:请教关于dbgrid和webbrowser的焦点问题
在一窗体中有一dbgrid和webbrowser, 在webbrowser载入一个页面后,载入的页面也没有连接,鼠标在webbrowser上随便点几下,然后再回点dbgrid,此时dbgrid的单击双击事件都不会执行,整行选中状态也不会显示。

 如果再点击了两外的控件,如treeview or text等,再回点dbgrid就可以了。为什么会是这样了?如何可以保持dbgrid中的一条记录保持选中状态下的高亮形式,并且点击webbrowser之后,再回点dbgrid单击和双击事件都能执行。
 在线等待。分不够,可以再开贴给分。
 详细一些最好,要不给个能实际实现功能的具体方法也行。


[解决办法]
Query.Locate('字段名称',Trim(Edit1.Text),[loCaseInsensitive ,loPartialKey]); 这样写就可以了

[解决办法]
于焦,有很好的解法。
,是一vcl的bug。
其他winControl移到webbrowser,行focusControl作,但我的是web的元素,focus失,整程就停止在里。所以后之前有焦的wincontrol送cm_exit消息也行,onexit事件也就不被了。正常,只要焦有正常切,onexit都被的。

一的解法是,在webbrowser.onStatusTextChange里

Delphi(Pascal) code
  if ActiveControl<>Sender then    ActiveControl := nil;
[解决办法]
由于原先activeControl有切成功,所以是保留上次的有焦的wincontrol。你想操作wincontrol,VCL就,control已有焦了,后作就不行了(window.setfocus),就使得很多消息法接收(如鼠消息,消息)。
[解决办法]
合一下VCL就更清楚了
Delphi(Pascal) code
procedure TCustomForm.SetActiveControl(Control: TWinControl);begin  if FActiveControl <> Control then  begin    if not ((Control = nil) or (Control <> Self) and      (GetParentForm(Control) = Self) and ((csLoading in ComponentState) or        Control.CanFocus)) then      raise EInvalidOperation.Create(SCannotFocus);    FActiveControl := Control;    if not (csLoading in ComponentState) then    begin      if FActive then SetWindowFocus;      ActiveChanged;    end;  end;end; 

读书人网 >.NET

热点推荐