⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hello.c

📁 PALM程序设计入门
💻 C
字号:
#include <Pilot.h>
#include "hello.h"

static Boolean HelloFormEventHandler(EventPtr event)
{
	Boolean handled = false;

	switch (event->eType) {

      case ctlSelectEvent:
        FrmCustomAlert(cmdButton, "aa", "bb", NULL);
        handled=true;
        break;

		case frmOpenEvent:

			FrmDrawForm(FrmGetActiveForm());
			handled = true;
			break;

      case menuEvent:
         if(event->data.menu.itemID==cmdMenu_1)
             SndPlaySystemSound(sndInfo);
         else
             SndPlaySystemSound(sndStartUp);
         handled=true;
         break;

	}

	return (handled);
}

static Boolean ApplicationHandleEvent(EventPtr event)
{
	FormPtr form;
	Word    formID;
	Boolean handled = false;

	if (event->eType == frmLoadEvent) {
		formID = event->data.frmLoad.formID;
		form   = FrmInitForm(formID);

		FrmSetActiveForm(form);

		switch (formID)  {
			case formID_hello:
				FrmSetEventHandler(form, HelloFormEventHandler);
				break;
		}

		handled = true;
	}

	return (handled);
}

static void StartApplication()
{
	FrmGotoForm(formID_hello);
}

static void EventLoop(void)
{
	short			err;
	int			formID;
	FormPtr		form;
	EventType		event;

	do {
		EvtGetEvent(&event, evtWaitForever);

		if (SysHandleEvent(&event)) continue;

		if (MenuHandleEvent(NULL, &event, &err))	continue;

		if (ApplicationHandleEvent(&event)) continue;

		FrmDispatchEvent(&event);

	} while (event.eType != appStopEvent);
}

static void StopApplication(void)
{
	FrmCloseAllForms();
}

DWord PilotMain (Word cmd, Ptr cmdPBP, Word launchFlags)
{
	if (cmd ==  sysAppLaunchCmdNormalLaunch) {
		StartApplication();
		EventLoop();
		StopApplication();
	}

	return (0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -