Solved

Resiable Controls, Windows

Posted on 2010-08-19
2
405 Views
Last Modified: 2013-12-26
Hello,
I want to create an object, either a form or another type of container that I can place a status bar on with a grab handle to resize the container.  The container will have a status bar and a list controll.  I want to have the container resizable using the status bar grab handle, but I don't want the container to be sizable by clicking on the top,left or right corner of teh containger (form, panel, etc.) - I can not get any panel to be resizable using a status bar, or for that matter resizabe at all.  I can get it working the way I want by putting a status bar on a form, then filling the form with the list boxb but then the user can resize the form by clicking on one edge of the form (top, left, right)..   in effect, I want a container that will resize to the right and down, but not from the top or left.

I'm trying to acccomplist a drop down combo then displays the list box with various values in it.  I hope that's clear, if not let me know....
0
Comment
Question by:DRRobinson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
kooswillem earned 500 total points
ID: 33483023
Just prevent the left and top values from being edited like in this example. Only the ratio's need some adjusting, but you should be able to figure that out.

Namespace WindowsFormsApplication2
      Public Partial Class Form1
            Inherits Form
            Const MAXIMUM As Integer = 800
            Private left As Integer = 0, top As Integer = 0, width As Integer = 0, height As Integer = 0, deltaResize As Integer = 0
            Private startResize As Boolean = False
            Public Sub New()
                  InitializeComponent()
            End Sub

            Private Sub Form1_ResizeEnd(sender As Object, e As EventArgs)
                  If Form1.ActiveForm.Left <> left Then
                        Form1.ActiveForm.Left = left
                  End If
                  If Form1.ActiveForm.Top <> top Then
                        Form1.ActiveForm.Top = top
                  End If
                  If Form1.ActiveForm.Width > MAXIMUM Then
                        Form1.ActiveForm.Width = MAXIMUM
                  End If

                  Dim formResize As Integer = width - Form1.ActiveForm.Width
                  Dim ratioFormBar As Single = MAXIMUM / progressBar1.Width
                  Try
                        progressBar1.Value = progressBar1.Value - CInt(Math.Floor(formResize / ratioFormBar))
                  Catch
                        If progressBar1.Value - CInt(Math.Floor(formResize / ratioFormBar)) < 0 Then
                              progressBar1.Value = 0
                        End If
                        If progressBar1.Value - CInt(Math.Floor(formResize / ratioFormBar)) > MAXIMUM Then
                              progressBar1.Value = MAXIMUM
                        End If
                  End Try
            End Sub

            Private Sub Form1_ResizeBegin(sender As Object, e As EventArgs)
                  If Form1.ActiveForm IsNot Nothing Then
                        left = Form1.ActiveForm.Left
                        top = Form1.ActiveForm.Top
                        width = Form1.ActiveForm.Width
                        height = Form1.ActiveForm.Height
                  End If
            End Sub

            Private Sub Form1_Activated(sender As Object, e As EventArgs)
                  progressBar1.Value = Form1.ActiveForm.Left
                  progressBar1.Maximum = MAXIMUM
                  width = Form1.ActiveForm.Width
                  height = Form1.ActiveForm.Height

            End Sub

            Private Sub progressBar1_MouseDown(sender As Object, e As MouseEventArgs)
                  If e.Button = MouseButtons.Left Then
                        deltaResize = e.X
                        startResize = True
                  End If
            End Sub

            Private Sub progressBar1_MouseUp(sender As Object, e As MouseEventArgs)
                  If e.Button = MouseButtons.Left AndAlso startResize Then
                        Dim mouseMovement As Integer = e.X - deltaResize
                        Dim ratioFormBar As Single = MAXIMUM / progressBar1.Width
                        Form1.ActiveForm.Width = Form1.ActiveForm.Width + CInt(Math.Floor(mouseMovement * ratioFormBar))
                        startResize = True
                  End If

            End Sub
      End Class
End Namespace
0
 

Author Closing Comment

by:DRRobinson
ID: 33484436
Thanks for the note.  I guess I should have figured that out on my own.. That's why I like EE so much.. it's a nice forum for teh lone programmer to bounce ideas off others...

Thanks again...
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question