Click here to Skip to main content
15,898,010 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralVB 6 ODBC connection to SQL 2000 Pin
JumpinJimmy20-Apr-04 6:18
JumpinJimmy20-Apr-04 6:18 
GeneralRe: VB 6 ODBC connection to SQL 2000 Pin
jimpar20-Apr-04 7:02
jimpar20-Apr-04 7:02 
GeneralRe: VB 6 ODBC connection to SQL 2000 Pin
JumpinJimmy20-Apr-04 10:01
JumpinJimmy20-Apr-04 10:01 
GeneralRe: VB 6 ODBC connection to SQL 2000 Pin
RichardGrimmer21-Apr-04 2:38
RichardGrimmer21-Apr-04 2:38 
QuestionDatabase connection error??? Pin
hounetdev20-Apr-04 5:07
hounetdev20-Apr-04 5:07 
QuestionHow do I autoupdate my application? Pin
ruseno20-Apr-04 4:08
ruseno20-Apr-04 4:08 
AnswerRe: How do I autoupdate my application? Pin
Michael Russell20-Apr-04 4:52
Michael Russell20-Apr-04 4:52 
GeneralStay inside MDI Client Area Pin
Michael Russell19-Apr-04 11:57
Michael Russell19-Apr-04 11:57 
In MDI applications, it is a common occurance for the user to open several different forms. However, even if one form is closed, the "offset" used to place the subsequent forms is remembered, so each form is gradually shifted down and to the right until it shifts partially or fully outside of the MDI client area.

I'd like to ensure that the MDI clients are always completely within the MDI client area upon first being opened.

I have come up with a hack involving the OnVisibleChanged event and two helper functions (listed below), but is there a more graceful way of doing this?

<code>
' In each form
    Protected Overrides Sub OnVisibleChanged(ByVal e As System.EventArgs)
        EnsureInsideMDIArea(Me)
    End Sub

' Helper functions in a module
    Public Function GetMDIClientRect(ByVal frm As Form) As Rectangle
        Dim pr As Rectangle = Rectangle.Empty
        For Each c As Control In frm.Controls
            If TypeOf c Is MdiClient Then pr = c.ClientRectangle
        Next
        Return pr
    End Function

    Public Sub EnsureInsideMDIArea(ByVal frm As Form)
        ' Ignore if not an MDI client
        If Not (frm.MdiParent Is Nothing) Then

            ' Get parent rect
            Dim pr As Rectangle = GetMDIClientRect(frm.MdiParent)

            Dim r, b As Integer
            r = frm.Size.Width + frm.Left
            b = frm.Size.Height + frm.Top

            If r > pr.Right Or b > pr.Bottom Then
                frm.Top = 0
                frm.Left = 0
            End If

        End If
    End Sub
</code>

GeneralRe: Stay inside MDI Client Area Pin
Dave Kreskowiak20-Apr-04 4:09
mveDave Kreskowiak20-Apr-04 4:09 
GeneralRe: Stay inside MDI Client Area Pin
Michael Russell20-Apr-04 4:47
Michael Russell20-Apr-04 4:47 
GeneralRe: Stay inside MDI Client Area Pin
Dave Kreskowiak20-Apr-04 5:31
mveDave Kreskowiak20-Apr-04 5:31 
QuestionHow do I Pin
KORCARI19-Apr-04 10:08
KORCARI19-Apr-04 10:08 
AnswerRe: How do I Pin
Daniel Turini19-Apr-04 10:28
Daniel Turini19-Apr-04 10:28 
QuestionHow do I Pin
KORCARI19-Apr-04 10:06
KORCARI19-Apr-04 10:06 
AnswerRe: How do I Pin
Dave Kreskowiak20-Apr-04 3:49
mveDave Kreskowiak20-Apr-04 3:49 
QuestionHow do I Pin
Anonymous19-Apr-04 10:00
Anonymous19-Apr-04 10:00 
GeneralPackage and Deployment Wizard VB6 Pin
krekre19-Apr-04 6:46
krekre19-Apr-04 6:46 
GeneralRe: Package and Deployment Wizard VB6 Pin
Roger Wright19-Apr-04 7:17
professionalRoger Wright19-Apr-04 7:17 
GeneralRe: Package and Deployment Wizard VB6 Pin
krekre19-Apr-04 8:31
krekre19-Apr-04 8:31 
GeneralRe: Package and Deployment Wizard VB6 Pin
Mike Dimmick19-Apr-04 8:59
Mike Dimmick19-Apr-04 8:59 
GeneralRe: Package and Deployment Wizard VB6 Pin
krekre19-Apr-04 9:57
krekre19-Apr-04 9:57 
GeneralEmail in VB .NET Pin
Jubal1519-Apr-04 6:08
Jubal1519-Apr-04 6:08 
GeneralRe: Email in VB .NET Pin
Dave Kreskowiak19-Apr-04 9:40
mveDave Kreskowiak19-Apr-04 9:40 
GeneralRe: Email in VB .NET Pin
Jubal1519-Apr-04 19:39
Jubal1519-Apr-04 19:39 
Generalautoconverting word version Pin
dark_owl19-Apr-04 5:50
dark_owl19-Apr-04 5:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.