Dialog help
Gary,
You can do edit line length restriction either in a modal dialog filter or when
ModalDialog returns a hit in the edit line. In the filter is cleaner since the
extra character never actually shows up, you can look at the example DialogBits
2.0.1 on a developer CD if you have access to one.
It's a little long to put in here, and anyway I _again_ don't have my CD drive
turned on, you'd think I'd learn…..
If you want to do it after the return from ModalDialog, just add something like
this…..
ModalDialog(nil,&hititem);
if (hititem == kMyEditLine) {
GetDItem(myDialog, kMyEditLine, &itemType, &itemhandle, &itemRect);
GetIText(itemhandle, &tempString);
/* don't want them to go over 20 characters */
if (tempString[0] > 20) {
SysBeep(1); /* yell */
tempString[0] = 20; /* reset len to 20 */
SetIText(itemhandle, &tempString); /* reset edit line
}
As for converting from text to a double, there isn't a toolbox function to do
this. I would say a creative use of the C StdLib function sprintf(…) would
work, that's the way I usta do it on IBMs. Or, you could just walk the
resulting character string (from GetIText) looking for the '.' and hand-make a
double. Someone else hasd got to have a better idea….
CKH