📄 ntpadop.c
字号:
{
length = dirnum;
}
GroupOn( hGC );
//刷新列表
for(i = 0; i < SAVE_DISP_MAX; i++)
{
if(i < dirnum) //列表没有结束时
{
SetWindowText(property[i], NULL, (char *)zi_mulushuxing); //属性按钮
SetWindowText(note[i], nowlist[i]->name, NULL); //目录文件名称
}
else //列表结束时,显示空按钮
{
SetWindowText(property[i], "", NULL); //显示空属性和按钮
SetWindowText(note[i], "", NULL);
}
}
GroupOff( hGC, 1, 107, (LCD_WIDTH + 150)/2, 218 );
//恢复状态参数
SetScrollRange(scroll, 1, (U16)(length - SAVE_DISP_MAX + 1)); //重新设置滚动条长度,并定位到最顶端
SetScrollPos(scroll, 1, 0, 0);
row = 1;
}
else //点击的不是已选目录/文件
{
if(((offset - row + 1) >= 0) && ((offset - row + 1) < NOTE_DISP_MAX))
{
RepaintWindow(note[offset - row + 1], BS_INVERT); //把刚才的目录/文件恢复
}
RepaintWindow(note[i], BS_INVERT); //设定现在点击的目录/文件为选定目录/文件,并设定为反色显示
offset = i + row - 1;
}
}
else
if(msg.lparam == property[i]) //点击属性按钮
{
PropertyDisp(nowlist[i + row - 1]);
// offset = -1;
}
}
}
}
break;
case WM_VSCROLL:
if(msg.lparam == scroll)
{
switch(msg.wparam)
{
case SB_PAGEUP:
row -= SAVE_DISP_MAX;
if (row < 1) row = 1;
break;
case SB_PAGEDOWN:
row += SAVE_DISP_MAX;
if (row > (length - SAVE_DISP_MAX + 1)) row = (length - SAVE_DISP_MAX + 1);
break;
case SB_LINEUP:
row -= 1;
if (row < 1) row = 1;
break;
case SB_LINEDOWN:
row += 1;
if (row > (length - SAVE_DISP_MAX + 1)) row = (length - SAVE_DISP_MAX + 1);
break;
case SB_THUMBTRACK:
dragflag = 1;
break;
case SB_ENDSCROLL:
row = GetScrollPos(scroll,0,0,0);
dragflag = 0;
break;
}
if(!dragflag)
{
SetScrollPos(scroll,row,0,0); // 滚动条拖动定位
GroupOn( hGC );
//显示的更新
for(i = 0; i < SAVE_DISP_MAX; i++)
{
if((i + row - 1) < dirnum) //列表没有结束时
{
SetWindowText(property[i], NULL, (char *)zi_mulushuxing); //属性按钮
SetWindowText(note[i], nowlist[i + row - 1]->name, NULL); //目录文件名称
}
else //列表结束时,显示空按钮
{
SetWindowText(property[i], "", NULL); //显示空属性和按钮
SetWindowText(note[i], "", NULL);
}
}
GroupOff( hGC, 1, 107, 139, 218 );
if((offset >= (row - 1)) && (offset <= (row - 1 + SAVE_DISP_MAX)))
{
RepaintWindow(note[offset - row + 1], BS_INVERT);
}
}
}
break;
case WM_QUIT:
quit = 1;
break;
}
DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam);
}
for(i = 0; i < allnum; i++)
{
Lfree(nowlist[i]);
}
DelOldSearchList(searchlist);
DestroyWindow( mainwin );
DetachDataBase(lacb);
if(saveflag == 0)
return SAVE_SMS_FAIL;
else
return SAVE_SMS_OK;
}
char *SearchNotepad(S16 type)
{
U32 hGC;
//定义窗口和控件ID
U32 mainwin; //主窗口
U32 dirtip; //标识位置,静态框
U32 directory; //目录显示框,静态框
U32 up; //返回上一级的按钮
U32 back; //列表显示框,静态框
U32 scroll; //垂直滚动条
U32 note[SEARCH_DISP_MAX]; //目录(文件)列表 按钮
U32 property[SEARCH_DISP_MAX]; //属性按钮
U32 ok;
U32 cancel;
U32 tskbar; //底部任务栏
//定义函数用变量
MSG msg;
S16 quit = 0;
S16 i = 0;
S16 row = 1; //滚动块的位置
S16 dragflag = 0; //拖动标志
S16 length = SEARCH_DISP_MAX;
char currentdir[NAME_SIZE + 1];
char currentid[LEVEL_NUM + 1]; //当前目录的id
S16 offset = -1; //offset是被选中的目录/文件与当前目录下的首个目录/文件偏移量,-1表示没有选中目录/文件
PROPERTY *nowlist[MAX_DIR_NUM];
S16 allnum;
LOCALSEARCHLIST *searchlist;
DBLACB *lacb;
char *content;
//初始化
if((content = (char *)Lmalloc(TEXT_SIZE + 1)) == NULL)
return NULL;
memset(content, 0x00, TEXT_SIZE + 1);
memset(currentid, 0x00, LEVEL_NUM + 1); //默认当前路径为根目录
memset(currentdir, 0x00, NAME_SIZE + 1);
strcpy(currentdir, "\\");
// CreateDataBase();
lacb = LinkDataBase(NOTEPAD_DATA_BASE);
searchlist = LocalSortRecord(lacb, NOTEPAD_NAME_FIELD, currentid, PRECISE_PART_MATCH);
allnum = searchlist->num;
GetNoteList(nowlist, allnum, searchlist);
if(allnum > SEARCH_DISP_MAX)
{
length = allnum;
}
//创建窗口和控件
mainwin = CreateWindow(WNDCLASS_WIN, "查找", WS_OVERLAPPEDWINDOW, 0, 0, PHY_LCD_W, PHY_LCD_H, 0, 0, NULL);
dirtip = CreateWindow(WNDCLASS_STATIC, "当前目录", WS_CHILD|SS_TEXT, (LCD_WIDTH - 100)/2, 23, 100, BUTTON_W, mainwin, 0, NULL);
directory = CreateWindow(WNDCLASS_STATIC, "\\", WS_CHILD|SS_TEXT|SS_BOARD|SS_LEFT, (LCD_WIDTH - 140)/2, 45, 115, BUTTON_W, mainwin, 0, NULL);
up = CreateWindow(WNDCLASS_BUTTON, "\\返回上级目录", WS_CHILD|BS_REGULAR, (LCD_WIDTH - 140)/2 + 120, 45, BUTTON_W, BUTTON_W, mainwin, 0x00140014, (char *)zi_back);
ok = CreateWindow(WNDCLASS_BUTTON, "确定", WS_CHILD|BS_REGULAR, (LCD_WIDTH - 120)/2, 198, 40, BUTTON_W, mainwin, 0, NULL);
cancel = CreateWindow(WNDCLASS_BUTTON, "取消", WS_CHILD|BS_REGULAR, (LCD_WIDTH - 120)/2 + 80, 198, 40, BUTTON_W, mainwin, 0, NULL);
back = CreateWindow(WNDCLASS_STATIC, "", WS_CHILD|SS_BOARD, (LCD_WIDTH - 158)/2, 66, 137, 130, mainwin, 0, NULL);
scroll = CreateWindow(WNDCLASS_SCROLL, "", WS_CHILD|SBS_VERT, (LCD_WIDTH - 158)/2 + 138, 66, 20, 130, mainwin, MAKELONG(1, length - SEARCH_DISP_MAX + 1), NULL);
tskbar = CreateWindow(WNDCLASS_TSKBAR, NULL, WS_CHILD|TBS_TYPICAL, 0, 0, 0, 0,mainwin, 0, NULL);
for(i = 0; i < SEARCH_DISP_MAX; i++) //显示目录/文件列表
{
if(i < allnum)
{
if(*(nowlist[i]->id) == 0)
property[i] = CreateWindow(WNDCLASS_BUTTON, "\\属性", WS_CHILD|BS_ICON, (LCD_WIDTH - 158)/2 + 2, (U16)(67 + i*(BUTTON_W + 1)), BUTTON_W, BUTTON_W, mainwin, 0x001400014, (char *)zi_wenjianshuxing); //属性按钮
else
property[i] = CreateWindow(WNDCLASS_BUTTON, "\\属性", WS_CHILD|BS_ICON, (LCD_WIDTH - 158)/2 + 2, (U16)(67 + i*(BUTTON_W + 1)), BUTTON_W, BUTTON_W, mainwin, 0x00140014, (char *)zi_mulushuxing); //属性按钮
note[i] = CreateWindow(WNDCLASS_BUTTON, nowlist[i]->name, WS_CHILD|BS_REGULAR, (LCD_WIDTH - 158)/2 + 22, (U16)(67 + i*(BUTTON_W + 1)), 115, BUTTON_W, mainwin, 0, NULL); //目录列表
}
else
{
property[i] = CreateWindow(WNDCLASS_BUTTON, "\\属性", WS_CHILD|BS_ICON, 2, (U16)(67 + i*(BUTTON_W + 1)), BUTTON_W, BUTTON_W, mainwin, 0, NULL); //显示空按钮
note[i] = CreateWindow(WNDCLASS_BUTTON, "", WS_CHILD|BS_REGULAR, (LCD_WIDTH - 158)/2 + 22, (U16)(67 + i*(BUTTON_W + 1)), 115, BUTTON_W, mainwin, 0, NULL); //显示空按钮
}
}
hGC = GetGC();
//程序开始
while(!quit)
{
ASIXGetMessage(&msg, NULL, 0, 0);
switch(msg.message)
{
case WM_COMMAND:
if(msg.lparam == ok)
{
if((offset == -1) || (*(nowlist[offset]->id) != 0))
{
MessageBox(mainwin, "请选择要导入的文件!", "提醒", MB_ICONEXCLAMATION|MB_OK);
}
else
{
strcpy(content, nowlist[offset]->content);
quit = 1;
break;
}
}
else
if(msg.lparam == cancel)
{
quit = 1;
break;
}
else
if(msg.lparam == up)
{
//更改当前所在目录
if(strlen(currentid) != 0)
{
*(currentid + strlen(currentid) - 1) = '\0';
}
if(*(nowlist[i]->parent) == 0)
{
strcpy(currentdir, "\\");
}
SetWindowText(directory, currentdir, NULL);
if(offset != -1)
{
if(((offset - row + 1) >= 0) && ((offset - row + 1) < NOTE_DISP_MAX))
{
RepaintWindow(note[offset - row + 1], BS_INVERT); //把刚才的目录/文件恢复
}
}
offset = -1;
DelOldSearchList(searchlist);
searchlist = LocalSortRecord(lacb, NOTEPAD_NAME_FIELD, currentid, PRECISE_PART_MATCH); //重新读入列表
for(i = 0; i < allnum; i++)
{
Lfree(nowlist[i]);
}
allnum = searchlist->num;
GetNoteList(nowlist, allnum, searchlist); //解析数据
length = SEARCH_DISP_MAX; //得出滚动条的长度
if(allnum > SEARCH_DISP_MAX)
{
length = allnum;
}
GroupOn( hGC );
//刷新列表
for(i = 0; i < SEARCH_DISP_MAX; i++)
{
if(i < allnum) //列表没有结束时
{
if(*(nowlist[i]->id) == 0) //是文件类型
SetWindowText(property[i], NULL, (char *)zi_wenjianshuxing);
else //是目录类型
SetWindowText(property[i], NULL, (char *)zi_mulushuxing); //属性按钮
SetWindowText(note[i], nowlist[i]->name, NULL); //目录文件名称
}
else //列表结束时,显示空按钮
{
SetWindowText(property[i], "", NULL); //显示空属性和按钮
SetWindowText(note[i], "", NULL);
}
}
GroupOff( hGC, 1, 66, 139, 197);
//恢复状态参数
SetScrollRange(scroll, 1, (U16)(length - SEARCH_DISP_MAX + 1)); //重新设置滚动条长度,并定位到最顶端
SetScrollPos(scroll, 1, 0, 0);
row = 1;
}
else
{
for(i = 0; i < SEARCH_DISP_MAX; i++)
{
if((i + row - 1) < allnum)
{
if(msg.lparam == note[i])
{
if(offset == -1) //没有已选目录/文件时,设定点击的目录/文件按钮反色,表示选中
{
RepaintWindow(note[i], BS_INVERT);
offset = i + row - 1;
}
else
if(offset == (i + row - 1)) //当点击的是已选目录/文件时,分别作处理
{
if(*(nowlist[offset]->id) == 0) //当已选的是文件时,浏览文件
{
ReadNotepad(nowlist, offset, allnum);
RepaintWindow(note[offset - row + 1], BS_INVERT);
}
else //当已选的时目录时,则进入已选目录
{
strcpy(currentid, nowlist[i]->parent);
strcat(currentid, nowlist[offset]->id);
strcpy(currentdir, nowlist[offset]->name);
SetWindowText(directory, currentdir, NULL);
RepaintWindow(note[offset - row + 1], BS_INVERT);
offset = -1;
DelOldSearchList(searchlist);
searchlist = LocalSortRecord(lacb, NOTEPAD_NAME_FIELD, currentid, PRECISE_PART_MATCH); //重新读入列表
for(i = 0; i < allnum; i++)
{
Lfree(nowlist[i]);
}
allnum = searchlist->num;
GetNoteList(nowlist, allnum, searchlist); //解析数据
length = SEARCH_DISP_MAX; //得出滚动条的长度
if(allnum > SEARCH_DISP_MAX)
{
length = allnum;
}
GroupOn( hGC );
//刷新列表
for(i = 0; i < SEARCH_DISP_MAX; i++)
{
if(i < allnum) //列表没有结束时
{
if(*(nowlist[i]->id) == 0) //是文件类型
SetWindowText(property[i], NULL, (char *)zi_wenjianshuxing);
else //是目录类型
SetWindowText(property[i], NULL, (char *)zi_mulushuxing); //属性按钮
SetWindowText(note[i], nowlist[i]->name, NULL); //目录文件名称
}
else //列表结束时,显示空按钮
{
SetWindowText(property[i], "", NULL); //显示空属性和按钮
SetWindowText(note[i], "", NULL);
}
}
GroupOff( hGC, 1, 66, (LCD_WIDTH + 150)/2, 197);
//恢复状态参数
SetScrollRange(scroll, 1, (U16)(length - SEARCH_DISP_MAX + 1)); //重新设置滚动条长度,并定位到最顶端
SetScrollPos(scroll, 1, 0, 0);
row = 1;
}
}
else //点击的不是已选目录/文件
{
if(((offset - row + 1) >= 0) && ((offset - row + 1) < NOTE_DISP_MAX))
{
RepaintWindow(note[offset - row + 1], BS_INVERT); //把刚才的目录/文件恢复
}
RepaintWindow(note[i], BS_INVERT); //设定现在点击的目录/文件为选定目录/文件,并设定为反色显示
offset = i + row - 1;
}
}
else
if(msg.lparam == property[i]) //点击属性按钮
{
PropertyDisp(nowlist[i + row - 1]);
// offset = -1;
}
}
}
}
break;
case WM_VSCROLL:
if(msg.lparam == scroll)
{
switch(msg.wparam)
{
case SB_PAGEUP:
row -= SEARCH_DISP_MAX;
if (row < 1) row = 1;
break;
case SB_PAGEDOWN:
row += SEARCH_DISP_MAX;
if (row > (length - SEARCH_DISP_MAX + 1)) row = (length - SEARCH_DISP_MAX + 1);
break;
case SB_LINEUP:
row -= 1;
if (row < 1) row = 1;
break;
case SB_LINEDOWN:
row += 1;
if (row > (length - SEARCH_DISP_MAX + 1)) row = (length - SEARCH_DISP_MAX + 1);
break;
case SB_THUMBTRACK:
dragflag = 1;
break;
case SB_ENDSCROLL:
row = GetScrollPos(scroll,0,0,0);
dragflag = 0;
break;
}
if(!dragflag)
{
SetScrollPos(scroll,row,0,0); // 滚动条拖动定位
GroupOn( hGC );
//显示的更新
for(i = 0; i < SEARCH_DISP_MAX; i++)
{
if((i + row - 1) < allnum) //列表没有结束时
{
if(*(nowlist[i + row - 1]->id) == 0) //是文件类型
SetWindowText(property[i], NULL, (char *)zi_wenjianshuxing);
else //是目录类型
SetWindowText(property[i], NULL, (char *)zi_mulushuxing); //属性按钮
SetWindowText(note[i], nowlist[i + row - 1]->name, NULL); //目录文件名称
}
else //列表结束时,显示空按钮
{
SetWindowText(property[i], "", NULL); //显示空属性和按钮
SetWindowText(note[i], "", NULL);
}
}
GroupOff( hGC, 1, 66, 139, 197);
if((offset >= (row - 1)) && (offset <= (row - 1 + SEARCH_DISP_MAX)))
{
RepaintWindow(note[offset - row + 1], BS_INVERT);
}
}
}
break;
case WM_QUIT:
quit = 1;
break;
}
DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam);
}
for(i = 0; i < allnum; i++)
{
Lfree(nowlist[i]);
}
DelOldSearchList(searchlist);
DestroyWindow( mainwin );
DetachDataBase(lacb);
if((offset != -1) && (*(nowlist[offset]->id) == 0))
return content;
else
{
memset(content, 0x00, TEXT_SIZE + 1);
return content;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -