|
vaseem
|
|
|
|
|
|
|
Voted one because this is fake non-rectangular shape, not reliable, too. It makes no sense as the settings the property Region is a simple and comprehensive way to solve this problem.
—SA
|
|
|
|
|
This article simply lies to reader about non-rectangular forms. The forms obtained this way are really as rectangular as the very rectangular rectangle .
The only way is to modify Form.Region .
—SA
modified on Tuesday, September 20, 2011 11:47 PM
|
|
|
|
|
I downloaded the demo file and ran it on windows xp. I found that the black background shows. However if i make the same background design using photoshop but keep the black portion transparent and then using it as a form background image and setting the background color of the form sams as the transparency key color (black in this case) it works fine.
|
|
|
|
|
has anyone solved this on 32 bit?
|
|
|
|
|
It works fine in 32 bit. Make your background pic with a transparent background. I use Photoshop CS with a .png or .gif, both worked after you follow the above directions!
|
|
|
|
|
I've had it work on my home computer with 32 bit display
However at school it won't work on 32 bit, 16 bit is the only way to get it to work.
Is it possible that the type of graphics card would affect it?
My home pc has an ATi X1600 256MB, whereas the school one has integrated (Intel accelerated)
|
|
|
|
|
setting FormBorderStyle to none cause the system context menu (when you right click the form tab in the task bar) not to appear. Does any one know a way of having such a borderless window still have this system menu?
Thank you
|
|
|
|
|
Hi everybody...
I have a problem when the form is minimized and then restored.I'm using a button to minimize the form. I added this OnClick method:
<br />
void BtnMinimizeClick(object sender, System.EventArgs e)<br />
{<br />
this.WindowState = FormWindowState.Minimized;<br />
}<br />
Later when i restore the form the title bar appears (and it's kinda ugly :S), i can't make it go away..
Anyone Help ¿?¿?
Thanks..
custom windows forms
|
|
|
|
|
Hi,
thanks for the articule. I want that the client can resize the form, how can i do that?
Thanks,
eL RaNu
ranu.com.ar
|
|
|
|
|
Mental note...this doesnt work with Visual Studio.Net 2003 or windows XP....gotta be one of them cause all tutorials or executables i have tried diplay the black background color even though it is not supposed to....anyone know how to make this work with .NET 2003???
|
|
|
|
|
Make Sure your VGA Card is set at 16 bit resolution.
|
|
|
|
|
It seems to me that it would be more robust using the SetWindowRegion API (Okay, it would make you use a bit of Interop...)
something like :
[DllImport("Gdi32.dll", EntryPoint= "CombineRgn", SetLastError=true, CharSet=CharSet.Auto)]<br />
public static extern int CombineRegion(IntPtr dst, IntPtr src1, IntPtr src2, CombineRegionOptions options);<br />
[DllImport("User32.dll", EntryPoint= "SetWindowRgn", SetLastError=true,CharSet=CharSet.Auto)]<br />
public static extern int SetWindowRegion(IntPtr hWnd, IntPtr hRgn, int visible);<br />
[DllImport("Gdi32.dll", EntryPoint= "CreateRectRgn",SetLastError=true,CharSet=CharSet.Auto)]<br />
public static extern IntPtr CreateRectangleRegion(int left, int top, int right, int bottom);<br />
[DllImport("Gdi32.dll", EntryPoint= "DeleteObject", SetLastError=true,CharSet=CharSet.Auto)]<br />
public static extern int DeleteObject(IntPtr obj);<br />
<br />
public enum CombineRegionOptions : int<br />
{<br />
RGN_AND = 1,<br />
RGN_OR = 2,<br />
RGN_XOR = 3,<br />
RGN_DIFF = 4,<br />
RGN_COPY = 5,<br />
RGN_MIN = RGN_AND,<br />
RGN_MAX = RGN_COPY<br />
}<br />
<br />
<br />
<br />
IntPtr region = Win32.CreateRectangleRegion(0,0,image.Width,image.Height);<br />
for(int y = 0; y < image.Height; y++)<br />
{<br />
for (int x = 0; x < image.Width; x++)<br />
{<br />
Color pixel = image.GetPixel(x,y);<br />
if((pixel.R == color.R) && (pixel.G == color.G) && (pixel.B == color.B))<br />
{<br />
IntPtr pixelRegion = CreateRectangleRegion(x,y,x + 1, y + 1);<br />
CombineRegion(region,region, pixelRegion,Win32.CombineRegionOptions.RGN_XOR);<br />
DeleteObject(pixelRegion);<br />
}<br />
}<br />
}<br />
SetWindowRegion(form.Handle,region,0);
where color is the desired transparent color and image the bitmap to parse.
I don't really know where I've seen this code (probably on http://www.learn247.net) but it works well for creating custom shaped forms.
Michael CARBENAY
|
|
|
|
|
Why use SetWindowRegion API when winforms provides the properties already; eg
public TestForm()
{
InitializeComponent();
this.Region = new Region(new Rectangle(5,5,250,150));
}
Works well.
|
|
|
|
|
Exactly! You are absolutely right. For this reason, I voted 1 for the article, please see my comment.
—SASergey A Kryukov
|
|
|
|
|
Use this code to set the ouside region of the window...
private void FormMain_Load(object sender, EventArgs e)
{
GraphicsPath oPath = new GraphicsPath();
oPath.AddEllipse(this.ClientRectangle);
this.Region = new Region(oPath);
}
C#, ASPX, SQL, novice to NHibernate
|
|
|
|
|
Regions are definitely a better way to do it, check out how to do it at Custom Shape Forms - Regions
Free Code Snippets and Downloads
http://vckicks.110mb.com/
|
|
|
|
|
Exactly! You are right. By that reason, I voted 1 for the fake an unreliable solution suggested by this article.
—SASergey A Kryukov
|
|
|
|
|
Hi!
There are problems with using the TransparencyKey when the desktop is set to 32bit color depth. It simply doesn't work then.
The workaround is something like this:
System.Drawing.Bitmap Img = new System.Drawing.Bitmap("MyBackground.bmp");
Img.MakeTransparent(Img.GetPixel(0,0));
this.BackgroundImage = Img;
this.TransparencyKey = Img.GetPixel(0,0); in the Load event of your Form .
Regards,
mav
|
|
|
|
|
Great piece of work mav, i will update the code as soon as possible
|
|
|
|
|
I tried doing this, but it also makes all of my black text transparent too. Is there anyway to get around that?
Thanks
|
|
|
|
|
What about setting your text color to RGB(1,0,0) ?
I didn't try that but maybe it works. And I think, you wouldn't see any difference to black.
if it doesn't fit...
use a bigger hammer!
|
|
|
|
|
I had the same problem...googled around and found the solution...
System.Drawing.Bitmap Img = new System.Drawing.Bitmap("LoginBackground.png");
Color color = Img.GetPixel(0, 0);
Img.MakeTransparent(color);
this.BackgroundImage = Img;
this.TransparencyKey = color;
this.BackColor = color;
|
|
|
|