TextBox - 鼠标下的字符 [英] TextBox - Character under Mouse

查看:61
本文介绍了TextBox - 鼠标下的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我希望能够找出鼠标下的角色,因为它是
移动到TextBox上......我在考虑通过

来测量字符串并按照这种方式进行处理。我不相信

这是a)非常可靠,或者b)非常整洁。


任何人都知道这种良好的起点事情是什么?


谢谢


Blu。

解决方案

如果您使用单行文本框,这可能是可行的,你是什么

谈论测量特定字符的字符宽度和

然后看看点是否是在那个区域内。这很容易,如果所有的角色

是相同的,但你已经知道他们不太可能这样你不能

甚至做分工。


根据你要做的事情,是否可以使用一组标签

代表文本框下面的字符用于显示&选择

目的。并使用文本框进行编辑,更改标签集会改变吗?


乱,但可行。


HTH

-


OHM(特里伯恩斯)

。 。 。单手人。 。


当你不知道自己在做什么时,过得很快


" BluDog" <是ne ** @ nospam.bludog.net>在消息中写道

news:f9 ******************************** @ 4ax.com ...



我希望能够找到鼠标下的角色,因为它在TextBox上移动......我在考虑通过测量字符串并以此方式处理它来实现它。我不相信
这是a)非常可靠,或者b)非常整洁。

任何人都知道这种事情有一个很好的起点吗?
<谢谢

Blu。



* BluDog< ne ** @ nospam.bludog.net> scripsit:

我希望能够找到鼠标下的角色,因为它在一个TextBox上移动......我正在考虑通过
测量字符串来解决它并以这种方式解决。我不相信
这是a)非常可靠,或者b)非常整洁。




P /调用''SendMessage''+ ''EM_CHARFROMPOS''。


-

Herfried K. Wagner [MVP]

< URL:http:/ /dotnet.mvps.org/>

< URL:http://dotnet.mvps.org/dotnet/faqs/>


< blockquote>我可能会弄错,但我认为他的意思是从图形的角度来看,

换句话说,如果你在框中有字符串ABCD,他需要

选择说,他正在盘旋的任何特定字母。你的功能会这么做吗?如果是这样的话,我印象深刻,因为我不知道这个功能是否存在,它是什么?b $ b不是大多数人想要的东西吗?


干杯 - OHM


-


OHM(特里伯恩斯)

。 。 。单手人。 。


当你不知道自己在做什么时,过得很快


" Herfried K. Wagner [MVP]" ; <喜*************** @ gmx.at>在消息中写道

news:eG **************** @ TK2MSFTNGP11.phx.gbl ...

* BluDog<是ne ** @ nospam.bludog.net> scripsit:

我希望能够找到鼠标下的角色,因为它在一个TextBox上移动......我正在考虑通过
测量字符串来解决它并以这种方式解决。我不相信这是a)非常可靠,或者b)非常整洁。



调用''SendMessage''+'''EM_CHARFROMPOS' '。

-
Herfried K. Wagner [MVP]
< URL:http://dotnet.mvps.org/>
< URL :http://dotnet.mvps.org/dotnet/faqs/>



Hi

I want to be able to work out the character under the mouse as it
moves over a TextBox... I was thinking about aproaching it by
measuring the string and working it out that way. I am not convinced
this is a) going to be very reliable, or b) very tidy.

Anyone know of a good starting point for this kind of thing?

THanks

Blu.

解决方案

This is probably doable if you are using single line textboxes, what you are
talkin about is measuring the character width for a particular character and
then seeing if the point is within that area. Thats easy if all the chars
are the same, but as you already know they are not likely to be so you cant
even do a division.

Depending on what you wan to do, would it be possible to use a set of labels
which represent the characters underneath the textbox for display & select
purposes. and use the textbox for edit, on change the label sets alters ?

Messy, but workable.

HTH
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don''t know what you''re doing

"BluDog" <ne**@nospam.bludog.net> wrote in message
news:f9********************************@4ax.com...

Hi

I want to be able to work out the character under the mouse as it
moves over a TextBox... I was thinking about aproaching it by
measuring the string and working it out that way. I am not convinced
this is a) going to be very reliable, or b) very tidy.

Anyone know of a good starting point for this kind of thing?

THanks

Blu.



* BluDog <ne**@nospam.bludog.net> scripsit:

I want to be able to work out the character under the mouse as it
moves over a TextBox... I was thinking about aproaching it by
measuring the string and working it out that way. I am not convinced
this is a) going to be very reliable, or b) very tidy.



P/invoke on ''SendMessage'' + ''EM_CHARFROMPOS''.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
<URL:http://dotnet.mvps.org/dotnet/faqs/>


I might be mistaken, but I thought he meant from a graphical point of view,
in other words, if you had the string ABCD in the box, that he needed to
select say, any particular letter he was hovering over. Will your function
do that ?, if so, im impressed as I did not know this function existed, its
not really something most people would want is it ?

Cheers - OHM

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don''t know what you''re doing

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eG****************@TK2MSFTNGP11.phx.gbl...

* BluDog <ne**@nospam.bludog.net> scripsit:

I want to be able to work out the character under the mouse as it
moves over a TextBox... I was thinking about aproaching it by
measuring the string and working it out that way. I am not convinced
this is a) going to be very reliable, or b) very tidy.



P/invoke on ''SendMessage'' + ''EM_CHARFROMPOS''.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
<URL:http://dotnet.mvps.org/dotnet/faqs/>



这篇关于TextBox - 鼠标下的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆