📄 smsh.c
字号:
SetWindowText(man, "", NULL); //清空显示
SetWindowText(time, "", NULL);
SetWindowText(content, "", NULL);
no = -1; //设置序号表示记录为空
if(MessageBox(mainwin, "当前列表已经为空!!!", "提醒", MB_ICONEXCLAMATION|MB_OK) == IDOK) //弹出提示框提醒
quit = 1;
}
else //不是第一个时显示前一个
{
//删除操作处理
LocalDelRecord( lacb, (*(nowlist + no))->index ); //从数据库中删除
Lfree(*(nowlist + no)); //从当前列表中删除
for(temp=no; temp<(listnum - 1); temp++)
{
*(nowlist + temp) = *(nowlist + temp + 1);
}
*(nowlist + temp) = NULL;
listnum -= 1; //列表个数减1
// no -= 1; //设置序号为前一个
if(strlen((*(nowlist + no))->name) == 0)
{
SetWindowText(man, (*(nowlist + no))->sms.number, NULL);
}
else
{
SetWindowText(man, (*(nowlist + no))->name, NULL);
}
strncpy(disptime, ((*(nowlist + no))->time + 2), 2);
*(disptime + 2) = '\0';
strcat(disptime, " ");
strncat(disptime, ((*(nowlist + no))->time + 4), 2);
strcat(disptime, ".");
strncat(disptime, ((*(nowlist + no))->time + 6), 2);
SetWindowText(time, disptime, NULL);
SetWindowText(content, (*(nowlist + no))->sms.content, NULL);
}
}
else //下一个不为空时
{
if(no == 0) //是第一个时
{
EnableWindow(first, FALSE); //first和prev按钮不响应
EnableWindow(prev, FALSE);
//删除操作处理
LocalDelRecord( lacb, (*(nowlist + no))->index ); //从数据库中删除
Lfree(*(nowlist + no)); //从当前列表中删除
for(temp=no; temp<(listnum - 1); temp++)
{
*(nowlist + temp) = *(nowlist + temp + 1);
}
*(nowlist + temp) = NULL;
listnum -= 1; //列表个数减1
// no += 1; //显示下一个
if(strlen((*(nowlist + no))->name) == 0)
{
SetWindowText(man, (*(nowlist + no))->sms.number, NULL);
}
else
{
SetWindowText(man, (*(nowlist + no))->name, NULL);
}
strncpy(disptime, ((*(nowlist + no))->time + 2), 2);
*(disptime + 2) = '\0';
strcat(disptime, " ");
strncat(disptime, ((*(nowlist + no))->time + 4), 2);
strcat(disptime, ".");
strncat(disptime, ((*(nowlist + no))->time + 6), 2);
SetWindowText(time, disptime, NULL);
SetWindowText(content, (*(nowlist + no))->sms.content, NULL);
}
else //前后都不为空时,把当前记录从列表中删除,并显示下一个
{
//删除操作处理
LocalDelRecord( lacb, (*(nowlist + no))->index ); //从数据库中删除
Lfree(*(nowlist + no)); //从当前列表中删除
for(temp=no; temp<(listnum - 1); temp++)
{
*(nowlist + temp) = *(nowlist + temp + 1);
}
*(nowlist + temp) = NULL;
listnum -= 1; //列表个数减1
// no += 1;
if(strlen((*(nowlist + no))->name) == 0)
{
SetWindowText(man, (*(nowlist + no))->sms.number, NULL);
}
else
{
SetWindowText(man, (*(nowlist + no))->name, NULL);
}
strncpy(disptime, ((*(nowlist + no))->time + 2), 2);
*(disptime + 2) = '\0';
strcat(disptime, " ");
strncat(disptime, ((*(nowlist + no))->time + 4), 2);
strcat(disptime, ".");
strncat(disptime, ((*(nowlist + no))->time + 6), 2);
SetWindowText(time, disptime, NULL);
SetWindowText(content, (*(nowlist + no))->sms.content, NULL);
}
}
}
else
if(msg.lparam == save) //点击保存菜单
{
switch(msg.wparam)
{
case 0: //保存电话号码
if(AddPhonetoBook((*(nowlist + no))->sms.number) == SAVE_SMS_FAIL)
MessageBox(mainwin, "保存失败", "提醒", MB_ICONEXCLAMATION|MB_OK); //弹出提示框提醒
else
MessageBox(mainwin, "保存完毕", "提醒", MB_ICONEXCLAMATION|MB_OK); //弹出提示框提醒
break;
case 1: //保存内容到记事本
if(SaveSmsNote(&((*(nowlist + no))->sms)) == SAVE_SMS_FAIL)
MessageBox(mainwin, "保存失败", "提醒", MB_ICONEXCLAMATION|MB_OK); //弹出提示框提醒
else
MessageBox(mainwin, "保存完毕", "提醒", MB_ICONEXCLAMATION|MB_OK); //弹出提示框提醒
break;
}
}
else
if(msg.lparam == first) //点击first按钮
{
if(no == (listnum - 1)) //如果是last,恢复last和next的按钮响应
{
EnableWindow(next, TRUE);
EnableWindow(last, TRUE);
}
no = 0; //显示当前列表的第一个记录
if(!strcmp((*(nowlist + no))->flag, SMS_UNREAD)) //如果是未读记录,改为已读
{
ModifySMS((*(nowlist + no))); //把未读短信改为已读短信
// Add2SMSHistory(&((*(nowlist + no))->sms), SMS_READ, NULL);
// LocalDelRecord( lacb, (*(nowlist + no))->index ); //从数据库中删除
// Lfree(*(nowlist + no)); //从当前列表中删除
// for(temp=no; temp<(listnum - 1); temp++)
// {
// *(nowlist + temp) = *(nowlist + temp + 1);
// }
// *(nowlist + temp) = NULL;
// if(listnum == 1)
// {
// if(MessageBox(mainwin, "没有未读的短信!", "提醒", MB_ICONEXCLAMATION|MB_OK) == IDOK)
// {
// quit = 1;
// break;
// }
// }
// else
// listnum -= 1; //列表个数减1
// strcpy((*(nowlist + no))->flag, SMS_READ);
}
if(strlen((*(nowlist + no))->name) == 0)
{
SetWindowText(man, (*(nowlist + no))->sms.number, NULL);
}
else
{
SetWindowText(man, (*(nowlist + no))->name, NULL);
}
strncpy(disptime, ((*(nowlist + no))->time + 2), 2);
*(disptime + 2) = '\0';
strcat(disptime, " ");
strncat(disptime, ((*(nowlist + no))->time + 4), 2);
strcat(disptime, ".");
strncat(disptime, ((*(nowlist + no))->time + 6), 2);
SetWindowText(time, disptime, NULL);
SetWindowText(content, (*(nowlist + no))->sms.content, NULL);
EnableWindow(first, FALSE); //灰化prev和first按钮
EnableWindow(prev, FALSE);
}
else
if(msg.lparam == prev) //点击prev按钮
{
if(no == (listnum - 1)) //当前按钮为last按钮
{
EnableWindow(next, TRUE); //恢复next和last按钮
EnableWindow(last, TRUE);
}
no -= 1; //显示当前记录的前一个记录
if(!strcmp((*(nowlist + no))->flag, SMS_UNREAD)) //如果是未读记录,改为已读
{
// Add2SMSHistory(&((*(nowlist + no))->sms), SMS_READ, NULL);
// LocalDelRecord( lacb, (*(nowlist + no))->index ); //从数据库中删除
ModifySMS((*(nowlist + no))); //把未读短信改为已读短信
// Lfree(*(nowlist + no)); //从当前列表中删除
// for(temp=no; temp<(listnum - 1); temp++)
// {
// *(nowlist + temp) = *(nowlist + temp + 1);
// }
// *(nowlist + temp) = NULL;
// if(listnum == 1)
// {
// if(MessageBox(mainwin, "没有未读的短信!", "提醒", MB_ICONEXCLAMATION|MB_OK) == IDOK)
// {
// quit = 1;
// break;
// }
// }
// else
// listnum -= 1; //列表个数减1
// strcpy((*(nowlist + no))->flag, SMS_READ);
}
if(strlen((*(nowlist + no))->name) == 0)
{
SetWindowText(man, (*(nowlist + no))->sms.number, NULL);
}
else
{
SetWindowText(man, (*(nowlist + no))->name, NULL);
}
strncpy(disptime, ((*(nowlist + no))->time + 2), 2);
*(disptime + 2) = '\0';
strcat(disptime, " ");
strncat(disptime, ((*(nowlist + no))->time + 4), 2);
strcat(disptime, ".");
strncat(disptime, ((*(nowlist + no))->time + 6), 2);
SetWindowText(time, disptime, NULL);
SetWindowText(content, (*(nowlist + no))->sms.content, NULL);
if(no == 0) //假如当前为第一个时,灰化first和prev按钮
{
EnableWindow(first, FALSE);
EnableWindow(prev, FALSE);
}
}
else
if(msg.lparam == next) //点击next按钮
{
if(no == 0) //当前为第一个时,回复prev和first按钮
{
EnableWindow(prev, TRUE);
EnableWindow(first, TRUE);
}
no += 1; //显示下一个
if(!strcmp((*(nowlist + no))->flag, SMS_UNREAD)) //如果是未读记录,改为已读
{
// Add2SMSHistory(&((*(nowlist + no))->sms), SMS_READ, NULL);
// LocalDelRecord( lacb, (*(nowlist + no))->index ); //从数据库中删除
ModifySMS((*(nowlist + no))); //把未读短信改为已读短信
// Lfree(*(nowlist + no)); //从当前列表中删除
// for(temp=no; temp<(listnum - 1); temp++)
// {
// *(nowlist + temp) = *(nowlist + temp + 1);
// }
// *(nowlist + temp) = NULL;
// if(listnum == 1)
// {
// if(MessageBox(mainwin, "没有未读的短信!", "提醒", MB_ICONEXCLAMATION|MB_OK) == IDOK)
// {
// quit = 1;
// break;
// }
// }
// else
// listnum -= 1; //列表个数减1
// strcpy((*(nowlist + no))->flag, SMS_READ);
}
if(strlen((*(nowlist + no))->name) == 0)
{
SetWindowText(man, (*(nowlist + no))->sms.number, NULL);
}
else
{
SetWindowText(man, (*(nowlist + no))->name, NULL);
}
strncpy(disptime, ((*(nowlist + no))->time + 2), 2);
*(disptime + 2) = '\0';
strcat(disptime, " ");
strncat(disptime, ((*(nowlist + no))->time + 4), 2);
strcat(disptime, ".");
strncat(disptime, ((*(nowlist + no))->time + 6), 2);
SetWindowText(time, disptime, NULL);
SetWindowText(content, (*(nowlist + no))->sms.content, NULL);
if(no == (listnum - 1)) //假如当前记录为最后一个时,灰化next和last按钮
{
EnableWindow(next, FALSE);
EnableWindow(last, FALSE);
}
}
else
if(msg.lparam == last) //点击最后一个按钮
{
if(no == 0) //假如当前为第一个时,恢复prev和first按钮
{
EnableWindow(prev, TRUE);
EnableWindow(first, TRUE);
}
no = (listnum - 1); //将记录设为最后一个,并显示
if(!strcmp((*(nowlist + no))->flag, SMS_UNREAD)) //如果是未读记录,改为已读
{
// Add2SMSHistory(&((*(nowlist + no))->sms), SMS_READ, NULL);
// LocalDelRecord( lacb, (*(nowlist + no))->index ); //从数据库中删除
ModifySMS((*(nowlist + no))); //把未读短信改为已读短信
// Lfree(*(nowlist + no)); //从当前列表中删除
// for(temp=no; temp<(listnum - 1); temp++)
// {
// *(nowlist + temp) = *(nowlist + temp + 1);
// }
// *(nowlist + temp) = NULL;
// if(listnum == 1)
// {
// if(MessageBox(mainwin, "没有未读的短信!", "提醒", MB_ICONEXCLAMATION|MB_OK) == IDOK)
// {
// quit = 1;
// break;
// }
// }
// else
// listnum -= 1; //列表个数减1
// strcpy((*(nowlist + no))->flag, SMS_READ);
}
if(strlen((*(nowlist + no))->name) == 0)
{
SetWindowText(man, (*(nowlist + no))->sms.number, NULL);
}
else
{
SetWindowText(man, (*(nowlist + no))->name, NULL);
}
strncpy(disptime, ((*(nowlist + no))->time + 2), 2);
*(disptime + 2) = '\0';
strcat(disptime, " ");
strncat(disptime, ((*(nowlist + no))->time + 4), 2);
strcat(disptime, ".");
strncat(disptime, ((*(nowlist + no))->time + 6), 2);
SetWindowText(time, disptime, NULL);
SetWindowText(content, (*(nowlist + no))->sms.content, NULL);
EnableWindow(next, FALSE); //灰化next和last按钮
EnableWindow(last, FALSE);
}
break;
case WM_ALARM: //收到短信
quit = 1;
//发送消息收到短信
AdvSendMessage(GetCurTask()->id, (P_MESSAGE)(&msg), NO_SWAP_TASK);
break;
case WM_QUIT:
quit = 1;
break;
}
DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam);
}
DestroyWindow( mainwin );
DetachDataBase(lacb );
dbgprintf( "### Exit 阅读短信 ###" );
return listnum;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -