📄 myfile.step7
字号:
return(TRUE);
// An SMS message has arrived for this app. Message is in the dwParam above as (char *)
// sender simply uses this format "//BREW:ClassId:Message", example //BREW:0x00000001:Hello World
case EVT_APP_MESSAGE:
// Add your code here...
return(TRUE);
// A key was pressed. Look at the wParam above to see which key was pressed. The key
// codes are in AEEVCodes.h. Example "AVK_1" means that the "1" key was pressed.
case EVT_KEY:
// Add your code here...
if((wParam == AVK_CLR) && (pMe->status != STATUS_MENU))
{
IFILEMGR_Release(pMe->pMyFileMgr);
pMe->pMyFileMgr = NULL;
IMENUCTL_Redraw(pMe->pMenu);
IMENUCTL_SetActive(pMe->pMenu,TRUE);
pMe->status = STATUS_MENU;
return TRUE;
}
else //When the user press clear key and the current page is main menu, the application should exit.
return FALSE;
return(TRUE);
case EVT_COMMAND:
item = IMENUCTL_GetSel (pMe->pMenu);
switch(item)
{
case ID_CREATE_FILE:
CreateFile(pMe);
break;
case ID_READ_FILE:
ReadFile(pMe);
break;
default:
break;
}
return TRUE;
// If nothing fits up to this point then we'll just break out
default:
break;
}
return FALSE;
}
// this function is called when your application is starting up
boolean myfile_InitAppData(myfile* pMe)
{
// Get the device information for this handset.
// Reference all the data by looking at the pMe->DeviceInfo structure
// Check the API reference guide for all the handy device info you can get
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo);
// The display and shell interfaces are always created by
// default, so we'll asign them so that you can access
// them via the standard "pMe->" without the "a."
pMe->pIDisplay = pMe->a.m_pIDisplay;
pMe->pIShell = pMe->a.m_pIShell;
// Insert your code here for initializing or allocating resources...
pMe->pMenu = NULL;
pMe->pMyFileMgr = NULL;
// if there have been no failures up to this point then return success
return TRUE;
}
// this function is called when your application is exiting
void myfile_FreeAppData(myfile* pMe)
{
// insert your code here for freeing any resources you have allocated...
// example to use for releasing each interface:
// if ( pMe->pIMenuCtl != NULL ) // check for NULL first
// {
// IMENUCTL_Release(pMe->pIMenuCtl) // release the interface
// pMe->pIMenuCtl = NULL; // set to NULL so no problems trying to free later
// }
//
if(pMe->pMenu)
{
IMENUCTL_Release(pMe->pMenu);
pMe->pMenu = NULL;
}
if(pMe->pMyFileMgr)
{
IFILEMGR_Release(pMe->pMyFileMgr);
pMe->pMyFileMgr = NULL;
}
}
static void BuildMainMenu(myfile *pMe)
{
if(!pMe->pMenu)
{
if(ISHELL_CreateInstance(pMe->pIShell,AEECLSID_MENUCTL,(void**)&pMe->pMenu) != SUCCESS)
return ;
}
IMENUCTL_SetTitle(pMe->pMenu,MYFILE_RES_FILE,IDS_TITLE,NULL);
IMENUCTL_AddItem(pMe->pMenu,MYFILE_RES_FILE,IDS_CREATE_FILE,ID_CREATE_FILE,NULL,0);
IMENUCTL_AddItem(pMe->pMenu,MYFILE_RES_FILE,IDS_READ_FILE,ID_READ_FILE,NULL,0);
IMENUCTL_SetActive(pMe->pMenu,TRUE);
pMe->status = STATUS_MENU;
}
static void CreateFile(myfile *pMe)
{
IFile *pMyFile;
AECHAR w_str[100];
char str[100];
AECHAR str_open_fail[] = {'O','p','e','n',' ','f','i','l','e',' ','f','a','i','l','\0'};
AECHAR str_success[] = {'W','r','i','t','e',' ','S','u','c','c','e','s','s','\0'};
AECHAR str_fail[] = {'W','r','i','t','e',' ','F','a','i','l','\0'};
if(ISHELL_CreateInstance(pMe->pIShell, AEECLSID_FILEMGR,(void **)&pMe->pMyFileMgr))
return;
IMENUCTL_SetActive(pMe->pMenu,FALSE);
pMyFile = IFILEMGR_OpenFile(pMe->pMyFileMgr,"mydir/myfile.txt",_OFM_CREATE);
if(pMyFile == NULL)
{
IDISPLAY_ClearScreen(pMe->pIDisplay);
IDISPLAY_DrawText(pMe->pIDisplay, // Display instance
AEE_FONT_BOLD, // Use BOLD font
str_open_fail, // Text - Normally comes from resource
-1, // -1 = Use full string length
0, // Ignored - IDF_ALIGN_CENTER
0, // Ignored - IDF_ALIGN_MIDDLE
NULL, // No clipping
IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
IDISPLAY_Update(pMe->pIDisplay);
pMe->status = STATUS_CREATE;
return;
}
ISHELL_LoadResString(pMe->pIShell,MYFILE_RES_FILE,IDS_FILE_DATA,w_str,sizeof(w_str));
WSTRTOSTR(w_str,str,sizeof(str));
if(IFILE_Write(pMyFile,str,STRLEN(str)) == 0)
{
IDISPLAY_ClearScreen(pMe->pIDisplay);
IDISPLAY_DrawText(pMe->pIDisplay, // Display instance
AEE_FONT_BOLD, // Use BOLD font
str_fail, // Text - Normally comes from resource
-1, // -1 = Use full string length
0, // Ignored - IDF_ALIGN_CENTER
0, // Ignored - IDF_ALIGN_MIDDLE
NULL, // No clipping
IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
}
else
{
IDISPLAY_ClearScreen(pMe->pIDisplay);
IDISPLAY_DrawText(pMe->pIDisplay, // Display instance
AEE_FONT_BOLD, // Use BOLD font
str_success, // Text - Normally comes from resource
-1, // -1 = Use full string length
0, // Ignored - IDF_ALIGN_CENTER
0, // Ignored - IDF_ALIGN_MIDDLE
NULL, // No clipping
IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
}
IDISPLAY_Update(pMe->pIDisplay);
IFILE_Release(pMyFile);
pMe->status = STATUS_CREATE;
}
static void ReadFile(myfile *pMe)
{
IFile *pMyFile;
AECHAR str_open_fail[] = {'N','o',' ','S','u','c','h',' ','f','i','l','e','\0'};
char buf[100];
char *pDest;
AECHAR w_buf[100];
if(ISHELL_CreateInstance(pMe->pIShell, AEECLSID_FILEMGR,(void **)&pMe->pMyFileMgr))
return;
IMENUCTL_SetActive(pMe->pMenu,FALSE);
pMyFile = IFILEMGR_OpenFile(pMe->pMyFileMgr,"mydir/myfile.txt",_OFM_READ);
if(pMyFile == NULL)
{
IDISPLAY_ClearScreen(pMe->pIDisplay);
IDISPLAY_DrawText(pMe->pIDisplay, // Display instance
AEE_FONT_BOLD, // Use BOLD font
str_open_fail, // Text - Normally comes from resource
-1, // -1 = Use full string length
0, // Ignored - IDF_ALIGN_CENTER
0, // Ignored - IDF_ALIGN_MIDDLE
NULL, // No clipping
IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
IDISPLAY_Update(pMe->pIDisplay);
pMe->status = STATUS_READ;
return;
}
IFILE_Read(pMyFile,buf,sizeof(buf));
pDest = STRCHR(buf,'.');
pDest ++;
*pDest = 0;
STRTOWSTR(buf,w_buf,sizeof(w_buf));
IDISPLAY_ClearScreen(pMe->pIDisplay);
IDISPLAY_DrawText(pMe->pIDisplay, // Display instance
AEE_FONT_BOLD, // Use BOLD font
w_buf, // Text - Normally comes from resource
-1, // -1 = Use full string length
0, // Ignored - IDF_ALIGN_CENTER
0, // Ignored - IDF_ALIGN_MIDDLE
NULL, // No clipping
IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
IDISPLAY_Update(pMe->pIDisplay);
IFILE_Release(pMyFile);
pMe->status = STATUS_READ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -