如何将滑鼠锁定在某特定区域!

Drag 2000-08-24 03:13:00
本人在工作中碰上几个问题,不知如何解决!希望能有高手帮助!
(1)怎么样将滑鼠不移入某一矩形区域?
(2)怎么样将所有系统颜色都列在Combobox的下拉框中?

...全文
251 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
wjt 2000-08-31
  • 打赏
  • 举报
回复
var
rtButton: TRect;
begin
try
rtButton := panel1.BoundsRect;
MapWindowPoints(handle, 0, rtButton, 2);
ClipCursor(@rtButton);
......
finally
rtbutton := Rect(0, 0, Screen.Width, Screen.Height);
ClipCursor(@rtbutton);
end;
MarsSoft 2000-08-31
  • 打赏
  • 举报
回复
使用api函数clipcursor可以将鼠标锁定在一定区域里,具体请查win32 SDK吧,对于问题2,你必须将comboBox定义为自绘画控件(在属性里有),然后在每一次的自绘画消息里画你想要的颜色到comboBox里,具体用法参见这个社区里的技术文章<C++ Builder 中的自画功能>吧!
祝你好运
friendkey 2000-08-29
  • 打赏
  • 举报
回复
procedure lmt(rt:trect);
begin
MapWindowPoints(handle, 0, rt, 2); // 座标换算
ClipCursor(@rt); // 限制鼠标移动区域
end;
guoyuzhang 2000-08-28
  • 打赏
  • 举报
回复
举一个例子,将鼠标锁定在button1中.
var
myrect:TRect;
begin
myrect:=button1.boundsRect;(好像是)
mapwindowpoints(hand,myrect,2);
clipcursor(@myrect);
end;
jumphigh 2000-08-27
  • 打赏
  • 举报
回复
//颜色存贮用下面的api

form1.color:=GetSysColor(索引值);


The GetSysColor function retrieves the current color of the specified display element. Display elements are the parts of a window and the Windows display that appear on the system display screen.

DWORD GetSysColor(

int nIndex // display element
);


Parameters

nIndex

Specifies the display element whose color is to be retrieved. This parameter must be one of the following values:

Value Meaning
COLOR_3DDKSHADOW Dark shadow for three-dimensional display elements.
COLOR_3DFACE,
COLOR_BTNFACE Face color for three-dimensional display elements.
COLOR_3DHILIGHT, COLOR_3DHIGHLIGHT, COLOR_BTNHILIGHT, COLOR_BTNHIGHLIGHT Highlight color for three-dimensional display elements (for edges facing the light source.)
COLOR_3DLIGHT Light color for three-dimensional display elements (for edges facing the light source.)
COLOR_3DSHADOW, COLOR_BTNSHADOW Shadow color for three-dimensional display elements (for edges facing away from the light source).
COLOR_ACTIVEBORDER Active window border.
COLOR_ACTIVECAPTION Active window caption.
COLOR_APPWORKSPACE Background color of multiple document interface (MDI) applications.
COLOR_BACKGROUND, COLOR_DESKTOP Desktop.
COLOR_BTNTEXT Text on push buttons.
COLOR_CAPTIONTEXT Text in caption, size box, and scroll bar arrow box.
COLOR_GRAYTEXT Grayed (disabled) text. This color is set to 0 if the current display driver does not support a solid gray color.
COLOR_HIGHLIGHT Item(s) selected in a control.
COLOR_HIGHLIGHTTEXT Text of item(s) selected in a control.
COLOR_INACTIVEBORDER Inactive window border.
COLOR_INACTIVECAPTION Inactive window caption.
COLOR_INACTIVECAPTIONTEXT Color of text in an inactive caption.
COLOR_INFOBK Background color for tooltip controls.
COLOR_INFOTEXT Text color for tooltip controls.
COLOR_MENU Menu background.
COLOR_MENUTEXT Text in menus.
COLOR_SCROLLBAR Scroll bar gray area.
COLOR_WINDOW Window background.
COLOR_WINDOWFRAME Window frame.
COLOR_WINDOWTEXT Text in windows.


Return Values

If the function succeeds, the return value is the red, green, blue (RGB) color value that specifies the color of the given element.

Remarks

System colors for monochrome displays are usually interpreted as shades of gray.
jumphigh 2000-08-27
  • 打赏
  • 举报
回复

var
r:trect;
begin
r.left:=100;
...
r.bottom:=100;
mapwindowpoints(hand,0,r,2); //将坐标转为屏幕坐标
clipcursor(@r);
end;


yinfudan 2000-08-27
  • 打赏
  • 举报
回复
Nicrosoft 说的很对
Michaelyfj 说的不对

不过,别忘了分一点分给我.我还可以提供源代码.
yinfudan@yahoo.com

Putao 2000-08-25
  • 打赏
  • 举报
回复
有一个鼠标api可以实现,具体名字忘了,你来信吧.
--joft@126.com
Michaelyfj 2000-08-24
  • 打赏
  • 举报
回复
用API函数ShowCursor(boolean)
如:
var
R : TRect;
pt : TPoint; //鼠标当前点
begin
R.Left := 100;
R.Top := 100;
R.Right := 200;
R.Bottom := 200;
if ptInRect(R, pt) then
showCursor(False)
else showCursor(True);
end;
Nicrosoft 2000-08-24
  • 打赏
  • 举报
回复
1.用API函数ClipCursor就可以了。传一个Rect类型的变量给他。

Rect类型需要声明

如:
dim R as Rect
R.left=100
R.right=200
R.Top=100
R.Button=200
ClipCursor(R)

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧