#include <Quickdraw.h>
#include <Windows.h>

/* Old libraries used to have a global variable called qd; now we must create one */
QDGlobals qd;
Rect windRect;

int Initialize(void) {
	WindowPtr window;
	
	InitGraf(&qd.thePort);					/* Initialize the toolbox */
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(NULL);
	InitCursor();

	windRect = qd.screenBits.bounds;		/* fullscreen window */
	InsetRect(&windRect, 50, 50);			/* minus 50 pixels on each side */
	window = NewWindow(NULL, &windRect, "\phello.c", true, documentProc,
		(WindowPtr)(-1), false, 0);			/* create a window */
	if(!window) return -1;
	SetPort(window);						/* set the graph port */

	return 0;
}

main() {
	EventRecord myEvent;
	if(Initialize()) exit(1);
	
	TextSize(48);							/* set the text size */
	MoveTo(windRect.left, windRect.top);	/* move the pen */
	DrawString("\pHello, World!");			/* draw the text */
	
	for(;;) {								/* loop until a button is pressed */
		SystemTask();
		if(WaitNextEvent(everyEvent, &myEvent, 5L, NULL))
			if(myEvent.what == mouseDown) break;
	}
	
	return 0;
}