home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-19 | 3.0 KB | 125 lines | [TEXT/CWIE] |
- //
- // You may incorporate this sample code into your
- // applications without restriction. This sample code has
- // been provided "AS IS" and the responsibility for its
- // operation is 100% yours. You are not permitted to
- // redistribute the source as "Apple sample 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
- // code, but that you've made changes.
- //
-
- #define OLDROUTINELOCATIONS 0
- #define OLDROUTINENAMES 0
- #define SystemSevenOrLater 1
-
- #ifndef __FONTS__
- # include <Fonts.h>
- #endif
-
- #ifndef __DIALOGS__
- # include <Dialogs.h>
- #endif
-
- #ifndef __QDOFFSCREEN__
- # include <QDOffscreen.h>
- #endif
-
- static pascal OSErr InitMac (void)
- {
- MaxApplZone ( );
- InitGraf (&(qd.thePort));
- InitFonts ( );
- InitWindows ( );
- InitMenus ( );
- TEInit ( );
- InitDialogs (nil);
-
- return noErr;
- }
-
- static pascal Boolean SetColorTableEntry (CTabHandle cth, short value, const RGBColor *rgbP)
- {
- ColorSpecPtr ctTable = (**cth).ctTable;
- short ctSize = (**cth).ctSize;
-
- while (ctSize > -1)
- {
- if (ctTable->value == value)
- {
- ctTable->rgb = *rgbP;
- CTabChanged (cth);
- return true;
- }
-
- ++ctTable;
- --ctSize;
- }
-
- return false;
- }
-
- void main (void)
- {
- if (InitMac ( ))
- SysBeep (10);
- else
- {
- WindowRef window;
- Rect boundsRect = qd.screenBits.bounds;
-
- //
- // [1] Create a window which covers most of the main screen.
- // Make it invisible for now.
- //
- // [2] Get the window's color table.
- //
- // [3] 'winCTabHandle' is the default color table because we've
- // just now created the window out of thin air. We don't want
- // to change the default color table, so make a copy.
- //
- // [4] Set the background entry (0) of the color table.
- //
- // [5] Set the window's color table.
- //
- // [6] Up till now, none of the changes we've made have been
- // visible. That's the way we've wanted it because the whole
- // purpose here is to avoid visible changes, which result in
- // flicker.
- //
- // [7] Wait for the user to click,
- // then put a smart-aleck message in the debugger.
- //
-
- InsetRect (&boundsRect,10,10); // 1
- boundsRect.top += GetMBarHeight ( ); // 1
- window = NewCWindow (nil,&boundsRect,"\p",false,plainDBox,(WindowRef)-1,false,0); // 1
- if (window) // 1
- {
- WCTabHandle winCTabHandle; // 2
- AuxWinHandle auxWinHandle; // 2
-
- GetAuxWin (window,&auxWinHandle); // 2
- winCTabHandle = (WCTabHandle) ((**auxWinHandle).awCTable); // 2
-
- HandToHand ((Handle *) &winCTabHandle); // 3
- if (!MemError ( )) // 3
- {
- RGBColor blackness = { 0, 0, 0 }; // 4
-
- if (SetColorTableEntry ((CTabHandle) winCTabHandle, 0, &blackness)) // 4
- {
- SetWinColor (window,winCTabHandle); // 5
-
- ShowWindow (window); // 6
-
- while (!Button ( )) ; // 7
- DebugStr ("\pNotice any flicker? I thought not."); // 7
- }
- }
- DisposeWindow (window);
- }
- }
- }
-