导航:
论坛 -> DELPHI技术
斑竹:liumazi,sephil
作者:
2003/12/19 15:31:15
标题:
加入我的收藏
楼主:
如何让自己的程序,有和QQ哪样的拖放效果呢? 把窗体拖到屏幕边上时能自动消失,鼠标移过去时显示? 还有如何响应键盘上的方向键(上下左右键)?
----------------------------------------------
-
作者:
2003/12/19 18:17:45
1楼:
怎么没人回呀!
----------------------------------------------
-
作者:
bios (阿贡)
★☆☆☆☆
-
盒子中级会员
2003/12/19 21:29:20
2楼:
偶在复习 多媒体 准备考试 人懒惰了 所以没回答嘛 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls; const WM_SNAPHOTKEY2=WM_USER + 102; WM_SNAPHOTKEY3=WM_USER + 103; WM_SNAPHOTKEY4=WM_USER + 104; WM_SNAPHOTKEY5=WM_USER + 105; type TForm1 = class(TForm) Timer1: TTimer; procedure FormDestroy(Sender: TObject); procedure FormShow(Sender: TObject); procedure Timer1Timer(Sender: TObject); private { Private declarations } procedure ONHotkey(var message:Tmessage);message WM_HOTKEY; public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.ONHotkey(var message:Tmessage); begin case message.WParam of WM_SNAPHOTKEY2:showmessage('左'); WM_SNAPHOTKEY3 :showmessage('右'); WM_SNAPHOTKEY4 :showmessage('下'); WM_SNAPHOTKEY5 :showmessage('上'); end; end; procedure TForm1.FormDestroy(Sender: TObject); begin UnregisterHotKey(Handle,WM_SNAPHOTKEY2); UnregisterHotKey(Handle,WM_SNAPHOTKEY3); UnregisterHotKey(Handle,WM_SNAPHOTKEY4); UnregisterHotKey(Handle,WM_SNAPHOTKEY5); end; procedure TForm1.FormShow(Sender: TObject); begin RegisterHotKey(Handle,WM_SNAPHOTKEY2,0 , VK_LEFT); RegisterHotKey(Handle,WM_SNAPHOTKEY3,0 , VK_RIGHT); RegisterHotKey(Handle,WM_SNAPHOTKEY4,0 , VK_DOWN); RegisterHotKey(Handle,WM_SNAPHOTKEY5,0 , VK_UP); end; procedure TForm1.Timer1Timer(Sender: TObject); var ppt:TPoint; begin GetCursorPos(ppt); if (ppt.X >=Left ) and(ppt.X <=Left+Width ) then begin//-1 if top<0 then begin//1 top:=-(Height-1); end;//1 if top>1 then exit; if ppt.y < top+height then begin//2 top:=1; end//2 else begin//3 top:=-(Height-1); exit; end;//3 end;//-1 end; end.
----------------------------------------------
作者:
crazy (疯子)
★☆☆☆☆
-
盒子活跃会员
2003/12/20 0:36:17
3楼:
可以用判断当前窗体在何位置的方法也可以达到
----------------------------------------------
春花秋月何時了 往事知多少 小樓昨夜又東風
作者:
2003/12/24 14:34:19
4楼:
我想的是用hook 判断,是否在屏幕边上,来决定是否显示,不过不知道怎么写!
----------------------------------------------
-
作者:
2003/12/24 14:38:42
5楼:
而3楼的,说的也无不可,不过在运行其他程序时呢? 自己的程序还是不能捕获message嘛!
----------------------------------------------
-
作者:
bios (阿贡)
★☆☆☆☆
-
盒子中级会员
2003/12/24 14:45:01
6楼:
如果要 捕获 MESSAGE 偶是不会 但偶这个自己都在用 没问题 能解决的简单 尽量简单 无须那么专业和复杂 !
----------------------------------------------