c# - .NET UserControl: Size property gives incorrect value on Resize event -


Sorry for the code dump, these are user control functions

  Private Zero PNGQuantPreviewControl_Resize ( Object sender, event ergres e) {createOffScreenBm (); Attract (); } Private Zero Making OffscreenBM () {offScreenBm = New Bitmap (This size, size, height, height); OffScreenGfx = Graphics.Fremight (OffscreenBM); } Private Zero Draw () {// Screenshots from the background. Filarentengel (transcrichers, 0, 0, offscreenbm. Wide, offscreenbm. High); // Skip Image PreviewScreen Gifs. Dowmage (PNG QuotePreview, getTopLeftPosition ()); // Apply to this photo box. Craigsfix (). Drymaz (OffscreenBM, 0, 0); }  

Therefore, when the control size changes, it rebuilds offscreen bitmaps to reflect the new shape and redraws the image.

However, if I quickly change the size of the control bitmap does not fill it, there is a difference between right and / or bottom.

I am quite new to C #, so maybe there is something obvious that I am doing wrong, or do I have any ideas to read the values ​​of size at the wrong time?

Firstly you need to overwrite the OnPaint method, or subscribe to the paint event and everything Dragging

Secondly, you do not need to create an offscreen bitmap for double buffering, because for the same purposes already in the client .net

and third, UserControl is undoubtedly And enable internal net buffering, something like this:

  public user control 2 {set CTT (ControlStyle Optimized WWuffer | ControlStyle.All Paging IncomePC | ControlStyle. UserPaint, True); }  

Using this approach you will get double-buffering, and you only have to draw your graphics in the OnPaint method. You can read more about it in MSDN.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -