0
Source Code
  Imports System.Runtime.InteropServices

Public Class Form1
    
    Public Structure RECT
        Public Left As Integer
        Public Top As Integer
        Public Right As Integer
        Public Bottom As Integer
    End Structure

    
    Private Shared Function SendMessage(hWnd As IntPtr, msg As Integer, wParam As IntPtr, ByRef lParam As RECT) As IntPtr
    End Function

    Private Const EM_SETRECT As Integer = &HB3

    Private Sub MoveText()

        Dim r As RECT

        r.Left = NumericUpDown2.Value   ' Right/Left
        r.Top = NumericUpDown1.Value    ' Up/Down

        ' IMPORTANT FIX ๐Ÿ‘‡
        r.Right = TextBox1.ClientSize.Width + r.Left
        r.Bottom = TextBox1.ClientSize.Height + r.Top
        SendMessage(TextBox1.Handle, EM_SETRECT, IntPtr.Zero, r)
        TextBox1.Refresh()
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        TextBox1.Multiline = True
        MoveText()
    End Sub

   Private Sub NumericUpDown1_ValueChanged(sender As Object, e As EventArgs) Handles NumericUpDown1.ValueChanged
        MoveText()
    End Sub
    Private Sub NumericUpDown2_ValueChanged(sender As Object, e As EventArgs) Handles NumericUpDown2.ValueChanged
        MoveText()
    End Sub
End Class




Small Coding its also working 

Imports System.Runtime.InteropServices
Public Class Form1
    
    Private Shared Function SendMessage(hWnd As IntPtr, msg As Integer, wp As IntPtr, ByRef lp As Drawing.Rectangle) As IntPtr
    End Function

    Private Sub MoveText() Handles NumericUpDown1.ValueChanged, NumericUpDown2.ValueChanged
        ' Rectangle structure ko direct use karein (RECT ki zaroorat nahi)
        Dim r As New Drawing.Rectangle(NumericUpDown2.Value, NumericUpDown1.Value,
                                       TextBox1.ClientSize.Width, TextBox1.ClientSize.Height)

        SendMessage(TextBox1.Handle, &HB3, IntPtr.Zero, r)
        TextBox1.Invalidate() ' Refresh se behtar hai
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        TextBox1.Multiline = True

    End Sub
    Private Sub NumericUpDown1_ValueChanged(sender As Object, e As EventArgs) Handles NumericUpDown1.ValueChanged
    End Sub

    Private Sub NumericUpDown2_ValueChanged(sender As Object, e As EventArgs) Handles NumericUpDown2.ValueChanged
    End Sub
End Class


  

Post a Comment

 
Top