Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
main.c
/* |
File: main.c |
Contains: 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 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. |
Written by: Albert Hui |
Copyright: Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved. |
You may incorporate this Apple sample source code into your program(s) without |
restriction. This Apple sample source code has been provided "AS IS" and the |
responsibility for its operation is yours. You are not permitted to redistribute |
this Apple sample source code as "Apple sample source code" after having made |
changes. If you're going to re-distribute the source, we require that you make |
it clear in the source that the code was descended from Apple sample source |
code, but that you've made changes. |
Change History (most recent first): |
8/6/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1 |
*/ |
#include <TextEdit.h> |
#include <Fonts.h> |
#include <Windows.h> |
#include <Dialogs.h> |
#include <Menus.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: |
GetDialogItem(theDialog,item,&iType,(Handle *)&checkBoxControl,&iRect); |
SetControlValue(checkBoxControl,!GetControlValue(checkBoxControl)); |
break; |
} |
} while (item!=kDone); |
DisposeDialog(theDialog); |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-30