home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-16 | 4.3 KB | 203 lines | [TEXT/KAHL] |
- /*** File: "StandAlone_v00.c"
- *
- * Versione 00. Del 25-09-94.
- * Scritto da Cadili Francesco.
- *
- * Legge i dati relativi ad un film da DB.
- ************************************************/
- #include "StandAlone_v00.h"
- #include <Windows.h>
- #include <Dialogs.h>
- #include <Fonts.h>
- #include <TextEdit.h>
- #include <ToolUtils.h>
- #include <Resources.h>
- #include <Memory.h>
- #include <Menus.h>
- #include <Desk.h>
-
- /******** Dichiarazioni private ************************/
- /******** Include Locali *******************************/
-
- #include "StandAloneMenu_v00.h"
- #include "stringUtility_v02.h"
- #ifdef CONTROLLORISORSE
- #include "ControlloRisorse.h"
- #endif
- #pragma segment StandAlone
- /******** Fine Include Locali **************************/
- /******** Strutture dati locali ************************/
-
- /********* Fine Strutture dati locali *******************/
- /******** Costanti locali ******************************/
-
- #define ckkID 128
- WindowPtr frontmost;
- Cursor iBeam;
-
- /******** Fine Costanti locali *************************/
- /******** Funzioni private: ****************************/
-
- void InitMacintosh(void);
- int HandleMouseDown(EventRecord *theEvent);
- int HandleEvent(void);
- int checkForCode(void);
- void CantOpen(void);
-
- /******** Fine Funzioni private ************************/
- /******** Fine Dichiarazioni private ********************/
-
- /*** InitMacintosh()
- *
- * Inizializza i manager e la memoria
- *
- ****************************************/
- void InitMacintosh(void)
- {
- MaxApplZone();
- InitGraf(&qd.thePort);
- InitFonts();
- FlushEvents(everyEvent, 0);
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(0L);
- InitCursor();
- }
- /* end InitMacintosh */
-
-
- /*** HandleMouseDown(&theEvent)
- *
- * Elabora un evento di tipo "mouse Down".
- *
- * Par INPUT: 'theEvent' il descrittore dell'evento corrente.
- * Val OUTPUT: TRUE se deve proseguire nell'elaborazione
- * FALSE se deve terminare.
- *
- *****************************************************************/
- int HandleMouseDown (EventRecord *theEvent)
- {
- WindowPtr theWindow;
- int windowCode = FindWindow(theEvent->where, &theWindow);
- int computeNext = true;
-
- switch (windowCode)
- {
- case inSysWindow:
- SystemClick (theEvent, theWindow);
- break;
-
- case inMenuBar:
- computeNext = HandleMenu(MenuSelect(theEvent->where));
- break;
- }
- return(computeNext);
- }
- /* end HandleMouseDown */
-
-
- /*** HandleEvent()
- *
- * Elabora un evento. (elabora solo un evento).
- *
- * Val OUTPUT: TRUE se deve proseguire nell'elaborazione
- * FALSE se deve terminare.
- *
- ************************************************************/
- int HandleEvent(void)
- {
- int evento;
- int computeNext = true;
- EventRecord theEvent;
-
- HiliteMenu(0);
- SystemTask (); // permette l'elaborazione ai "desk accessory"
-
- evento = GetNextEvent (everyEvent, &theEvent);
- if (evento)
- switch (theEvent.what)
- {
- case mouseDown:
- computeNext = HandleMouseDown(&theEvent);
- break;
-
- case keyDown:
- case autoKey:
- if ((theEvent.modifiers & cmdKey) != 0)
- computeNext = HandleMenu(MenuKey((char) (theEvent.message & charCodeMask)));
- break;
- }
- return(computeNext);
- }
- /* end HandleEvent */
-
- /*** main()
- *
- ********************/
- void main(void)
- {
- CursHandle hCurs;
-
- InitMacintosh();
- if (!checkForCode())
- {
- SysBeep(20);
- CantOpen();
- return;
- }
- SetUpMenus();
-
- hCurs = GetCursor(1);
- #ifdef CONTROLLORISORSE
- CaricaRisorsa('CURS', 1);
- #endif
- if (hCurs == NULL)
- iBeam = qd.arrow;
- else
- iBeam = **hCurs;
-
- while(HandleEvent());
- }
- /* end main */
-
- /*** checkForCode()
- *
- * Controlla la presenza del codice di controllo.
- *
- * Val OUTPUT: TRUE se รจ presente, FALSE altrimenti.
- *
- *****************************************************/
- int checkForCode(void)
- {
- Handle chkHdl;
-
- #ifdef CONTROLLORISORSE
- CaricaRisorsa('chk?', ckkID);
- #endif
- return(compareCHandleToPascal(GetResource('chk?', ckkID), "\pcode:10200"));
- }
- /* end checkForCode */
-
- /*** CantOpen()
- *
- * Errore nell'apertura del file delle risorse
- *
- *****************************************************/
- void CantOpen(void)
- {
- Rect r;
- WindowPtr window;
-
- SetRect(&r, 152, 60, 410, 132);
- SetPort((window = NewWindow( (Ptr) 0L, &r, "\p", true, dBoxProc, (WindowPtr) -1L, false, 0L)));
- TextFont(0);
- MoveTo(4, 20);
- DrawString("\pNon posso aprire il file delle risorse.");
- MoveTo(4, 40);
- DrawString("\pPremi il bottone del mouse per uscire.");
- do {
- } while (!Button());
- }
- /* end CantOpen */
-