473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

borderstyle of a panel

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
Nov 16 '05 #1
5 15576
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

Nov 16 '05 #2
exacly what I was looking ofr. thx :)
Nov 16 '05 #3
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" <Wi**************@discussions.microsoft.com> wrote in
message news:D8**********************************@microsof t.com...
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

Nov 16 '05 #4
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" <Wi**************@discussions.microsoft.com> wrote in
message news:D8**********************************@microsof t.com...
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


Nov 16 '05 #5
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" <pr*******@discussions.microsoft.com> wrote in message
news:4F**********************************@microsof t.com...
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" <Wi**************@discussions.microsoft.com> wrote in message news:D8**********************************@microsof t.com...
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


Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: os_bonn | last post by:
Hi, Currently I am developing a css+xml+html+javascript based offline GUI application (IE6 based). Especially I have a <div...> layer where - the mouseover event sets borderstyle="solid" -...
1
by: Luc Benninger | last post by:
Hi, I want a panel control on a form appear as raised. But the BorderStyle property just let me choose Fixed3D which adds a sunken 3D border around the panel. How can I get a raised one? Many...
0
by: Steph. | last post by:
Hi, I was looking for a way to get a Panel with a Raised border style ... I found the simplest way to do it, so I share it with you : public class StpPanel:Panel { const int...
5
by: BrianW | last post by:
I am working on a program that has multiple picturebox controls that a user is allowed to move around which are contained within a panel control for visual placement. In my mousedown event, I set...
2
by: Saber | last post by:
glb is a global string, I want when moving mouse to a picturebox, change border style of picturebox. the code shown below do that but MouseLeave event fires less than a second after MouseHover,...
3
by: alexjaquet | last post by:
Hi, I've in my web pages an affectation to this property but it's doesn't work (same for all the others properties I'm trying to update): here is the complete function I call on mouseover : ...
2
by: spifster | last post by:
Hello all, I am building a collapsable tree using Javascript with DOM in IE. In order to make collapsed cells disappear I have been hiding the text. The cells collapse but still leave borders...
4
by: active | last post by:
There are at least the following border styles: None FixedSingle Sizable
6
by: mgawelek | last post by:
I am doing this in vb.net 2K5 The code below is in a module trying to edit the main form's label control. The error message is: BorderStyle is not a member of System.Windows.Forms.Control. When it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.