From: infodesk laplage on 30 Nov 2006 11:25 I prototyped an access and assign method for the functions SetTerBuffer and GetTerBuffer of the TE control. In the assign method I often get an error <<could not obtain buffer lock>>. In the access method I always get the error <<ran out of memory>> Something is wrong and I can't find what. functions : _DLL FUNCTION SetTerBuffer (hWnd AS PTR, hbuffer AS PSZ, size AS INT, title AS STRING, release AS LOGIC) AS LOGIC PASCAL:TER14.SetTerBuffer _DLL FUNCTION GetTerBuffer (hWnd AS PTR) AS PTR PASCAL:TER14.GetTerBuffer Wrapper-class methods : ACCESS rtftekst () CLASS TEcontrol LOCAL rtfhandle AS PTR LOCAL rtftext AS STRING LOCAL lengte AS LONG lengte := 0 rtftext := "" rtfhandle := GetTerBuffer(SELF:TEHandle) HandleToStr(rtftext,lengte,rtfhandle) RETURN rtftext ASSIGN rtftekst (tekstrtf) CLASS TEcontrol LOCAL size AS DWORD LOCAL ptrtekst AS PSZ ptrtekst := String2Psz(tekstrtf) size := Len(tekstrtf) SetTerBuffer(SELF:TEHandle,ptrtekst,size,"",TRUE) RETURN Help appreciated, Frank Rouser�, Westende, Belgium
From: Greg on 30 Nov 2006 12:00 Frank, Look up the GetTerBuffer method in the help file. You must lock the returned memory block. Here's my TextValue Access method: ACCESS TextValue( ) CLASS TEControl LOCAL pszBuffer AS PSZ LOCAL iSize AS INT LOCAL ptrBuffer AS PTR LOCAL pTemp AS PTR LOCAL cBuffer AS STRING ptrBuffer := GetTerBuffer( SELF:TEHandle, @iSize ) pTemp := GlobalLock( ptrBuffer ) pszBuffer := PSZ( Buffer( MAX_ALLOC ) ) MemCopy( pszBuffer, pTemp, iSize ) GlobalUnlock( ptrBuffer ) GlobalFree( ptrBuffer ) cBuffer := Psz2String( pszBuffer ) RETURN cBuffer Here's my TextValue Assign method: ASSIGN TextValue( uValue ) CLASS TEControl TerInsertText( SELF:TEHandle, uValue, -1, -1, TRUE ) RETURN uValue Here's my TextValueRTF Assign method: ASSIGN TextValueRTF( uValue ) CLASS TEControl LOCAL iSize AS INT LOCAL m, n AS DWORD LOCAL aMargin AS ARRAY iSize := Len( uValue ) + 1 InsertRTFBuf( SELF:TEHandle, PSZ( uValue ), iSize, -2, -1, TRUE ) aMargin := {{"\margl",-1},{"\margr",-1},{"\margt",-1},{"\margb",-1}} FOR m:=1 TO 4 IF (n:=At(aMargin[m,1],uValue)) > 0 aMargin[m,2] := Val(SubStr(uValue,n+6,At("\",SubStr(uValue,n+6))-1)) ENDIF NEXT TerSetMargin( SELF:TEHandle, aMargin[1,2], aMargin[2,2], aMargin[3,2], aMargin[4,2], TRUE ) RETURN uValue I have prototyped SetTerBuffer but I haven't had the need to use it. HTH, Greg
From: infodesk laplage on 1 Dec 2006 11:46 Assign works, Access not. I get an compiler error on ptrBuffer := GetTerBuffer( SELF:TEHandle, @iSize ) <<Illegal convertion to Long>> When I set iSize instaed of @iSize, I get an another error message. When I leave this parameter behind, no error is generated. However the length of the rtf-stream is then unknown. Thanks for your code, Frank Rouser� "Greg" <ggarza(a)ruddwisdom.com> schreef in bericht news:1164906022.285367.295780(a)16g2000cwy.googlegroups.com... > Frank, > > Look up the GetTerBuffer method in the help file. You must lock the > returned memory block. > > Here's my TextValue Access method: > > ACCESS TextValue( ) CLASS TEControl > LOCAL pszBuffer AS PSZ > LOCAL iSize AS INT > LOCAL ptrBuffer AS PTR > LOCAL pTemp AS PTR > LOCAL cBuffer AS STRING > > ptrBuffer := GetTerBuffer( SELF:TEHandle, @iSize ) > > pTemp := GlobalLock( ptrBuffer ) > pszBuffer := PSZ( Buffer( MAX_ALLOC ) ) > > MemCopy( pszBuffer, pTemp, iSize ) > > GlobalUnlock( ptrBuffer ) > GlobalFree( ptrBuffer ) > > cBuffer := Psz2String( pszBuffer ) > > RETURN cBuffer > > Here's my TextValue Assign method: > > ASSIGN TextValue( uValue ) CLASS TEControl > TerInsertText( SELF:TEHandle, uValue, -1, -1, TRUE ) > RETURN uValue > > Here's my TextValueRTF Assign method: > > ASSIGN TextValueRTF( uValue ) CLASS TEControl > LOCAL iSize AS INT > LOCAL m, n AS DWORD > LOCAL aMargin AS ARRAY > > iSize := Len( uValue ) + 1 > > InsertRTFBuf( SELF:TEHandle, PSZ( uValue ), iSize, -2, -1, TRUE ) > > aMargin := {{"\margl",-1},{"\margr",-1},{"\margt",-1},{"\margb",-1}} > FOR m:=1 TO 4 > IF (n:=At(aMargin[m,1],uValue)) > 0 > aMargin[m,2] := > Val(SubStr(uValue,n+6,At("\",SubStr(uValue,n+6))-1)) > ENDIF > NEXT > TerSetMargin( SELF:TEHandle, aMargin[1,2], aMargin[2,2], > aMargin[3,2], aMargin[4,2], TRUE ) > > RETURN uValue > > > I have prototyped SetTerBuffer but I haven't had the need to use it. > > HTH, > > Greg >
From: Greg on 1 Dec 2006 12:32 Frank, It looks like your prototype of the GetTerBuffer is incorrect. Here's what the version 13 help file says: HANDLE GetTerBuffer(hWnd, size) HWND hWnd; // Handle of the window to be accessed long far*size; // The GetTerBuffer function returns the size of the global buffer using this variable My prototype looks like this: _DLL FUNCTION GetTerBuffer( hWnd AS PTR, size REF INT ) AS PTR PASCAL:TER32.GetTerBuffer Your prototype looks like this: _DLL FUNCTION GetTerBuffer (hWnd AS PTR) AS PTR PASCAL:TER14.GetTerBuffer Has the size parameter been removed in version 14? HTH, Greg
From: Frank Rouser� on 4 Dec 2006 07:04 My prototype is indeed false. I didn't reference the size parameter. Sometimes the solution is too simple... This was stupid on my behalf. The TE-control works properly now. Thanks, Frank "Greg" <ggarza(a)ruddwisdom.com> schreef in bericht news:1164994353.663280.237910(a)16g2000cwy.googlegroups.com... > Frank, > > It looks like your prototype of the GetTerBuffer is incorrect. > > Here's what the version 13 help file says: > > HANDLE GetTerBuffer(hWnd, size) > > HWND hWnd; > // Handle of the window to be accessed > > long far*size; > // The GetTerBuffer function returns the size of the global buffer > using this variable > > My prototype looks like this: > > _DLL FUNCTION GetTerBuffer( hWnd AS PTR, size REF INT ) AS PTR > PASCAL:TER32.GetTerBuffer > > Your prototype looks like this: > > _DLL FUNCTION GetTerBuffer (hWnd AS PTR) AS PTR > PASCAL:TER14.GetTerBuffer > > Has the size parameter been removed in version 14? > > HTH, > > Greg >
|
Pages: 1 Prev: CAVORT20.DLL and 2.7 Next: InternetWiteFile (to upload files using HTTP) |