c# - Richtextbox mousemove event what color the text is -


is there way determine color text in richtextbox using mousemove event? avoid using richtextbox.select because adds little select bar everywhere mouse moves.

private void rtbcomputerstatus_mousemove(object sender, mouseeventargs e) {     int c = rtbcomputerstatus.getcharindexfromposition(new point(e.x, e.y));      rtbcomputerstatus.select(c, 1);      if (rtbcomputerstatus.selectioncolor == color.blue)         rtbcomputerstatus.cursor = cursors.hand;     else         rtbcomputerstatus.cursor = cursors.default; } 

you can try this, modified msdn forum answer of jools, give color of pixel under mouse.

private void rtbcomputerstatus_mousemove(object sender, mouseeventargs e) {     point  cursorpoint = cursor.position;     bitmap bm = new bitmap(1, 1);     graphics g  = graphics.fromimage(bm);     g.copyfromscreen(cursorpoint, new point(), new size(1, 1));     color pixelcolor = bm.getpixel(0, 0);     g.dispose();     bm.dispose();     if (pixelcolor.toargb().equals(color.blue.toargb()))     {         if (rtbcomputerstatus.cursor != cursors.hand)             rtbcomputerstatus.cursor = cursors.hand;     }     else     {         if(rtbcomputerstatus.cursor != cursors.default)             rtbcomputerstatus.cursor = cursors.default;     } } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -