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

📄 list1.c

📁 国家ASIC工程中心使用的嵌入式操作系统
💻 C
字号:
/*
 *
 */
 
 
#include <sys\sysusr.h>
#include <sys\sysmsg.h>


#include <asixwin.h>
#include <asixapp.h>
#include <asixwin\asix_ed.h>
#include <asixwin\asix_tb.h>
#include <ctype.h>


#include <resource\bitmap.h>


#include "WordM1.h"
#include "List1.h"
#include "wordDetail1.h"

//外部变量申明
extern unsigned	char	*pWordBuf[MAXWORDNUM];
extern unsigned	char	*pTestModify[MAXWORDNUM];
extern unsigned	char	*pAnswerModify[MAXWORDNUM];
extern unsigned	char	*pExpBuf[MAXWORDNUM];
extern unsigned char	*pTestBuf[MAXWORDNUM];
extern unsigned char	*pAnswerBuf[MAXWORDNUM];

/*******************************************************************
* Function: 	ListWord()
*
* Parameter: 	void
*
* Description:	This Function use to Show the Words
*
* returns:	
*
*********************************************************************/
void ListWord(int lev,int list, int counter)
{
	//窗口和控件ID
	U32 	mainwin;
	U32 	tskbar;
	U32 	List[40];
	U32 	stroll;
	
	//变量申明
	MSG 	msg;
	U8 		quit = 0;
	int 	i,margin = 5;
	S16     row = 1;
	S16     dragflag = 0;
	
	mainwin = CreateWindow( WNDCLASS_WIN,
							"单词列表",
							WS_OVERLAPPEDWINDOW,
							0, 0, LCD_WIDTH, LCD_HEIGHT,
							0, 
							0, 
							NULL );
	tskbar = CreateWindow( 	WNDCLASS_TSKBAR,
							NULL,
							WS_CHILD|TBS_TYPICAL,
							0, 0, 0, 0,
							mainwin,
							0,
							NULL );
	
		
	
	for(i = 0; i < WM_LIST_NUM; i++)
	{
		List[i] = CreateWindow( WNDCLASS_BUTTON,
								NULL,
								WS_CHILD|BS_BOARD,
								margin,
							 	LCD_HEIGHT/8+i*20 ,
							 	LCD_WIDTH - 2*margin - 20,
							 	20,
							 	mainwin,
							 	0, 
							 	NULL);
		} 
	stroll = CreateWindow( 	WNDCLASS_SCROLL,
							NULL,
							WS_CHILD|SBS_VERT,
						   	LCD_WIDTH - margin - 20,
						   	LCD_HEIGHT/8,
						   	20,
						   	WM_LIST_NUM*20,
						   	mainwin,
						   	MAKELONG(1, 40 - WM_LIST_NUM + 1),
						   	NULL );
	for(i = 0; (i < WM_LIST_NUM)&&(i <= counter - 1); i++ )
	{
	SetWindowText(List[i], pWordBuf[i] , NULL);
	}
	while(!quit)
	{
		ASIXGetMessage(&msg, NULL, 0, 0);
		switch(msg.message)
	  	{
	      	case WM_PENDOWN:
	           	for(i = 0; (i < WM_LIST_NUM)&&(i <= counter - 1); i++)			//判断点击哪个
			   	{
				   	if(msg.lparam == List[i])
				   	{
	                   	ShowDetail(list,i+row);
				   	}
			   	}
			   	break; 

		  	case WM_VSCROLL:
			   	if(msg.lparam == stroll)
			   	{
				   	switch(msg.wparam)
				   	{
					   	case SB_PAGEUP:
						   	row -= WM_LIST_NUM;
						   	if (row < 1)
							   	row = 1;
						   	break;
	
					   	case SB_PAGEDOWN:
						   	row += WM_LIST_NUM;
						   	if (row > (40 - WM_LIST_NUM + 1))
							   	row = (40 - WM_LIST_NUM + 1);
						   	break;
						   
					   	case SB_LINEUP:
					       	row -= 1; 
						   	if (row < 1)
							   	row = 1;
						   	break;
	
					   	case SB_LINEDOWN:
					       	row += 1; 
						   	if (row > (40 - WM_LIST_NUM + 1))
							   	row = (40 - WM_LIST_NUM + 1);
						   	break;
						   
					   	case SB_THUMBTRACK:
						   	dragflag = 1;
						   	break;
					
					   	case SB_ENDSCROLL:
						   	row = GetScrollPos(stroll,0,0,0);
						   	dragflag = 0;
						   	break;
				   	}
				
				   	if(!dragflag)
				   	{
					   	SetScrollPos(stroll,row,0,0); 					// 滚动条拖动定位
					    
					   	//显示的更新
					   	for(i = 0; i < WM_LIST_NUM; i++)
						if(row - 1 + i <= counter - 1)
							SetWindowText(List[i], pWordBuf[row - 1 + i], NULL);
						else 
							SetWindowText(List[i], NULL, NULL);
						SetScrollRange(stroll, 1, (U16)(40 - WM_LIST_NUM + 1));
	                   	SetScrollPos(stroll, (U16)(row + 1), 0,0);
	               	}
				}
			   	break;

		  	case WM_QUIT:
			   	quit = 1;
			   	break;
		  
		}
	  	DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam); 
	}
	DestroyWindow( mainwin ); 
	for(i = 0;i < counter - 1; i++)
	{
		free(pExpBuf[i]);
		free(pWordBuf[i]);
	}
	return;
}
	  
/*******************************************************************
* Function: 	ListTest()
*
* Parameter: 	int lev , int list
*
* Description:	This Function use to create the window of Test,and the answer of the Test
*
* returns:	
*
*********************************************************************/	  
void ListTest(int lev,int list, int counter)
{
	//窗口和控件ID
	U32 mainwin;
	U32 tskbar;
	U32 TestDisp;
	U32 AnswerDisp;
	U32 NextWord_bt;
	U32 PrevWord_bt;
	U32 Confirm_bt;
	
	//变量申明
	MSG 	Tmsg;
	U8 	    quit = 0;
	int 	margin = 5, Counter;
	S16     row = 1;
	S16     dragflag = 0;
	S16	    page = 0;
	char    *Empty = "";
	int		i;
	switch(lev)
	{
		case 4:
			mainwin = CreateWindow(	WNDCLASS_WIN,
									"四级单词测试",
									WS_OVERLAPPEDWINDOW,
									0, 0, LCD_WIDTH, LCD_HEIGHT,
									0,
									0,
									NULL);
			break;
	
		case 6:
			mainwin = CreateWindow( WNDCLASS_WIN,
									"六级单词测试",
									WS_OVERLAPPEDWINDOW,
									0, 0, LCD_WIDTH, LCD_HEIGHT,
									0,
									0,
									NULL);
			break;
	
		case 10:
			mainwin = CreateWindow( WNDCLASS_WIN,
									"考研单词测试",
									WS_OVERLAPPEDWINDOW,
									0, 0, LCD_WIDTH, LCD_HEIGHT,
									0,
									0,
									NULL);
			break;
	
		default:
			break;
	}
	
	tskbar = CreateWindow(	WNDCLASS_TSKBAR,
							NULL,
							WS_CHILD|TBS_TYPICAL,
						 	0, 0, 0, 0,
						 	mainwin,
						 	0,
						 	NULL);
	NextWord_bt = CreateWindow(	WNDCLASS_BUTTON,
								"下一题",
								WS_CHILD | BS_REGULAR,
							   	LCD_WIDTH - 40,
							   	LCD_HEIGHT - 45,
							   	40,
							   	20,
							   	mainwin,
							   	0,
							   	NULL);
	PrevWord_bt = CreateWindow(	WNDCLASS_BUTTON,
								"上一题", 
								WS_CHILD | BS_REGULAR,
							   	LCD_WIDTH - 90,
							   	LCD_HEIGHT - 45,
							   	40,
							   	20,
							   	mainwin,
							   	0,
							   	NULL);
	Confirm_bt = CreateWindow(	WNDCLASS_BUTTON, 
								"显示答案",
								WS_CHILD|BS_REGULAR,
							  	LCD_WIDTH - 190,
							  	LCD_HEIGHT - 45,
							  	90,
							  	20,
							  	mainwin,
							  	0,
							  	NULL);
	
	//Counter = 40;
	Counter = RangeTest(counter);
	TestDisp = CreateWindow(WNDCLASS_EDITOR,
							NULL,
							WS_CHILD|ES_MULTI_REGULAR,
							0,
							20,
							LCD_WIDTH,
							LCD_HEIGHT - 130,
							mainwin,
							EXP_LEN + 1,
							NULL);
	AnswerDisp = CreateWindow(	WNDCLASS_EDITOR,
								"本题答案",
							  	WS_CHILD|ES_MULTI_REGULAR,
							  	0,
							  	LCD_HEIGHT - 110,
							  	LCD_WIDTH,
							  	60,
							  	mainwin,
							  	2*EXP_LEN + 1,
							  	NULL);
	SetWindowText(TestDisp, pTestModify[page],NULL);
	while(!quit)
	{
		ASIXGetMessage(&Tmsg, NULL, 0, 0);
		switch(Tmsg.message)
	  	{
	  	
	      	case WM_COMMAND:
				if (Tmsg.lparam == NextWord_bt)
				{	
					page++;
					if(page<Counter)
					{
					SetWindowText(TestDisp, pTestModify[page],NULL);
					SetWindowText(AnswerDisp, Empty,NULL);
					}
				}
				else if(Tmsg.lparam == PrevWord_bt)
				{    if ( page < 0 )
	        	     		 page = 0;
					 page--;
	        	    SetWindowText(TestDisp, pTestModify[page],NULL);
					SetWindowText(AnswerDisp, Empty,NULL);
				}
				else if (Tmsg.lparam == Confirm_bt)
					 SetWindowText(AnswerDisp, pAnswerModify[page],NULL);
				break;
		  
			case WM_QUIT:
		  		quit = 1;
				break; 
	      
			default:
	      			break;
		}
		DefWindowProc(Tmsg.message, Tmsg.lparam, Tmsg.data, Tmsg.wparam);
	}
	DestroyWindow( mainwin );
	for(i = 0; i < Counter; i++)
	{
	free(pAnswerModify[i]);
	free(pTestModify[i]);
	}
	return;
}

⌨️ 快捷键说明

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