home *** CD-ROM | disk | FTP | other *** search
- PROGRAM MultiHider;
-
- {$R MultiHider.Rsrc}
- {$U-}
-
- USES Memtypes,QuickDraw,OSIntf,ToolIntf,PackIntf;
-
- CONST
- itemOK = 7;
- itemCancel = 8;
- itemStat1 = 1;
- itemStat2 = 3;
- itemStat3 = 4;
- itemEdit1 = 2;
- itemEdit2 = 5;
- itemEdit3 = 6;
- itemHider = 9;
- itemHideIt = 10;
- itemMax = 10;
- VAR
- ihDialog: DialogPtr;
- itemHit: INTEGER;
- theType: INTEGER;
- theHdl: Handle;
- theBox: Rect;
- hidden: BOOLEAN;
-
-
- PROCEDURE MyDrawItem(dlg: DialogPtr; theItem: INTEGER);
- VAR
- iType: INTEGER;
- iBox: Rect;
- iHdl: Handle;
- iIndex: INTEGER;
-
- BEGIN
- GetDItem(dlg, theItem, iType, iHdl, iBox);
- IF hidden THEN BEGIN
- PenMode(notPatBic);
- PenPat(gray);
- BackPat(gray);
- PaintRect(iBox);
- FrameRect(iBox);
-
- PenMode(patCopy);
- PenPat(black);
- BackPat(white);
- PenNormal;
- END;
- END;
-
-
- PROCEDURE HideEditItem(theDialog: DialogPtr; theItem: INTEGER);
- VAR
- iIndex: INTEGER;
- BEGIN
- (* Get the item information. *)
- GetDItem(theDialog, theItem, theType, theHdl, theBox);
-
- (* Now check to see if it is the current text item. *)
- IF DialogPeek(theDialog)^.EditField + 1 = theItem THEN BEGIN
- (* It is, so now we find the next editText item *)
- (* in the item list. Start with the one we are on.*)
- iIndex := theItem;
- REPEAT
- (* Increment to the next item, and make sure we *)
- (* don't run off the end of the item list. *)
- iIndex := iIndex + 1;
- IF iIndex > itemMax THEN iIndex := 1;
- GetDItem(theDialog, iIndex, theType, theHdl, theBox);
-
- (* Keep going until we find an editText item. *)
- (* NOTE: THIS CODE ASSUMES THERE IS MORE THAN *)
- (* ONE editText ITEM IN THE DIALOG. *)
- UNTIL (theType = editText);
- SelIText(theDialog, iIndex, 0, 0);
- END;
- GetDItem(theDialog, theItem, theType, theHdl, theBox);
- SetDItem(theDialog, theItem, statText, theHdl, theBox);
- DrawDialog(theDialog);
- END;
-
-
- PROCEDURE ShowEditItem(theDialog: DialogPtr; theItem: INTEGER);
- VAR
- oldPort: GrafPtr;
- BEGIN
- GetPort(oldPort);
- SetPort(theDialog);
- GetDItem(theDialog, theItem, theType, theHdl, theBox);
- SetDItem(theDialog, theItem, editText, theHdl, theBox);
- InvalRect(theBox);
- DrawDialog(theDialog);
- SetPort(oldPort);
- END;
-
-
- BEGIN {main program}
- InitGraf (@thePort); {the big five inits}
- InitFonts;
- InitWindows;
- TEInit;
- InitDialogs (nil);
-
- hidden := FALSE;
-
- ihDialog := GetNewDialog(128, NIL, WindowPtr(-1));
- GetDItem(ihDialog, itemHider, theType, theHdl, theBox);
- SetDItem(ihDialog, itemHider, theType, @MyDrawItem, theBox);
- ShowWindow(ihDialog);
-
- itemHit := 0;
- WHILE ((itemHit <> itemOK) AND (itemHit <> itemCancel)) DO BEGIN
- ModalDialog(nil, itemHit);
- CASE itemHit OF
- itemHideIt: BEGIN
- GetDItem(ihDialog, itemHit, theType, theHdl, theBox);
- hidden := NOT hidden;
- IF hidden THEN BEGIN
- SetCtlValue(ControlHandle(theHdl), 1);
- HideEditItem(ihDialog, itemEdit2);
- END ELSE BEGIN
- SetCtlValue(ControlHandle(theHdl), 0);
- ShowEditItem(ihDialog, itemEdit2);
- END;
- END;
- END;
- END;
-
- DisposDialog(ihDialog);
- END.
-