1

I am trying to make a form with a border like the border on the Windows Vista volume control. The form would need to be resizeable as well.

enter image description here

Thanks, giodamelio

To be a little more clear about what I am looking for. Here is a form with the ControlBox property set to false.

enter image description here

Here is a rough Photoshop of what I am looking for.

enter image description here

giodamelio
  • 5,465
  • 14
  • 44
  • 72
  • Check accepted answer at [Drop shadow in Winforms Controls](http://stackoverflow.com/questions/2463519/drop-shadow-in-winforms-controls) – Javed Akram Apr 29 '11 at 10:18
  • @Javed Akram Though that is interesting and my play a role in the final answer, it is not the complete picture. – giodamelio Apr 29 '11 at 10:27
  • You can use Spy++ to see what styles are applied to the mixer popup, then try setting those same styles in your CreateParams – Sam Axe Apr 29 '11 at 22:21
  • Ill try that when I have access to my dev machine tomorro. – giodamelio Apr 30 '11 at 04:18
  • Unfortunately, my dev machine is having a boatload of issues and has some nasty rootkit on it I think. I reinstalled the os and it stuck! Must have hid itself on my linux drive! Needless to say, my work on this will be on hold till I can get this fixed. That may take a few days cause of school. :( – giodamelio Apr 30 '11 at 18:57
  • @boo turns out spy++ doesn't ship with VS Express. If Someone wouldn't mind posting a screenshot of the output here that would be great. – giodamelio May 01 '11 at 06:12

4 Answers4

2

Set the forms .Controlbox=False
Set the forms .Text=""

Done.

Jack Marchetti
  • 15,536
  • 14
  • 81
  • 117
Stefan
  • 11,423
  • 8
  • 50
  • 75
  • I can believe I did not think of `setting Text=""`. If this is it, I'm going to kick myself. As my comment above says it might be a few days till I can put this to the test. – giodamelio Apr 30 '11 at 19:13
  • Do not kick yourself to hard. ;) – Stefan May 02 '11 at 07:54
0

You can enable in your Projectsettigs "enable XP-Visual Style". If you launch your application now, you should have the default borderstyle of the launched OS

SwissGuy
  • 565
  • 1
  • 6
  • 18
0

Try setting the FormBorderStyle to None or Fixed(3D|Single) and work from there, perhaps.

Alternatively, setting the ControlBox to False should also have the effect of hiding the title bar. However, beware that the form won’t update automatically:

If you set ControlBox to false, and also set the Location property, the Size property of Form will not update to reflect that the non-client area of the form has been hidden. To fix this problem, put the code which alters the Location property to the HandleCreated event.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
  • Even after doing that, the topbar(taskbar?) stays. – giodamelio Apr 29 '11 at 10:38
  • @giodamelio It’s been some time since I’ve used WinForms (before Vista) but at least with `None` as the border style there should be no non-client area at all, hence no title bar. – Konrad Rudolph Apr 29 '11 at 10:40
  • True, but then I have the issue of drawing the border and shadow on again. – giodamelio Apr 29 '11 at 10:44
  • @giodamelio See my added remark concerning the `ControlBox` property. – Konrad Rudolph Apr 29 '11 at 10:45
  • @Konrad Rudolph Setting the `Controlbox` property to `False` removes the maximize, minimize and close buttons but does not actually remove the topbar itself. My second picture is with `ControlBox=False`, As you can see, the topbar remains. – giodamelio Apr 29 '11 at 10:55
  • @giodamelio That’s why I added the quote from MSDN. Setting `ControlBox` to `False` *should* remove the title bar. If that’s not happening the reason is that the resizing event has not been fired. You may need to set the property in the `HandleCreated` event to get the desired effect. – Konrad Rudolph Apr 29 '11 at 11:31
  • The part `To fix this problem, put the code which alters the Location property to the HandleCreated event.1` confuses me. Can you give me an example? – giodamelio Apr 29 '11 at 11:40
  • @giodamelio Admittedly, this is confusing. I don’t have Windows so I can’t experiment (it works under Mono!). I take that to mean that you need to re-set the size of the form after disabling the `ControlBox` so that the form’s non-client are vanishes. – Konrad Rudolph Apr 29 '11 at 11:45
  • Using this code, I reset the size in the Form_HandleCreate, the results are the same. `Private Sub Form1_HandleCreated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.HandleCreated Me.Size = New Size(300, 300) End Sub` – giodamelio Apr 29 '11 at 11:49
  • I am am thinking maybe overriding the onPaint sub and drawing custom borders. – giodamelio Apr 29 '11 at 11:50
0

One way achieve this by following steps:

  • Set FormBorderStyle of your Form to None.

  • Take a PictureBox, set its Dock Property to Fill.

  • Take a image containing Border, and set this Image to the PictureBox.

Javed Akram
  • 15,024
  • 26
  • 81
  • 118
  • That is a cool trick, and way more out of the box then I was thinking. Here(http://gyazo.com/01a132bd42e4bce1eb49780aece50619.png) is a screenshot of it in action. The form would not be resizeable though, which I would need. – giodamelio Apr 29 '11 at 10:50
  • @giodamelio, by setting `FormBorderStyle` to **NONE**, form will not be resizable. – Javed Akram Apr 29 '11 at 10:58
  • I overlooked that fact. That is another reason that this solution will not work for me. – giodamelio Apr 29 '11 at 11:01
  • If you want to resize the form by mouse and move too, I will give you a link shortly..... – Javed Akram Apr 29 '11 at 11:04
  • See [Drag borderless windows form by mouse](http://stackoverflow.com/questions/4767831/drag-borderless-windows-form-by-mouse) – Javed Akram Apr 29 '11 at 11:31