I'm not sure exactly what you are looking for but you can fill rectangles with semi-transparent colors by using the Color.FromARGB function, specifying a value from 0 to 255 for opacity, red, green and blue values and then call Graphics.FillRectangle using a SolidBrush created from your ARGB color.
'I haven't tested this code Dim MyBrush AsNew SolidBrush(Color.FromARGB(128, 0, 0, 255)) MyGraphics.FillRectangle(MyBrush, New Rectangle(0, 0, 100, 100)) 'It should draw a 50% opaque blue rectangle 100 px by 100 px at 0,0.
DiverDan, not for the sake of contradicting you, but for the sake of posting accurate information, I'm going to point out that although "Layered Windows" (used for semi-transparent forms) is only supported on Windows 2000/Xp and up, other semi-transparency using Windows Forms is a feature of the GDI+ library included with the .Net Framework and is fully supported in any .Net application. Try using the Graphics object and controls with semi-transparent BackColors on the Win9x/NT platforms and you will still see the nifty semi-transparent effects.
Ok, PROKA, here is what is wrong with your display.
You are drawing one rectangle in the form's Paint event. This in itself will only guarantee that one rectangle will be visible on your form.
When you create a new rectangle in MouseUp, you invalidate the region where you place the rectangle, so, even though:
you may not have a rectangle in this region and
you can successfully place it so that the old rectangle is not invalidated
The fact remains that you are only drawing one rectangle in the Paint event.
So, when the rectangles that you have drawn overlap, the one you are drawing now is the one that will dominate. Furthermore, the region of the rectangle is invalidated, therefore giving it an "opaque center".
I suggest that you create your own graphics object.
Dim GFX As Graphics
In Form_Load or somewhere on the form that runs first:
GFX = Me.CreateGraphics()
Now, instead of invalidating your display, which clears out a hole on the display,
just draw the rectangle.
This solution will cause your rectangles to disappear when the form disappears or is obscured. If you want to keep the rectangles persistent, then keep an array of rectangles, go back to this solution you have already, with the Invalidate and the drawing in the Paint and, in the Pait event, use e.Graphics.DrawRectangles to draw a bunch of rectangles.
One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(