switch(id)
{
case ID_MENUITEMOPEN:
{
TCHAR *srcTxt = "D:/text.txt";
char srcStr[50] ;
FILE *fp = fopen(srcTxt,"r");
if (fp != NULL)
{
fgets(srcStr,sizeof(srcStr),fp);
fclose(fp);
SetDlgItemText(hwnd,IDC_EDITCONTENT,TEXT(srcStr));
}
else
{
MessageBox(hwnd,TEXT("文件无法打开"),TEXT("error"),MB_OK);
}
}
break;
case ID_MENUITEMSAVE:
{
TCHAR *srcTxt = "D:\\text.txt";
TCHAR srcStr[256];
FILE *fp = fopen(srcTxt,"wt");
if (fp != NULL)
{
GetDlgItemText(hwnd,IDC_EDITCONTENT,srcStr,sizeof(srcStr));
fputs(srcStr,fp);
fclose(fp);
}
else
{
MessageBox(hwnd,TEXT("文件无法打开"),TEXT("error"),MB_OK);
}
}
break;
{
case ID_MENUITEMOPEN:
{
TCHAR *srcTxt = "D:/text.txt";
char srcStr[50] ;
FILE *fp = fopen(srcTxt,"r");
if (fp != NULL)
{
fgets(srcStr,sizeof(srcStr),fp);
fclose(fp);
SetDlgItemText(hwnd,IDC_EDITCONTENT,TEXT(srcStr));
}
else
{
MessageBox(hwnd,TEXT("文件无法打开"),TEXT("error"),MB_OK);
}
}
break;
case ID_MENUITEMSAVE:
{
TCHAR *srcTxt = "D:\\text.txt";
TCHAR srcStr[256];
FILE *fp = fopen(srcTxt,"wt");
if (fp != NULL)
{
GetDlgItemText(hwnd,IDC_EDITCONTENT,srcStr,sizeof(srcStr));
fputs(srcStr,fp);
fclose(fp);
}
else
{
MessageBox(hwnd,TEXT("文件无法打开"),TEXT("error"),MB_OK);
}
}
break;