formerTexan
Programmer
Could someone have a look at the following code and suggest where I am going wrong in adapting to vb/vba.
As is, the code crashes the application on:
SendMessageRef(m_hWnd, EM_GETTEXTEX, tGTT, sBuff)
C Datatypes and all the fun stuff like memory management are a new experience to me and a prickly introduction.
Thanks, Bill
CODE:
Private Declare Function apiSendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal msg As Long, ByRef tGTT As Any, ByRef lp As Any) As Long
Dim tGTL As GETTEXTLENGTHEX
Dim tGTT As GETTEXTEX
Dim lRet As Long '
Dim lRet1 As Long
Dim sBuff As String
Dim sRTText As String
Call apiZeroMemory(tGTL, Len(tGTL))
tGTL.flags = GTL_NUMCHARS
tGTL.codepage = CP_ACP
'return number of TChars in RtichText control
lRet = SendMessageRef(m_hWnd, EM_GETTEXTLENGTHEX, tGTL, 0&)
Call apiZeroMemory(tGTT, Len(tGTT))
tGTT.cb = lRet + 1
tGTT.flags = GT_DEFAULT
tGTT.codepage = CP_ACP
tGTT.lpDefaultChar = Chr(164) '0&
tGTT.lpUsedDefChar = 0&
sBuff = String$(lRet + 1, 0)
lRet1 = SendMessageRef(m_hWnd, EM_GETTEXTEX, tGTT, sBuff) 'CRASH!!
If (lRet1 > 0) Then
sRTText = Left$(sBuff, lRet1)
End If
As is, the code crashes the application on:
SendMessageRef(m_hWnd, EM_GETTEXTEX, tGTT, sBuff)
C Datatypes and all the fun stuff like memory management are a new experience to me and a prickly introduction.
Thanks, Bill
CODE:
Private Declare Function apiSendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal msg As Long, ByRef tGTT As Any, ByRef lp As Any) As Long
Dim tGTL As GETTEXTLENGTHEX
Dim tGTT As GETTEXTEX
Dim lRet As Long '
Dim lRet1 As Long
Dim sBuff As String
Dim sRTText As String
Call apiZeroMemory(tGTL, Len(tGTL))
tGTL.flags = GTL_NUMCHARS
tGTL.codepage = CP_ACP
'return number of TChars in RtichText control
lRet = SendMessageRef(m_hWnd, EM_GETTEXTLENGTHEX, tGTL, 0&)
Call apiZeroMemory(tGTT, Len(tGTT))
tGTT.cb = lRet + 1
tGTT.flags = GT_DEFAULT
tGTT.codepage = CP_ACP
tGTT.lpDefaultChar = Chr(164) '0&
tGTT.lpUsedDefChar = 0&
sBuff = String$(lRet + 1, 0)
lRet1 = SendMessageRef(m_hWnd, EM_GETTEXTEX, tGTT, sBuff) 'CRASH!!
If (lRet1 > 0) Then
sRTText = Left$(sBuff, lRet1)
End If