如何向其他程序中的toolbar中ToolButton发送点击按钮??? Delphi / Windows SDK/APIhttp://www.delphi2007.net/DelphiAPI/html/delphi_20061112160354251.html
可以找到toolbar的句柄,
在Toolbar中的按扭也没有句柄,
请问如向ToolButton中ToolButton发送点击按钮?
大家请帮帮忙,谢谢!!!
什么现在还没有人回复我!!!
//测试如下代码
uses CommCtrl, Types;
procedure TForm1.Button1Click(Sender: TObject);
var
vHandle: THandle;
vIndex: Integer;
vRect: TRect;
vProcessId: DWORD;
vProcess: THandle;
vPointer: Pointer;
vNumberOfBytesRead: Cardinal;
begin
vHandle := ToolBar1.Handle; // 改写为其他进程ToolBar句柄
vIndex := 0; // 按钮序号
GetWindowThreadProcessId(vHandle, @vProcessId);
vProcess := OpenProcess(PROCESS_VM_OPERATION or PROCESS_VM_READ or
PROCESS_VM_WRITE, False, vProcessId);
vPointer := VirtualAllocEx(vProcess, nil, $1000, MEM_RESERVE or MEM_COMMIT,
PAGE_READWRITE);
try
SendMessage(vHandle, TB_GETITEMRECT, vIndex, Integer(vPointer));
ReadProcessMemory(vProcess, vPointer, @vRect, SizeOf(TRect),
vNumberOfBytesRead);
finally
VirtualFreeEx(vProcess, vPointer, 0, MEM_RELEASE);
CloseHandle(vProcess);
end;
SendMessage(vHandle, WM_LBUTTONDOWN, MK_LBUTTON,
Longint(PointToSmallPoint(CenterPoint(vRect))));
SendMessage(vHandle, WM_LBUTTONUP, MK_LBUTTON,
Longint(PointToSmallPoint(CenterPoint(vRect))));
end;