📄 callcard.c
字号:
{
high = countall-DISP_NUM;
if((S8)(startp)<0) startp = 0;
if(startp>high) startp = high;
endp = startp+DISP_NUM;
}
else
{
high = 0;
startp = 0;
endp=countall;
}
if(topdir==TRUE)
if(startp!=0) topdir=FALSE;
if(enddir==TRUE)
if(endp!=countall) enddir=FALSE;
SetScrollRange(scroll,low,high);
if((topdir==FALSE)&&(enddir==FALSE))
{
SetScrollPos(scroll, startp, 0, 0);
CardDetailDisplay(recordinf, cueinf,countall, startp, endp, bt,st);
}
}
break;
// 关闭窗口的消息,建议用户不要更改该消息的处理
case WM_QUIT:
quit = 1;
break;
}
DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam);
}
DestroyWindow( browsewin );
}
*/
CALLCARD * SearchCallCard(U16 *recordlen,U8 * isfindok)//定义参数
{
MSG msg;
U32 searchwin,edit1,keyboard,bt1,bt2,lbox;
U8 quit=0;
P_S8 string1 = "请输入查询数据";
P_S8 tmpbuf=NULL;
SEARCHSTYLE style = PHONETICISE;
U32 hGC;
U32 tskbar; //任务栏
struct LBOX_ITEM lboxitem[] =
{
ICON_ENABLE, UNDERLINE, "模糊查询",
ICON_ENABLE, UNDERLINE, "精确查询",
ICON_END, UNDERLINE, NULL
};
U16 len = 0;
CALLCARD * searchlst =NULL;
U8 flag=0;
hGC = GetGC();
searchwin = CreateWindow(WNDCLASS_WIN,
"查找",
WS_OVERLAPPEDWINDOW,
0,0,
PHY_LCD_W,PHY_LCD_H,
0,
0,
NULL);
tskbar = CreateWindow(WNDCLASS_TSKBAR, NULL, WS_CHILD|TBS_TYPICAL, 0, 0, 0, 0,searchwin, 0, NULL);
edit1 = CreateWindow( WNDCLASS_EDITOR,
NULL,
WS_CHILD|ES_SINGLE_REGULAR,
LCD_WIDTH/2-70,LCD_HEIGHT*5/32,
140,
20,
searchwin,
0,
NULL);
keyboard = CreateWindow( WNDCLASS_KEYBD,
NULL,
WS_CHILD|KBS_PINGYING|0xff,
LCD_WIDTH/6,LCD_HEIGHT*9/16,
LCD_WIDTH*3/4,LCD_HEIGHT*19/160,
searchwin,
0,
NULL);
lbox = CreateWindow( WNDCLASS_LIST,
"ListBox",
WS_CHILD|LBS_POPUP,
LCD_WIDTH/2-(LCD_WIDTH*15/64),LCD_HEIGHT*9/32,
LCD_WIDTH*15/32,
LCD_HEIGHT/15,
searchwin,
0,
lboxitem);
bt1 = CreateWindow( WNDCLASS_BUTTON,
"确定",
WS_CHILD|BS_REGULAR,
LCD_WIDTH/2-(LCD_WIDTH*5/16),LCD_HEIGHT*3/8,
LCD_WIDTH/4,
LCD_HEIGHT*3/32,
searchwin,
0,
NULL);
bt2 = CreateWindow( WNDCLASS_BUTTON,
" 取消",
WS_CHILD|BS_REGULAR,
LCD_WIDTH*9/16,LCD_HEIGHT*3/8,
LCD_WIDTH/4,
LCD_HEIGHT*3/32,
searchwin,
0,
NULL);
hGC = GetGC();
SetFocus( edit1 );
while(!quit)
{
ASIXGetMessage(&msg, NULL, 0, 0);
switch(msg.message)
{
case WM_COMMAND:
if ( msg.lparam == bt1 )
{
tmpbuf = GetEditorStr(edit1, NULL, 0);//需要判断是否为空,即有否输入数据
if((P_S8)(*tmpbuf) != NULL)
{
switch (style)
{
case PHONETICISE://变成模糊查询
//根据tmpbuf和style搜索数据库
searchlst=(CALLCARD*)CardLoadSearchData(tmpbuf,&len,PRECISE_PART_MATCH);
* isfindok = TRUE;
* recordlen = len;
flag = 1;
break;
case CHINESEWORD: //变成精确查询
//根据tmpbuf和style搜索数据库
searchlst=CardLoadSearchData(tmpbuf,&len,PRECISE_FULL_MATCH);
* isfindok = TRUE;
* recordlen = len;
flag = 1;
//return searchlst;
break;
}
quit = 1;
* isfindok = TRUE;
}else{
MessageBox(0, string1, "提醒", MB_OK);
}
} else
if ( msg.lparam == bt2 )
{
quit = 1;
* isfindok = FALSE;
}
break;
case WM_LISTBOX:
switch(msg.wparam)
{
case 0: style = PHONETICISE;
break;
case 1: style = CHINESEWORD;
break;
default: break;
}
break;
case WM_QUIT:
quit = 1;
* isfindok = FALSE;
break;
}
DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam);
}
DestroyWindow( searchwin );
return searchlst;
}
STATUS CardDisplay(CALLCARD * displaylist, U16 len, S16 startpos, S16 endpos, U32 *bt)
// displaylist是现在需要显示的记录类,listlen是此记录的长度,
//startpos,endpos 分别是链表显示信息的起始和终止记录
//bt是显示记录button的ID,
{
U16 count;
CALLCARD *pointer;
U32 hGC;
hGC = GetGC();
pointer = displaylist;
GroupOn( hGC );
for(count = 0; count < DISP_NUM; count++)
{
SetWindowText(*bt, NULL, NULL);
EnableWindow(*bt,FALSE);
bt++;
}
bt -= DISP_NUM;
if(len <= 0)
{
SetWindowText(*bt, " 此记录为空", NULL);
//return ASIX_OK;
goto herecarddisp;
}
if(startpos != 0)
{
for(count = 0;count<startpos;count++)
{
pointer = pointer->next;
}
}
for(count = startpos; count < endpos; count++)
{
EnableWindow(*bt, TRUE);
SetWindowText(*bt, pointer->name, NULL);
pointer = pointer->next;
bt++;
}
herecarddisp:
GroupOff( hGC, 1, 1, LCD_WIDTH-1,LCD_HEIGHT-1);
return ASIX_OK;
}
void NewCardRecordInf(CALLCARD* newptr)//将数据的指针赋上正确的值
{
U8 count;
newptr->name = newptr->namebuf;
for(count = 0;count<MAXTELNUM;count++)
{
newptr->tel[count] = newptr->telbuf[count];
}
for(count = 0;count<MAXMOBNUM;count++)
{
newptr->mobile[count] = newptr->mobbuf[count];
}
for(count = 0;count<MAXBPNUM;count++)
{
newptr->bp[count] = newptr->bpbuf[count];
}
for(count = 0;count<MAXFAX;count++)
{
newptr->fax[count] = newptr->faxbuf[count];
}
for(count = 0;count<MAXUNIT;count++)
{
newptr->unit[count] = newptr->unitbuf[count];
}
for(count = 0;count<MAXEMAIL;count++)
{
newptr->email[count] = newptr->emailbuf[count];
}
for(count = 0;count<MAXADDRESS;count++)
{
newptr->address[count] = newptr->addressbuf[count];
}
for(count = 0;count<MAXQQ;count++)
{
newptr->QQ[count] = newptr->QQbuf[count];
}
for(count = 0;count<MAXHABIT;count++)
{
newptr->habbit[count] = newptr->habbitbuf[count];
}
for(count = 0;count<MAXPOSTALCODE;count++)
{
newptr->postalcode[count] = newptr->postalcodebuf[count];
}
}
void FreeCardList(CALLCARD *head)
{
CALLCARD * pointer;
while(head != NULL)
{
pointer =head;
head = head->next;
Lfree(pointer);
}
}
void CardProcess(void)
{
MSG Msg;
U32 mainwin,newbt,delbt,searchbt,recoverybt,editbt,scroll,st;
U32 bt[DISP_NUM];
U32 hGC;
U8 quit=0;
U8 topdir=FALSE,enddir=FALSE;//标志滚动滑块在页首和页尾,用于阻止相同页面的重刷
S16 startp,endp,high,low;
CURSCRSTATE curscrstate;
CALLCARD *displisthead =NULL;//XXX看看程序是否会飞
CALLCARD *ThisPtr;
CALLCARD *tmplist =NULL; //用于搜索的暂时存储链表的指针
CALLCARD *tmpptr;
CALLCARD newrecord;
CALLCARD *newrecoredptr;
U32 lbox;
struct LBOX_ITEM lboxitem[] =
{
ICON_ENABLE, UNDERLINE, "全部",
ICON_ENABLE, UNDERLINE, "朋友",
ICON_ENABLE, UNDERLINE, "亲戚",
ICON_ENABLE, UNDERLINE, "同事",
ICON_ENABLE, UNDERLINE, "同学",
ICON_ENABLE, UNDERLINE, "其他",
ICON_END, UNDERLINE, NULL
};
RELATIONSHIP nowrelation;
U8 count;
S8 select_bt;
U8 activeflag[DISP_NUM];
U32 hmenu;
U8 isturntoedit = 0;
U8 isrefreshscr = 0;
U8 isfindok = FALSE;
U32 *LoadID=NULL; //需要考虑数组的释放
U16 RecordLen = 0; //从数据库获得的ID的长度
S8 string[50]= "确定删除联系人:";
U32 newid;
U16 msgst;
U8 isfirstnote = 0;
U8 islastnote = 0;
U32 tskbar; // 任务栏
U32 databst;
P_S8 returncall=NULL;
P_S8 string1 = "所存电话本记录已满!";
// U8 isinactivest = 0; //在编辑,浏览,删除态之后,使所有BT状态为UNACTIVE,并且所有返黑清除
curscrstate = SHOW_ALLST;
nowrelation = AllRelation;
cardlacb = LinkDataBase(CARD_DATA_BASE);//连接数据库
displisthead = CardLoadRelationData(nowrelation,&RecordLen);
memset( (P_VOID)&newrecord, 0x0 , sizeof(CALLCARD));//初试化新的记录
newrecoredptr = &newrecord;
/* 创建主窗口 */
mainwin = CreateWindow(WNDCLASS_WIN,
"名片",
WS_OVERLAPPEDWINDOW,
0,0,
PHY_LCD_W,PHY_LCD_H,
0,
0,
NULL);
tskbar = CreateWindow(WNDCLASS_TSKBAR, NULL, WS_CHILD|TBS_TYPICAL, 0, 0, 0, 0,mainwin, 0, NULL);
st = CreateWindow(WNDCLASS_STATIC,
"关系:",
WS_CHILD|SS_TEXT,
LCD_WIDTH/2-LCD_WIDTH*2/5,46*LCD_HEIGHT/240+(LCD_HEIGHT>240)*8,
40,
22,
mainwin,
0,
NULL);
lbox = CreateWindow( WNDCLASS_LIST,
"ListBox",
WS_CHILD|LBS_POPUP,
LCD_WIDTH/2-LCD_WIDTH*2/5+(LCD_WIDTH*4/5-18)/10+40,46*LCD_HEIGHT/240+(LCD_HEIGHT>240)*8,
(LCD_WIDTH*4/5-18)*9/10-40,
16,
mainwin,
0,
lboxitem);
newbt = CreateWindow( WNDCLASS_BUTTON,
"\\新建",
WS_CHILD|BS_REGULAR,
LCD_WIDTH/2-LCD_HEIGHT*5/24-2,18,
LCD_HEIGHT/12,
LCD_HEIGHT/12,
mainwin,
0,
(char*)zi_new);
delbt = CreateWindow( WNDCLASS_BUTTON,
"\\删除",
WS_CHILD|BS_REGULAR,
LCD_WIDTH/2-LCD_HEIGHT/8-1,18,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -