home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-23 | 1.5 KB | 88 lines | [TEXT/MWPS] |
- { MySystemUtils.p
- {
- { Pascal version by Bill Catambay
- { Original C version by Kenneth Worley
- { Public Domain
- }
- Unit MySystemUtils;
-
- Interface
-
- Uses
- Types, Windows, Fonts, Dialogs;
-
- Procedure InitToolbox;
- Function GetSysVersion: integer;
- Function HasColorQuickDraw: Boolean;
- Function WindowDevice( winPtr: WindowPtr): GDHandle;
-
- Implementation
-
- Procedure InitToolbox;
-
- begin
- { Initialize the Mac Toolbox Managers }
- InitGraf(@qd.thePort);
- InitFonts;
- InitWindows;
- InitMenus;
- FlushEvents(everyEvent,0);
- TEInit;
- InitDialogs(NIL);
- InitCursor;
- end;
-
- Function GetSysVersion: integer;
-
- Var
- env: SysEnvRec;
- err: OSErr;
-
- begin
- GetSysVersion := 0;
- err := SysEnvirons( 2, env );
- if err <> NoErr then
- exit(GetSysVersion);
- if env.systemVersion >= $0700 then
- GetSysVersion := 7
- else if env.systemVersion >= $0600 then
- GetSysVersion := 6;
- end;
-
- Function HasColorQuickDraw: Boolean;
-
- Var
- env: SysEnvRec;
- err: OSErr;
-
- begin
- err := SysEnvirons( 2, env );
- if err = NoErr then
- HasColorQuickDraw := env.hasColorQD
- else
- HasColorQuickDraw := false;
- end;
-
- Function WindowDevice( winPtr: WindowPtr): GDHandle;
-
- Var
- theDevice: GDHandle;
- targetPt: Point;
-
- begin
- targetPt := winPtr^.portRect.topLeft;
- theDevice := GetDeviceList;
- while (not PtInRect(targetPt, theDevice^^.gdRect)) do
- begin
- theDevice := GetNextDevice( theDevice );
- if theDevice = NIL then
- begin
- theDevice := GetMainDevice;
- leave;
- end;
- end;
- WindowDevice := theDevice;
- end;
-
- End.
-