procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button=mbright then
begin
//do you want
//Edit1.text:='1';
end;
end;
Shift: TShiftState; X, Y: Integer);
begin
if Button=mbright then
begin
//do you want
//Edit1.text:='1';
end;
end;
解决方案 »
- 有关一个数据上传和下载的问题~~~~
- 用DELPHI如何调用的DLL
- 简单问题:窗体不能用鼠标改变其大小??怎么设置属性?
- 各位老大:在哪能找到fastreport的中文详细说明? 最好有例子
- IntraWeb/EWF/Asp.Net,你都用哪个?why?
- 在ACCESS中,我想每新增一条记录,记录前有一ID值就自动加一,应该怎么做?
- 大家来看看,100分,这个问题不难!
- delphi SQL输入数据类型是货币型,默认为RMB,如何输入$
- 急急急急!!!UDP的返回信息(对方为未运行通信程序时)
- QQ木马的代码公布,很简单,希望高手能把他更完善!
- 我想得到网络驱动器的 UNC路 径(“ \\服 务 器 \共 享 路 径 ”) ,如何做???
- 向真正的高手请教:如何限制上网(IE浏览、QQ、……),只有满足权限的用户才能?
别人说的是窗体外,也就是他的应用程序范围之外,你的方法行不通
你可以写一个系统Hook,挂钩Mouse事件,当发生右键单击的时候后,先给你的窗体的这个Edit法更新消息,然后在处理系统缺省事件
var
CurPoint:TPoint;
Left,Top:integer;
Button: TMouseButton;
begin
if Button=mbright then
begin
GetCursorPos(CurPoint);
form1.caption:='('+inttostr(CurPoint.x)
+','+inttostr(CurPoint.y)+')';
......
end;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer)
begin
if Mouse->Capture=Handle then
begin
Mouse.Capture = NULL;
if Button=mbRight then
Edit1.Text := 'RightMouseDown';
end;
end;如果上面的方法不能满足你的需求,就要考虑用钩子函数了。
怎么个不正常,将相关的代码贴出来,帮你分析一下,或将测试程序发到
[email protected]
这就是报的错!procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Mouse.Capture=Handle then
begin
Mouse.Capture := NULL;
if Button=mbRight then
Edit1.Text := 'RightMouseDown';
end;
end;不管我有没有先给Mouse.Capture:=Handle都一样抱的错
数(需要写成DLL)。而要写例子,我是用C++Builder的,又不会用Delphi写
(只能看和简单的Delphi代码编写),所以至今没有再帮你。在没有人帮你
的情况下,我只能将我的C++Builder写的代码给你啦,你自己将下面的代码翻
译成Delphi就是了。下面是DLL的源程序代码:HHOOK hHook = NULL;
HWND hWindow = NULL;
HINSTANCE hDllIns = NULL;int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
if (reason==DLL_PROCESS_ATTACH)
hDllIns = hinst;
if (reason==DLL_PROCESS_DETACH) {
if (hHook != NULL)
UnhookWindowsHookEx(hHook);
}
return 1;
}
//---------------------------------------------------------------
LRESULT CALLBACK HookProc(int code, WPARAM wParam, LPARAM lParam)
{
AnsiString str;
EVENTMSG* pMsg; pMsg = (EVENTMSG*)lParam;
if (code==HC_ACTION && pMsg->message==
WM_RBUTTONDOWN && hWindow!=NULL) {
str = AnsiString("Mouse -- (") +
LOWORD(pMsg->paramH) + ',' +
HIWORD(pMsg->paramH) + ')';
SetWindowText(hWindow, str.c_str());
}
return CallNextHookEx(hHook, code, wParam, lParam);
}__declspec(dllexport) BOOL __stdcall SetHook(HWND hWnd, BOOL load)
{
if (load) {
hWindow = hWnd;
if (hHook == NULL)
hHook = SetWindowsHookEx(
WH_JOURNALRECORD, (HOOKPROC)
HookProc, (HINSTANCE)HInstance, 0);
return hHook != NULL;
}
else {
if (hHook && UnhookWindowsHookEx(hHook))
hHook = NULL;
return hHook == NULL;
}
}在你的EXE程序里,调用DLL的函数SetHook,其中的参数 hWnd 是Edit的窗
口句柄。这样当用户在任何地方按下鼠标右键时,都会在Edit里显示"Mouse
-- (X,Y)"这样的文字。