PC Review


Reply
Thread Tools Rate Thread

borderstyle of a panel

 
 
=?Utf-8?B?V2lsZnJpZWQgTWVzdGRhZ2g=?=
Guest
Posts: n/a
 
      21st Mar 2005
Hi,

I seems not to find how to change borderstyle of a panel so that it is not
sunken, but raised. I only find a 3d setting in obejct inspector... Someone
knows this ?

--
rgds, Wilfried
http://www.mestdagh.biz
 
Reply With Quote
 
 
 
 
=?Utf-8?B?cHJhZGVlcF9UUA==?=
Guest
Posts: n/a
 
      21st Mar 2005
Hi WilFried,

I have written the following code in the paint event of the Panel to give it
a raised look. hope this helps

//code starts
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs
e)
{

Graphics g = panel1.CreateGraphics();

Rectangle panelRect = panel1.ClientRectangle;

Point p1 = new Point(panelRect.Left, panelRect.Top); //top left
Point p2 = new Point(panelRect.Right-1, panelRect.Top); //Top Right
Point p3 = new Point(panelRect.Left, panelRect.Bottom-1); //Bottom Left
Point p4 = new Point(panelRect.Right - 1, panelRect.Bottom -1); //Bottom
Right

Pen pen1 = new Pen(System.Drawing.Color.White);
Pen pen2 = new Pen(System.Drawing.Color.Black);

g.DrawLine(pen1, p1, p2);
g.DrawLine(pen1, p1, p3);
g.DrawLine(pen2, p2, p4);
g.DrawLine(pen2, p3, p4);
}

//code ends

Happy programming!
pradeep_TP

"Wilfried Mestdagh" wrote:

> Hi,
>
> I seems not to find how to change borderstyle of a panel so that it is not
> sunken, but raised. I only find a 3d setting in obejct inspector... Someone
> knows this ?
>
> --
> rgds, Wilfried
> http://www.mestdagh.biz

 
Reply With Quote
 
=?Utf-8?B?V2lsZnJpZWQgTWVzdGRhZ2g=?=
Guest
Posts: n/a
 
      21st Mar 2005
exacly what I was looking ofr. thx
 
Reply With Quote
 
Tim Wilson
Guest
Posts: n/a
 
      21st Mar 2005
As an alternative to painting the window you can always allow the system to
handle the border style and still be part of the non-client area using some
p/invokes. There are other border styles that you can use as well if you
look through the docs. But if you're painting the border yourself then you
might consider using the ControlPaint class to perform the drawing for you.

using System.Runtime.InteropServices;

private const int GWL_EXSTYLE = -20;
private const int WS_EX_DLGMODALFRAME = 0x00000001;
private const int SWP_NOSIZE = 0x0001;
private const int SWP_NOMOVE = 0x0002;
private const int SWP_NOZORDER = 0x0004;
private const int SWP_NOACTIVATE = 0x0010;
private const int SWP_FRAMECHANGED = 0x0020;

[DllImport("user32.dll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int
dwNewLong);
[DllImport("user32.dll")]
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter,
int X, int Y, int cx, int cy, uint uFlags);

IntPtr hWnd = this.panel1.Handle;
int style = GetWindowLong(hWnd, GWL_EXSTYLE);
SetWindowLong(hWnd, GWL_EXSTYLE, (style | WS_EX_DLGMODALFRAME));
SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, (SWP_FRAMECHANGED | SWP_NOSIZE |
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE));

--
Tim Wilson
..Net Compact Framework MVP

"Wilfried Mestdagh" <(E-Mail Removed)> wrote in
message news8E90443-992A-4995-B888-(E-Mail Removed)...
> Hi,
>
> I seems not to find how to change borderstyle of a panel so that it is not
> sunken, but raised. I only find a 3d setting in obejct inspector...

Someone
> knows this ?
>
> --
> rgds, Wilfried
> http://www.mestdagh.biz



 
Reply With Quote
 
=?Utf-8?B?cHJhZGVlcF9UUA==?=
Guest
Posts: n/a
 
      22nd Mar 2005
HI Tim,

That was a good tip. The code is importing three DLLs. What kind of
performance issues are there in such calls. I means is is faster than drawing
the windows.

In my VB 6 days I used to do what exactly you have written. But in .net
things have beocme more easier.

Can you please throw some more lights on the performance issues here. I want
to gain more understanding about the same.

thanks
pradeep_TP

"Tim Wilson" wrote:

> As an alternative to painting the window you can always allow the system to
> handle the border style and still be part of the non-client area using some
> p/invokes. There are other border styles that you can use as well if you
> look through the docs. But if you're painting the border yourself then you
> might consider using the ControlPaint class to perform the drawing for you.
>
> using System.Runtime.InteropServices;
>
> private const int GWL_EXSTYLE = -20;
> private const int WS_EX_DLGMODALFRAME = 0x00000001;
> private const int SWP_NOSIZE = 0x0001;
> private const int SWP_NOMOVE = 0x0002;
> private const int SWP_NOZORDER = 0x0004;
> private const int SWP_NOACTIVATE = 0x0010;
> private const int SWP_FRAMECHANGED = 0x0020;
>
> [DllImport("user32.dll")]
> private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
> [DllImport("user32.dll")]
> private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int
> dwNewLong);
> [DllImport("user32.dll")]
> private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter,
> int X, int Y, int cx, int cy, uint uFlags);
>
> IntPtr hWnd = this.panel1.Handle;
> int style = GetWindowLong(hWnd, GWL_EXSTYLE);
> SetWindowLong(hWnd, GWL_EXSTYLE, (style | WS_EX_DLGMODALFRAME));
> SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, (SWP_FRAMECHANGED | SWP_NOSIZE |
> SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE));
>
> --
> Tim Wilson
> ..Net Compact Framework MVP
>
> "Wilfried Mestdagh" <(E-Mail Removed)> wrote in
> message news8E90443-992A-4995-B888-(E-Mail Removed)...
> > Hi,
> >
> > I seems not to find how to change borderstyle of a panel so that it is not
> > sunken, but raised. I only find a 3d setting in obejct inspector...

> Someone
> > knows this ?
> >
> > --
> > rgds, Wilfried
> > http://www.mestdagh.biz

>
>
>

 
Reply With Quote
 
Tim Wilson
Guest
Posts: n/a
 
      22nd Mar 2005
The code just p/invokes to a system dll ("user32.dll"). To be honest,
without running tests, I would think that the p/invoke method would be a lot
faster than the .Net drawing method since under the covers the drawing
method is going to be p/invoking too, and making more p/invoke calls. But
the .Net drawing method is more flexible since you can basically do whatever
you want. In other words, if you drew the border yourself then you're pretty
much only limited by your imagination when it comes to custom styles. The
way I see it, it all depends on what you're attempting to accomplish.
However, when you look at the manifest, through ildasm, for the
"System.Drawing.dll" you can see that it too relies on the "user32.dll".

--
Tim Wilson
..Net Compact Framework MVP

"pradeep_TP" <(E-Mail Removed)> wrote in message
news:4F94835D-0E69-4681-AE5A-(E-Mail Removed)...
> HI Tim,
>
> That was a good tip. The code is importing three DLLs. What kind of
> performance issues are there in such calls. I means is is faster than

drawing
> the windows.
>
> In my VB 6 days I used to do what exactly you have written. But in .net
> things have beocme more easier.
>
> Can you please throw some more lights on the performance issues here. I

want
> to gain more understanding about the same.
>
> thanks
> pradeep_TP
>
> "Tim Wilson" wrote:
>
> > As an alternative to painting the window you can always allow the system

to
> > handle the border style and still be part of the non-client area using

some
> > p/invokes. There are other border styles that you can use as well if you
> > look through the docs. But if you're painting the border yourself then

you
> > might consider using the ControlPaint class to perform the drawing for

you.
> >
> > using System.Runtime.InteropServices;
> >
> > private const int GWL_EXSTYLE = -20;
> > private const int WS_EX_DLGMODALFRAME = 0x00000001;
> > private const int SWP_NOSIZE = 0x0001;
> > private const int SWP_NOMOVE = 0x0002;
> > private const int SWP_NOZORDER = 0x0004;
> > private const int SWP_NOACTIVATE = 0x0010;
> > private const int SWP_FRAMECHANGED = 0x0020;
> >
> > [DllImport("user32.dll")]
> > private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
> > [DllImport("user32.dll")]
> > private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int
> > dwNewLong);
> > [DllImport("user32.dll")]
> > private static extern bool SetWindowPos(IntPtr hWnd, IntPtr

hWndInsertAfter,
> > int X, int Y, int cx, int cy, uint uFlags);
> >
> > IntPtr hWnd = this.panel1.Handle;
> > int style = GetWindowLong(hWnd, GWL_EXSTYLE);
> > SetWindowLong(hWnd, GWL_EXSTYLE, (style | WS_EX_DLGMODALFRAME));
> > SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, (SWP_FRAMECHANGED |

SWP_NOSIZE |
> > SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE));
> >
> > --
> > Tim Wilson
> > ..Net Compact Framework MVP
> >
> > "Wilfried Mestdagh" <(E-Mail Removed)> wrote

in
> > message news8E90443-992A-4995-B888-(E-Mail Removed)...
> > > Hi,
> > >
> > > I seems not to find how to change borderstyle of a panel so that it is

not
> > > sunken, but raised. I only find a 3d setting in obejct inspector...

> > Someone
> > > knows this ?
> > >
> > > --
> > > rgds, Wilfried
> > > http://www.mestdagh.biz

> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Panel with a Raised BorderStyle Steph. Microsoft C# .NET 2 23rd Sep 2010 02:23 PM
VS 2005 PocketPC project: no GroupBox control, no BorderStyle property for Panel control... SammyBar Microsoft Dot NET Compact Framework 2 13th Jan 2006 07:35 PM
borderstyle =?Utf-8?B?c2Vla2VyNTI=?= Microsoft Access Form Coding 1 17th Jan 2004 07:29 PM
BorderStyle and Alt+Tab Daniel Bello Urizarri Microsoft Dot NET Framework Forms 6 21st Oct 2003 04:21 AM
Panel BorderStyle Raised Luc Benninger Microsoft C# .NET 1 25th Jul 2003 12:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:15 PM.