473,668 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 15611
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(ob ject sender, System.Windows. Forms.PaintEven tArgs
e)
{

Graphics g = panel1.CreateGr aphics();

Rectangle panelRect = panel1.ClientRe ctangle;

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.Botto m-1); //Bottom Left
Point p4 = new Point(panelRect .Right - 1, panelRect.Botto m -1); //Bottom
Right

Pen pen1 = new Pen(System.Draw ing.Color.White );
Pen pen2 = new Pen(System.Draw ing.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_DLGMODALF RAME = 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_FRAMECHANGE D = 0x0020;

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

IntPtr hWnd = this.panel1.Han dle;
int style = GetWindowLong(h Wnd, GWL_EXSTYLE);
SetWindowLong(h Wnd, GWL_EXSTYLE, (style | WS_EX_DLGMODALF RAME));
SetWindowPos(hW nd, IntPtr.Zero, 0, 0, 0, 0, (SWP_FRAMECHANG ED | 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******** *************** ***********@mic rosoft.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_DLGMODALF RAME = 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_FRAMECHANGE D = 0x0020;

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

IntPtr hWnd = this.panel1.Han dle;
int style = GetWindowLong(h Wnd, GWL_EXSTYLE);
SetWindowLong(h Wnd, GWL_EXSTYLE, (style | WS_EX_DLGMODALF RAME));
SetWindowPos(hW nd, IntPtr.Zero, 0, 0, 0, 0, (SWP_FRAMECHANG ED | 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******** *************** ***********@mic rosoft.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*******@disc ussions.microso ft.com> wrote in message
news:4F******** *************** ***********@mic rosoft.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_DLGMODALF RAME = 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_FRAMECHANGE D = 0x0020;

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

IntPtr hWnd = this.panel1.Han dle;
int style = GetWindowLong(h Wnd, GWL_EXSTYLE);
SetWindowLong(h Wnd, GWL_EXSTYLE, (style | WS_EX_DLGMODALF RAME));
SetWindowPos(hW nd, IntPtr.Zero, 0, 0, 0, 0, (SWP_FRAMECHANG ED | 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******** *************** ***********@mic rosoft.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
2314
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" - the mouseout event sets borderstyle="none". The problem is, that inner elements (in this case a cross made with the
1
6514
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 thanks, Luc
0
1664
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 WS_EX_DLGMODALFRAME = 0x00000001;
5
4893
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 the picturebox control's borderstyle to Fixed3D, but upon doing so, I am not able to track the picturebox control through mousemove events (if you move the mouse off of the control too quickly, the control no longer receives mouse events). If I...
2
2838
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, even without leaving the mouse pointer or moving that. I also tried MouseEnter event instead of MouseHover, but they act same here. Private Sub p1_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles p1.MouseLeave,...
3
4580
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 : <script language="javascript"> function highLigth (x) { x.style.borderWidth = '5px';
2
4740
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 behind. I have set the borderStyle to none and the black lines go away, but there is still white space where the borders were. Following are my html files I am using to test it. ----------------BEGIN HTML FILE----------------
4
6155
by: active | last post by:
There are at least the following border styles: None FixedSingle Sizable
6
2828
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 is able to be set in the property window and you can do Label1.BorderStyle = BorderStyle.None in the Form's Code. Can anyone help with this? For Each ctrl As Control In Form.Controls ctrl.BorderStyle = BorderStyle.None Next
0
8459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8374
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8791
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8575
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8653
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7398
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2018
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.