Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / April 2007



Tip: Looking for answers? Try searching our database.

setting maximum length of TERec  structure ( mac)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vcmac - 27 Apr 2007 10:54 GMT
Hi,

How could we set the maximum lenght of a TERec structure.
We want to set the maximum lenght for extended-edit type in mac to suppose
32767,
How should we do it ?

we coded like as below. But still (*teHandle)->teLength is not modified.
where teHandle is of typr **TERec

if( len > 32767 )   
{
    len = 32767;
    HLock ((Handle)teHandle) ;
    (*teHandle)->teLength = len;
    (*teHandle)->selEnd = (*teHandle)->teLength ;
    HUnlock ((Handle)teHandle) ;
}

Please suggest any way to achieve this ?

Thanks and Regards
Sanjaya
David Phillip Oster - 27 Apr 2007 15:41 GMT
In article
<ad89a2b9c20fdb1ead08c995194e075e@localhost.talkaboutmac.com>,

> Hi,
>
[quoted text clipped - 19 lines]
> Thanks and Regards
> Sanjaya

In my own code, I use a keyDown handler that, after it has checked for
Clear, Left, Right, Up, Down, Home, End, PageUp, PageDown, and backSpace
does:

  if(TEMAX -1 <= (**text).teLength){
     TellAnyError(MUSTTRUNCATE);
  }else{
     TEKey(chr, text);
  }

With a similar protection on Paste.

There is similar code in LTextEditView.cp

1.) a TE can't handle even 32767 characters. Pick a smaller maximum.
2.) You don't need to lock a teHandle to assign to if from simple
variables.
3.) Rarely do HLock() xxx HUnlock(). What if it were already locked on
entry?
You should use HGetState(); HLock(); xxx HSetState();
4.) Don't assign to selEnd. Use TESetSelection()
5.) You also have to resize the actual hText text handle with
SetHandleSize()
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.