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
Post a Comment