I dont know if this is a typo in your code but the new string that you alloc is called 
newText but then you use newText in WinDrawChars.

Also a suggestion, if you are not going to change the DB record then you can do a 
DmQueryRecord instead of a DmGetRecord and then you dont need to do a DmReleaseRecord. 

Another suggestion, you could write the record directly without copying it to a temp 
string first:

recHandle = DmQueryRecord(TestDB,CurrentRecord);
recText = MemHandleLock(recHandle);
FntSetFont(stdFont);
WinSetUnderlineMode(noUnderline);
WinDrawChars(testTxt,20,bounds.topLeft.x,bounds.topLeft.y);
MemHandleUnlock(recHandle);

Chris

On Wed, 24 Nov 1999 15:50:35 +0530 [EMAIL PROTECTED] wrote:
> Hi ,
> 
>    Thanks for The suggestions given to HTML viewer.
> 
>    In an application, I tried to display a text  in a window resource, but
> each time it diplayed some garbage.
> 
>     Code used in the program to retrieve a record and display it on a window
> is given below .
> CurrentRecord  always has value 0 ( for test purpose ) .
> 
> Code :
> 
> if (CurrentRecord != noRecordSelected && DmNumRecords(TestDB) > 0) {
>      // Get a handle for the first record.
>      recHandle = DmGetRecord(TestDB,CurrentRecord);
> 
>      #ifdef saveForReference
>       // Lock down the handle and get a pointer to the record data.
>        recText = MemHandleLock(recHandle);
> 
>       // Allocate a new memory chunk that will contain a copy of the data.
>      newHandle = MemHandleNew(StrLen(recText) + 1);
> 
>      // Lock down the handle and get a pointer to the memory chunk.
>      newText = MemHandleLock(newHandle);
> 
>      StrCopy(newText,recText);
>     // Unlock the new memory chunk.
>     MemHandleUnlock(newHandle);
> 
>     // Unlock the database record.
>     MemHandleUnlock(recHandle);
> 
>     // Release the record to the database system.
>     // (The zero means that the record data hasn't been changed.)
>     DmReleaseRecord(TestDB, CurrentRecord, 0);
> 
>   #endif
> 
>   FntSetFont(stdFont);
>   WinSetUnderlineMode(noUnderline);
>   WinDrawChars(testTxt,20,bounds.topLeft.x,bounds.topLeft.y);
> 
>           I pass 20 as the length of the string , b'cos using StrLen
> function retuns  zero.
> testTxt  is a CharPtr .
> 
> Do I have to do any conversion of the data got from the record , before
> being displayed ?
> Pl. suggest a better method if any.
> 
> TIA ,
> 
>   Alagesh
>   mail : [EMAIL PROTECTED]
> 
> 
> 
> 
> --------------------------------------------------------------
> Robosoft Technologies, Mangalore, India




This message sent using EMUmail.  http://EmuMail.com

Reply via email to