- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们的 VCL Delphi 应用程序有许多网格,我们需要开始通过 UIAutomation 与之交互。存在许多问题,尤其是 TStringGrid 没有实现任何 IUIAutomation 模式(IGridProvider 或 ITableProvider,甚至 IValueProvider)。
我试图找出需要添加到 TStringGrid 中的内容,以允许它实现提供程序(位于 .NET 中的 System.Windows.Automation.Provider 命名空间中)。
最佳答案
这是我的步骤...
(实际文件太大,无法全部发布,因此这是要点的精炼)。
另外 - 这仍然存在重大问题,可能是我自己造成的,但这足以让我取得进展。
function UiaHostProviderFromHwnd(hwnd: HWND; provider: IRawElementProviderSimple): LRESULT; stdcall; external 'UIAutomationCore.dll' name 'UiaHostProviderFromHwnd';
function UiaReturnRawElementProvider(hwnd: HWND; wParam: WPARAM; lParam: LPARAM; element : IRawElementProviderSimple) : LRESULT; stdcall; external 'UIAutomationCore.dll' name 'UiaReturnRawElementProvider';
<ol start="5">
<li>The component needs to implement the IRawElementProviderSimple interface, as well as any other providers - in the example case I have used ISelectionProvide, in order to illustrate what I did.</li>
</ol>
<pre> // IRawElementProviderSimple
function Get_ProviderOptions(out pRetVal: ProviderOptions): HResult; stdcall;
function GetPatternProvider(patternId: SYSINT; out pRetVal: IUnknown): HResult; stdcall;
function GetPropertyValue(propertyId: SYSINT; out pRetVal: OleVariant): HResult; stdcall;
function Get_HostRawElementProvider(out pRetVal: IRawElementProviderSimple): HResult; stdcall;
// ISelectionProvider
function GetSelection(out pRetVal: PSafeArray): HResult; stdcall;
function Get_CanSelectMultiple(out pRetVal: Integer): HResult; stdcall;
function Get_IsSelectionRequired(out pRetVal: Integer): HResult; stdcall;
</pre>
<p>These are implemented as follows ..</p>
<pre>function TAutomationStringGrid.Get_ProviderOptions(
out pRetVal: ProviderOptions): HResult;
begin
pRetVal:= ProviderOptions_ClientSideProvider;
Result := S_OK;
end;
function TAutomationStringGrid.GetPatternProvider(patternId: SYSINT;
out pRetVal: IInterface): HResult;
begin
pRetval := nil;
if (patternID = UIA_SelectionPatternId) then
begin
result := QueryInterface(ISelectionProvider, pRetVal);
end
else
result := S_OK;
end;
function TAutomationStringGrid.GetPropertyValue(propertyId: SYSINT;
out pRetVal: OleVariant): HResult;
begin
if(propertyId = UIA_ControlTypePropertyId) then
begin
TVarData(pRetVal).VType := varWord;
TVarData(pRetVal).VWord := UIA_DataGridControlTypeId;
end;
result := S_OK;
end;
function TAutomationStringGrid.Get_HostRawElementProvider(
out pRetVal: IRawElementProviderSimple): HResult;
begin
result := UiaHostProviderFromHwnd (self.Handle, pRetVal);
end;
function TAutomationStringGrid.GetSelection(out pRetVal: PSafeArray): HResult;
begin
end;
function TAutomationStringGrid.Get_CanSelectMultiple(
out pRetVal: Integer): HResult;
begin
end;
function TAutomationStringGrid.Get_IsSelectionRequired(
out pRetVal: Integer): HResult;
begin
end;
</pre>
<p>In order to actually get the control, the WM_GETOBJECT message needs to be handled ...</p>
<pre> procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT;
</pre>
<p>This is implemented as follows ..</p>
procedure TAutomationStringGrid.WMGetObject(var Message: TMessage);
begin
if (Message.Msg = WM_GETOBJECT) then
begin
QueryInterface(IID_IRawElementProviderSimple, FRawElementProviderSimple);
message.Result := UiaReturnRawElementProvider(self.Handle, Message.WParam, Message.LParam, FRawElementProviderSimple);
end
else
Message.Result := DefWindowProc(self.Handle, Message.Msg, Message.WParam, Message.LParam);
end;
关于delphi - 将 UIAutomation Provider 添加到 Delphi 控件(特别是网格),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29841789/
我已经可以在其中输入一些附加文本了mydomain/wiki/Special:UserLogin。我添加了一句话: In order to apply for an account send an m
有人可以解释以下脚本输出背后的逻辑吗? import numpy if(numpy.dtype(numpy.float64) == None): print "Surprise!!!!" 谢谢
是我还是 gmail bulls**t?在 outlook/浏览器上,我的电子邮件是完美的,但在 gmail 上,2 个表之间有一个空间,为什么?!?图片:http://i.imgur.com/srJ
我是一名优秀的程序员,十分优秀!