While we appreciate comments from our users, please follow our posting guidelines. Have you tried the Cyotek Forums for support from Cyotek and the community?
Styling with Markdown is supported
25 May 2014 Reply
This can we call quick answer :-) thank you!
I should been happy to ask my question on forum, if I just found it... but not managed..
The scenario is in short:
I have a bitmap, ca. 2000 pixel wide. I need to show about 200 pixel wide part of it, which I managed. I need to simple edit some pixels by mouse click, managed as well. (using indexed bitmaps)
I have a List, which contains simple line numbers in the bitmap, and I have to mark a selected line on the imagebox without reflecting it in the origan bitmap. So, I created a Graphics object, drwing the line, but the line just shown up, and disappear. I realized, disappear because lost the focus. I do not use any Paint or OnPanint event.
You mention that the control invalidated, when loose the focus. If it does, then I understand, why my lines disappear. But is there any way, to prevent the imageBox to be invalidated?
Thanks a lot.
26 May 2014 Reply
You can't stop the ImageBox from invalidating itself, if you do then it won't update at all. For example, panning or zooming will invalidate the control, even just moving another window in front of the control will cause parts of it to be repainted, that's the way Windows works. The ImageBox isn't a VB6 AutoRedraw PictureBox :)
You will need to hook into the paint chain, otherwise it's going to be impossible to keep your custom drawing available. Try to ensure that any slow code is performed only once (for example selecting an item in the List you mentioned) and then hook the Paint event and perform your custom painting on the Graphics object passed to this event. Then you can be sure that your custom code will always be executed whenever the control paints itself, regardless of what caused the control to be invalidated.