home *** CD-ROM | disk | FTP | other *** search
- /*
- main.c
-
- Use of ictb snippet
- Albert Hui -- MacDTS
-
- This snippet shows the an example of ictb resource this is discussed in
- Inside Macintosh:Macintosh Toolbox Essentials, page 6-158 t0 6-164.
- It is based on the Dialog Manager Q&A technote. You can find the technote
- in the latest developer CD:
-
- Dev.CD Jun 96 RL
- Technical Documentation
- Macintosh Technical Notes
- Archive
- Toolbox
- tb_525.html.
-
- There is no Rez template for it, and no ResEdit template or editor. This sample
- ictbSample.r shows how you can do one by hand.
-
- The best solution is to get Resorcerer which provides an excellent ictb editor.
- With Resorcerer, it is really simple to use ictb in your dialog boxes.
-
- This sample is built with CW 9.
- */
-
- #include <TextEdit.h>
-
- // constants
-
- #define kMyDialog 128
- #define kDone 1
- #define kCheckOneItem 2
- #define kCheckTwoItem 3
- #define kCheckThreeItem 4
- #define kEditTextItem1 5
- #define kEditTextItem2 6
- #define kEditTextItem3 7
-
- // prototypes
-
- void main(void);
- void InitStuff(void);
- void DoDialog(void);
- void SetupDialog(DialogPtr theDialog);
- void PrepareFreeDialog(DialogPtr theDialog);
-
-
-
-
- /* main entry point */
-
- void main(void)
- {
- InitStuff();
- DoDialog();
- ExitToShell();
- }
-
-
- /* initialize the Mac managers */
-
- void InitStuff(void)
- {
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(nil);
- InitCursor();
- FlushEvents(everyEvent,0);
- }
-
-
- /* display dialog, and handle pretty standard ModalDialog loop.
- */
-
- void DoDialog(void)
- {
- DialogPtr theDialog;
- short item;
- ControlHandle checkBoxControl;
- short iType;
- Rect iRect;
-
- theDialog = GetNewDialog(kMyDialog,nil,(WindowPtr)-1L);
-
- do {
- ModalDialog(NULL,&item);
- switch (item) {
- case kCheckOneItem: // check boxes
- case kCheckTwoItem:
- case kCheckThreeItem:
- GetDItem(theDialog,item,&iType,(Handle *)&checkBoxControl,&iRect);
- SetCtlValue(checkBoxControl,!GetCtlValue(checkBoxControl));
- break;
- }
- } while (item!=kDone);
-
- DisposeDialog(theDialog);
- }
-
-
-
-
-