Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2006

Tip: Looking for answers? Try searching our database.

Scrolling textbox programmatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jester - 20 Mar 2006 04:10 GMT
Hi,

This code (w/c programmatically scrolls a textbox) works in VB 6.0:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
As Long)

Private Const EM_LINESCROLL = &HB6

Private Sub Command1_Click()
   Dim result As Long
  ' Textbox should scroll after call below.
   result = SendMessage(Text1.hwnd, EM_LINESCROLL, 0, 1)
End Sub

but the same code does not work in VB.NET:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
As Long)
Private Const EM_LINESCROLL As Integer = &HB6

Dim result As Long
result = SendMessage(Textbox1.Handle.ToInt64, EM_LINESCROLL, 0, 1)

result for VB.NET code is always 0. Same happens if hwnd is defined as
IntPtr and Textbox1.Handle is passed to SendMessage. Help please?
Claes Bergefall - 20 Mar 2006 21:08 GMT
Wrong datatypes. Use this:

Private Declare Auto Function SendMessage Lib "user32" (ByVal hwnd As
IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam
As Integer)

Private Const EM_LINESCROLL As Integer = &HB6

Dim result As Integer
result = SendMessage(Textbox1.Handle, EM_LINESCROLL, 0, 1)

> Hi,
>
[quoted text clipped - 26 lines]
> result for VB.NET code is always 0. Same happens if hwnd is defined as
> IntPtr and Textbox1.Handle is passed to SendMessage. Help please?
jester - 21 Mar 2006 02:08 GMT
Worked like a charm! Thanks, Claes :)

> Wrong datatypes. Use this:
>
[quoted text clipped - 37 lines]
> > result for VB.NET code is always 0. Same happens if hwnd is defined as
> > IntPtr and Textbox1.Handle is passed to SendMessage. Help please?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.