- long offset ;
- Handle datahandle = NewHandle(0) ;
- HLock( datahandle ) ;
- GetScrap( datahandle , dataFormat.GetFormatId() , &offset ) ;
- HUnlock( datahandle ) ;
- if ( GetHandleSize( datahandle ) > 0 )
- {
- long byteCount = GetHandleSize( datahandle ) ;
- if ( dataFormat.GetType() == wxDF_TEXT )
- data = new char[ byteCount + 1] ;
- else
- data = new char[ byteCount ] ;
-
- memcpy( (char*) data , (char*) *datahandle , byteCount ) ;
- if ( dataFormat.GetType() == wxDF_TEXT )
- ((char*)data)[byteCount] = 0 ;
- * len = byteCount ;
- }
- DisposeHandle( datahandle ) ;
+ long offset ;
+ Handle datahandle = NewHandle(0) ;
+ HLock( datahandle ) ;
+ GetScrap( datahandle , dataFormat.GetFormatId() , &offset ) ;
+ HUnlock( datahandle ) ;
+ if ( GetHandleSize( datahandle ) > 0 )
+ {
+ byteCount = GetHandleSize( datahandle ) ;
+ Size allocSize = byteCount ;
+ if ( dataFormat.GetType() == wxDF_TEXT )
+ allocSize += 1 ;
+ else if ( dataFormat.GetType() == wxDF_UNICODETEXT )
+ allocSize += 2 ;
+
+ data = new char[ allocSize ] ;
+
+ memcpy( (char*) data , (char*) *datahandle , byteCount ) ;
+ if ( dataFormat.GetType() == wxDF_TEXT )
+ ((char*)data)[byteCount] = 0 ;
+ if ( dataFormat.GetType() == wxDF_UNICODETEXT )
+ ((wxChar*)data)[byteCount/2] = 0 ;
+ *len = byteCount ;
+ }
+ DisposeHandle( datahandle ) ;