OK! Now I understand what you want to do.
The MDI child form might be partly outside the MDI form so a textbox might not be seen.
I've changed the code a bit and used the GetWindowRect API function.
This function will get the bounding rectangle of any Window or control relative to the upper-left corner of the screen.
Then I used almost the same code as before but used the rectangle of the TextBox and the MDI form instead.
Best regardsVB Code:
Private Declare Function GetWindowRect _ Lib "user32" ( _ ByVal hwnd As Long, _ lpRect As RECT) As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Sub Text1_GotFocus(Index As Integer) Dim rTextBox As RECT Dim rMDI As RECT GetWindowRect Text1(Index).hwnd, rTextBox GetWindowRect MDIForm1.hwnd, rMDI With rTextBox If (.Bottom <= rMDI.Top Or .Top >= rMDI.Bottom) Or (.Right <= rMDI.Left Or .Left >= rMDI.Right) Then MsgBox "I'am out of bound" End If End With End Sub




Reply With Quote