New topic: Help Converting Buffers
<http://forums.realsoftware.com/viewtopic.php?t=36515> Page 1 of 1 [ 2 posts ] Previous topic | Next topic Author Message trice Post subject: Help Converting BuffersPosted: Thu Dec 02, 2010 10:20 pm Joined: Thu Dec 02, 2010 10:17 pm Posts: 1 Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Private Sub Form_Activate() Dim MyStr As String MyStr = String(GetWindowTextLength(Me.hwnd) + 1, Chr$(0)) GetWindowText Me.hwnd, MyStr, Len(MyStr) MsgBox MyStr End Sub Hi, I read this example and I am kinda stuck On converting it to RB. I know the ByVal lpString As String should be ByVal lpString As cString and all the long should be integer i got all that stuff done but the MyStr = String(GetWindowTextLength(Me.hwnd) + 1, Chr$(0)) GetWindowText Me.hwnd, MyStr, Len(MyStr) is the code that is getting me stuck. Any help would be nice Top timhare Post subject: Re: Help Converting BuffersPosted: Thu Dec 02, 2010 10:55 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 8734 Location: Portland, OR USA Use a MemoryBlock for the buffer. Code:Declare Function GetWindowTextA lib "User32" (hwnd as Integer, buffer as Ptr, cch as Integer) as Integer Declare Function GetWindowTextLengthA lib "User32" (hwnd as Integer) as Integer dim buff as MemoryBlock dim myStr as String buff = New MemoryBlock(GetWindowTextLengthA(self.Handle)+1) call GetWindowTextA(self.Handle, buff, buff.Size) myStr = buff.CString(0) msgbox myStr Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 2 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
