⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ntpadop.c

📁 国家ASIC工程中心使用的嵌入式操作系统
💻 C
📖 第 1 页 / 共 3 页
字号:
							sprintf(temp, "%u", time.hour); 
							strcat(timetemp, temp); 
							if(time.minute < 10)
							{
								strcat(timetemp, "0"); 
							}
							sprintf(temp, "%u", time.minute); 
							strcat(timetemp, temp); 
							if(time.second < 10)
							{
								strcat(timetemp, "0"); 
							}
							sprintf(temp, "%u", time.second); 
							strcat(timetemp, temp); 

						searchlist = LocalFindRecord(lacb, NOTEPAD_MODIFY_TIME_FIELD, timetemp, PRECISE_FULL_MATCH); 
						quit = 1; 
					}
				}
				else
				if(msg.lparam == cancel)
				{
					searchlist = NULL; 
					quit = 1; 
				}
				break; 

			case WM_SELECTBOX:
				if(msg.lparam == range)
				{
					if(item[0].state == SL_CHECKED)
					{
						if(*timerange != DAY_RANGE + 48)
							*timerange = DAY_RANGE + 48; 
					}
					else
					if(item[1].state == SL_CHECKED)
					{
						if(*timerange != WEEK_RANGE + 48)
							*timerange = WEEK_RANGE + 48; 
					}
					else
					if(item[2].state == SL_CHECKED)
					{
						if(*timerange != MONTH_RANGE + 48)
							*timerange = MONTH_RANGE + 48; 
					}
					else
					if(item[3].state == SL_CHECKED)
					{
						if(*timerange != YEAR_RANGE + 48)
							*timerange = YEAR_RANGE + 48; 
					}
					else
						*timerange = 0xff; 
				}
				break; 

			case WM_QUIT:
				quit = 1; 
				break; 
		}
		DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam); 
	}	
	if(*timerange == 0xff)
	{
		searchlist = NULL; 
	}
	DestroyWindow( mainwin ); 
	DetachDataBase( lacb ); 
	return searchlist; 
}

LOCALSEARCHLIST *SearchName(void)
{
	//窗口和控件ID
	U32		mainwin; 
	U32		type; 
	U32		tip; 
	U32		keyword; 
	U32		ok; 
	U32		cancel; 
	U32		keyboard; 
	U32		tskbar; 

	//函数用参数
	MSG		msg; 
	S16		quit = 0; 
	LOCALSEARCHLIST *searchlist;			//查找的结果列表	
	DBLACB	*lacb; 
	U8		searchtype = 0xff; 
	char	temp[NAME_SIZE + 1]; 

	//初始化
	SL_ITEM	 item[] =
	{
		SL_UNCHECKED,	"部分匹配",
		SL_UNCHECKED,	"完全匹配", 
		0,	NULL,
	}; 

	memset(temp, 0x00, (NAME_SIZE + 2)); 

	//创建窗口和控件
	mainwin = CreateWindow(WNDCLASS_WIN, "查找", WS_OVERLAPPEDWINDOW, 0, 0, PHY_LCD_W, PHY_LCD_H, 0, 0, NULL); 
	type = CreateWindow(WNDCLASS_SELECT, "类型选择", WS_CHILD|SLS_ENABLE|SLS_FRAME|SLS_RADIOBOX, (LCD_WIDTH - 100)/2, 23, 100, 50, mainwin, 0, item); 
	tip = CreateWindow(WNDCLASS_STATIC, "请输入名称的关键字:", WS_CHILD|SS_TEXT, (LCD_WIDTH - 150)/2, 73, 150, 17, mainwin, 0, NULL); 
	keyword = CreateWindow(WNDCLASS_EDITOR, "", WS_CHILD|ES_SINGLE_REGULAR, (LCD_WIDTH -150)/2, 90, 150, 20, mainwin, NAME_SIZE + 1, NULL); 
	ok = CreateWindow(WNDCLASS_BUTTON, "确定", WS_CHILD|BS_REGULAR, (LCD_WIDTH - 120)/2, 111, 40, 20, mainwin, 0, NULL); 
	cancel = CreateWindow(WNDCLASS_BUTTON, "取消", WS_CHILD|BS_REGULAR, (LCD_WIDTH + 40)/2, 111, 40, 20, mainwin, 0, NULL); 
	keyboard = CreateWindow(WNDCLASS_KEYBD, "", WS_CHILD|KBS_HANDWRITE|0xff, 1, 148, 157, 70, mainwin, 0, NULL); 

	tskbar = CreateWindow(WNDCLASS_TSKBAR, NULL, WS_CHILD|TBS_TYPICAL, 0, 0, 0, 0,mainwin, 0, NULL);

	SetFocus(keyword); 
	lacb = LinkDataBase(NOTEPAD_DATA_BASE); 

	while(!quit)
	{
		ASIXGetMessage(&msg, NULL, 0, 0); 
		switch(msg.message)
		{
			case WM_COMMAND:
				if(msg.lparam == ok)			//点击确定
				{
					switch(searchtype)
					{
						case PRECISE_PART_MATCH:
							GetEditorStr(keyword, temp, NAME_SIZE);		//读出关键字
							if(strlen(temp) == 0)			//关键字为0时
							{
								MessageBox(mainwin, "请输入要查找的文件名或关键字!", "提醒", MB_ICONEXCLAMATION|MB_OK); 
							}
							else
							{
								searchlist = LocalFindRecord(lacb, NOTEPAD_NAME_FIELD, temp, searchtype); 
								quit = 1; 
							}
							break; 
						case PRECISE_FULL_MATCH:
							GetEditorStr(keyword, temp, NAME_SIZE);		//读出关键字
							if(strlen(temp) == 0)			//关键字为0时
							{
								MessageBox(mainwin, "请输入要查找的文件名或关键字!", "提醒", MB_ICONEXCLAMATION|MB_OK); 
							}
							else
							{
								searchlist = LocalFindRecord(lacb, NOTEPAD_NAME_FIELD, temp, searchtype); 
								quit = 1; 
							}
							break;
						case 0xff:
							MessageBox(mainwin, "请选择查找类型!", "提醒", MB_ICONEXCLAMATION|MB_OK); 
							break; 
					}
				}
				else
				if(msg.lparam == cancel)			//点击取消按钮
				{
					searchlist = NULL; 
					quit = 1; 
				}
				break; 

			case WM_SELECTBOX:
				if(msg.lparam == type)				//点选选择框
				{
					if(item[0].state == SL_CHECKED)
					{
						if(searchtype != PRECISE_PART_MATCH)
							searchtype = PRECISE_PART_MATCH; 
					}
					else
					if(item[1].state == SL_CHECKED)
					{
						if(searchtype != PRECISE_FULL_MATCH)
							searchtype = PRECISE_FULL_MATCH; 
					}
					else
						searchtype = 0xff; 
				}
				break; 
				
			case WM_QUIT:
				quit = 1; 
				break; 
		}
		DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam); 
	}
	
	if(searchtype == 0xff)
	{
		searchlist = NULL; 
	}
	DestroyWindow( mainwin ); 
	DetachDataBase( lacb ); 
	return searchlist; 
}


//保存短信到记事本
STATUS SaveSmsNote(SMS *sms)
{
	U32		hGC; 

	//定义窗口和控件ID
	U32		mainwin;					//主窗口
	U32		nametip;					//标识名称,静态框
	U32		nameedit;					//名称编辑栏
	U32		save;						//保存按钮
	U32		dirtip;						//标识位置,静态框
	U32		directory;					//目录显示框,静态框
	U32		up;							//返回上一级的按钮
	U32		back;						//列表显示框,静态框
	U32		scroll;						//垂直滚动条
	U32		keybd;						//软键盘弹出或关闭按钮
	U32		note[SAVE_DISP_MAX];		//目录(文件)列表	按钮
	U32		property[SAVE_DISP_MAX];	//属性按钮
	U32		keyboard;					//软键盘
	U32		tskbar;						//底部任务栏

	//定义函数用变量
	MSG		msg; 
	S16		quit = 0; 
	S16		i = 0; 
	S16		row = 1;					//滚动块的位置
	S16		dragflag = 0;				//拖动标志
	S16		kbflag = 0; 	
	S16		saveflag = 0; 
	S16		length = SAVE_DISP_MAX; 
	char	currentdir[NAME_SIZE + 1]; 
	char	currentid[LEVEL_NUM + 1];		//当前目录的id
	S16		offset = -1;				//offset是被选中的目录/文件与当前目录下的首个目录/文件偏移量,-1表示没有选中目录/文件
	PROPERTY	*nowlist[MAX_DIR_NUM]; 
	PROPERTY	newitem; 
	S16		allnum; 
	S16		dirnum; 
	char	id[2]; 
	LOCALSEARCHLIST		*searchlist; 
	DBLACB		*lacb; 
	char	name[NAME_SIZE + 1]; 
	char	sizestr[5]; 
//	S16		size; 

	//初始化
	memset(id, 0x00, 2); 
	memset(sizestr, 0x00, 5); 
	memset(currentid, 0x00, LEVEL_NUM + 1);		//默认当前路径为根目录
	memset(name, 0x00, NAME_SIZE + 1); 
	memset(currentdir, 0x00, NAME_SIZE + 1); 
	strcpy(currentdir, "\\"); 
	newitem.id = id; 
	newitem.parent = currentid; 
	*(newitem.id) = 0; 
	newitem.content = sms->content; 
	newitem.index = 0; 
	newitem.size = sizestr; 
//	size = strlen(sms->content); 
	sprintf(newitem.size, "%u", strlen(sms->content)); 

//	CreateDataBase(); 
	lacb = LinkDataBase(NOTEPAD_DATA_BASE); 
	searchlist = LocalSortRecord(lacb, NOTEPAD_NAME_FIELD, currentid, PRECISE_PART_MATCH); 
	allnum = searchlist->num; 
	GetNoteList(nowlist, allnum, searchlist); 

	for(i = 0; i < allnum; i++)
	{
		if(*(nowlist[i]->id) == 0)
			break; 
	}
	dirnum = i; 

	if(dirnum > SAVE_DISP_MAX)
	{
		length = dirnum; 
	}

	//创建窗口和控件
	mainwin = CreateWindow(WNDCLASS_WIN, "保存", WS_OVERLAPPEDWINDOW, 0, 0, PHY_LCD_W, PHY_LCD_H, 0, 0, NULL); 
	nametip = CreateWindow(WNDCLASS_STATIC, "文件名", WS_CHILD|SS_TEXT, (LCD_WIDTH - 100)/2, 23, 100, BUTTON_W, mainwin, 0, NULL); 
	nameedit = CreateWindow(WNDCLASS_EDITOR, "", WS_CHILD|ES_SINGLE_REGULAR, (LCD_WIDTH - 140)/2, 44, 115, BUTTON_W, mainwin, NAME_SIZE + 1, NULL); 
	save = CreateWindow(WNDCLASS_BUTTON, "\\保存", WS_CHILD|BS_REGULAR, (LCD_WIDTH - 140)/2 + 120, 44, BUTTON_W, BUTTON_W, mainwin, 0x00140014, (char *)zi_save); 
	dirtip = CreateWindow(WNDCLASS_STATIC, "保存目录", WS_CHILD|SS_TEXT, (LCD_WIDTH - 100)/2 , 65, 100, BUTTON_W, mainwin, 0, NULL); 
	directory = CreateWindow(WNDCLASS_STATIC, "\\", WS_CHILD|SS_TEXT|SS_BOARD|SS_LEFT, (LCD_WIDTH - 140)/2, 85, 115, BUTTON_W, mainwin, 0, NULL); 
	up = CreateWindow(WNDCLASS_BUTTON, "\\返回上级目录", WS_CHILD|BS_REGULAR, (LCD_WIDTH - 140)/2 + 120, 85, BUTTON_W, BUTTON_W,	mainwin, 0x00140014, (char *)zi_back); 
	back = CreateWindow(WNDCLASS_STATIC, "", WS_CHILD|SS_BOARD, (LCD_WIDTH - 140)/2, 107, 137, 110, mainwin, 0, NULL); 
	scroll = CreateWindow(WNDCLASS_SCROLL, "", WS_CHILD|SBS_VERT, (LCD_WIDTH - 140)/2 + 139, 107, 20, 110, mainwin, MAKELONG(1, length - SAVE_DISP_MAX + 1), NULL); 
//	keybd = CreateWindow(WNDCLASS_BUTTON, "", WS_CHILD|BS_REGULAR, 30, 220, BUTTON_W, BUTTON_W, mainwin, 0, NULL); 

	tskbar = CreateWindow(WNDCLASS_TSKBAR, NULL, WS_CHILD|TBS_TYPICAL, 0, 0, 0, 0,mainwin, 0, NULL);
	keybd = AddBtn2TskBar(tskbar, NULL, BS_ICON, BUTTON_W, (char *)zi_jianpan); 

	for(i = 0; i < SAVE_DISP_MAX; i++)				//显示目录/文件列表
	{		
		if(i < dirnum)
		{
			property[i] = CreateWindow(WNDCLASS_BUTTON, "\\属性", WS_CHILD|BS_ICON, (LCD_WIDTH - 140)/2 + 1, (U16)(108 + 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 - 140)/2 + 23, (U16)(108 + i*(BUTTON_W + 1)), 115, BUTTON_W, mainwin, 0, NULL);		//目录列表
		}
		else
		{
			property[i] = CreateWindow(WNDCLASS_BUTTON, "\\属性", WS_CHILD|BS_ICON, (LCD_WIDTH - 140)/2 + 1, (U16)(108 + i*(BUTTON_W + 1)), BUTTON_W, BUTTON_W, mainwin, 0, NULL);		//显示空按钮
			note[i] = CreateWindow(WNDCLASS_BUTTON, "", WS_CHILD|BS_REGULAR, (LCD_WIDTH - 140)/2 + 23, (U16)(108 + 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 == save)
				{
					GetEditorStr(nameedit, name, NAME_SIZE + 1); 
					if(strlen(name) == 0)
					{
						MessageBox(mainwin, "请输入文件名!!!", "提醒", MB_ICONEXCLAMATION|MB_OK); 
					}
					else
					{
						newitem.name = name; 
						AddDirFile(&newitem); 
						saveflag = 1; 
						quit = 1; 
					}
				}
				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 = SAVE_DISP_MAX;				//得出滚动条的长度
					for(i = 0; i < allnum; i++)
					{
						if(*(nowlist[i]->id) == 0)			//当项目类型为文件时,跳出
							break; 
					}
					dirnum = i;							//得出目录的个数
					if(dirnum > SAVE_DISP_MAX)
					{
						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(msg.lparam == keybd)
				{
					if(kbflag == 0)
					{
						for(i = 0; i < SAVE_DISP_MAX; i++)
						{
							EnableWindow(note[i], FALSE); 
							EnableWindow(property[i], FALSE); 
						}
						EnableWindow(up, FALSE); 
						keyboard = CreateWindow(WNDCLASS_KEYBD, "", WS_CHILD|KBS_UPCASE|0xff, 1, 148, 157, 70, mainwin, 0, NULL); 
						SetFocus(nameedit); 
						kbflag = 1; 
					}
					else
					{
						DestroyWindow(keyboard); 
						kbflag = 0; 
						for(i = 0; i < SAVE_DISP_MAX; i++)
						{
							EnableWindow(note[i], TRUE); 
							EnableWindow(property[i], TRUE); 
						}
						EnableWindow(up, TRUE); 
					}
				}
				else
				{
					for(i = 0; i < SAVE_DISP_MAX; i++)
					{
						if((i + row - 1) < dirnum)
						{
							if(msg.lparam == note[i])
							{
								if(offset == -1)			//没有已选目录/文件时,设定点击的目录/文件按钮反色,表示选中
								{
									RepaintWindow(note[i], BS_INVERT); 
									offset = i + row - 1; 
								}
								else
								if(offset == (i + row - 1))			//当点击的是已选目录/文件时,分别作处理
								{
									strcpy(currentid, nowlist[i]->parent); 
									strcat(currentid, nowlist[offset]->id); 
									strcpy(currentdir, nowlist[offset]->name); 
									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);		//解析数据
								
									for(i = 0; i < allnum; i++)
									{
										if(*(nowlist[i]->id) == 0)			//当项目类型为文件时,跳出
											break; 
									}
									dirnum = i;							//得出目录的个数
									length = SAVE_DISP_MAX;				//得出滚动条的长度
									if(dirnum > SAVE_DISP_MAX)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -