XOR problem
-
hi all, this is my problem i used this code Graphics grfx = this.createGraphics(); grfx.DrawLine(Pens.Black,p1,p2); in the Mouse_Move EventHandler but it draw alot of lines so i want to use XOR mode to draw only the last one thanx in advance Generator
-
hi all, this is my problem i used this code Graphics grfx = this.createGraphics(); grfx.DrawLine(Pens.Black,p1,p2); in the Mouse_Move EventHandler but it draw alot of lines so i want to use XOR mode to draw only the last one thanx in advance Generator
Hi! You could use
ControlPaint.DrawReversibleLine()
to get something like an "XOR" mode. But are you sure you know what you're doing? Usually creating a graphics object in a mouse event handler to do some painting is a bad idea. Do you dispose of every Graphics object you create? Beginners usually forget about it and then get ressource leaks. And what if the surface you're drawing your lines on gets hidden by another window and redrawn? All your lines will be gone...Regards, mav -- Black holes are the places where God divided by 0...
-
Hi! You could use
ControlPaint.DrawReversibleLine()
to get something like an "XOR" mode. But are you sure you know what you're doing? Usually creating a graphics object in a mouse event handler to do some painting is a bad idea. Do you dispose of every Graphics object you create? Beginners usually forget about it and then get ressource leaks. And what if the surface you're drawing your lines on gets hidden by another window and redrawn? All your lines will be gone...Regards, mav -- Black holes are the places where God divided by 0...
hi mav, actually i didnot draw in mouse move i put every drawing in OnPaint() but it make some problems in other parts of code so i decided to draw it in mouse move (iam just trying to solve my problem so i didnot think in Dispose) and thanx for remembering me of Dispose as i think u solve to me the problem of my program stop(Resources leak) thanx again(i will try ControlPaint.DrawReversibleLine()) Generator
-
hi mav, actually i didnot draw in mouse move i put every drawing in OnPaint() but it make some problems in other parts of code so i decided to draw it in mouse move (iam just trying to solve my problem so i didnot think in Dispose) and thanx for remembering me of Dispose as i think u solve to me the problem of my program stop(Resources leak) thanx again(i will try ControlPaint.DrawReversibleLine()) Generator
hi mav, i read about ControlPaint.DrawReversibleLine in MSDN and if my understanding(it deletes the first draw if drawen again by same coordinates) is right so i think it will not be true to use it as i tried it and nothing changed thanx Generator
-
hi mav, i read about ControlPaint.DrawReversibleLine in MSDN and if my understanding(it deletes the first draw if drawen again by same coordinates) is right so i think it will not be true to use it as i tried it and nothing changed thanx Generator
Hi mav, thanx for ur efforts but i think i made actually not good solution but i think it work at this time this is the code(please tell me if any notes) Graphics grfx = this.CreateGraphics(); Pen pen = new Pen(mainScreen.DefaultBackColor); if (counter == 0) { lastPntOfLine = e.Location; counter++; } else grfx.DrawLine(pen, mLineBeginPnt, lastPntOfLine); mLineEndPnt = e.Location; grfx.DrawLine(Pens.Black, mLineBeginPnt, mLineEndPnt); lastPntOfLine = e.Location; grfx.Dispose(); pen.Dispose(); Invalidate(); i felt very stubid to write that but this is my thinking until now Generator