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

📄 color.c

📁 一个操作系统源代码 用于嵌入式设备 在Vc++环境下仿真 成功移植到多款处理器上
💻 C
字号:
#include <stdio.h>
#include <string.h> 
#include <math.h>


#include <asixwin.h>
#include <asixapp.h>

#include <asixwin\asix_mn.h>
#include <asixwin\select.h>
#include <asixwin\asix_sb.h>
#include <asixwin\asix_lb.h>
#include <asixwin\disp.h>
#include <asixwin\asix_ed.h>
#include <asixwin\asix_key.h>

#include <resource\bitmap.h>
#include <resource\picture.h>


extern void   Col();

extern char   gpc[][50];
extern unsigned long  rgb[];

#define NUM       (LCD_HEIGHT-47-88-25)/20    //取整
#define ALLNUM    148



//注册表
TASKDESCRIPTION ColorTskDesp = 
{"颜色", ASIX_APP, 0, yanshi, 4096, 1, LCD_WIDTH, LCD_HEIGHT, Col, APP_PRI};

void Col()
{
     //窗口和控件ID
     U32     mainwin;
     U32     editor;
     U32     list[NUM];
     U32     display;
     U32     scroll;
     U32     tskbar;
     
     //函数变量
     U8      quit = 0; 
     U8      i = 0;
//   U16     length = ALLNUM;
     MSG     msg; 
     U32     pGC;
     S16     row = 1;
	 S16     dragflag = 0;

     
     U32     editor_w = LCD_WIDTH * 2 / 3, editor_h = 20;
     
     U32     margin = 0.5 * (LCD_WIDTH - editor_w);
     
     U32     editor_x = margin, editor_y = 25;
     
     U32     scroll_w = 20, scroll_h = 20 * NUM;
     
     U32     list_x = margin;
     U32     list_w = editor_w - scroll_w;
     
     U32     display_h = (LCD_HEIGHT - 47 - 20 - 20*NUM)/2;
     U32     display_w = editor_w;
     U32     display_x = margin;
     U32     display_y = 47 + 20 * NUM + display_h/2; 
     
     
     U32     scroll_x =  list_x + list_w;
     U32     scroll_y =  47;
     
 //    memset();
      
	 //创建按钮
     mainwin = CreateWindow(WNDCLASS_WIN, "颜色", WS_OVERLAPPEDWINDOW, 0, 0, LCD_WIDTH, LCD_HEIGHT, 0, 0, NULL); 
     editor = CreateWindow(WNDCLASS_EDITOR, NULL, WS_CHILD|ES_SINGLE_REGULAR, editor_x, editor_y, editor_w, editor_h, mainwin, 0, NULL);
     for(i = 0; i < NUM; i++)
     {
         list[i] = CreateWindow(WNDCLASS_BUTTON, NULL, WS_CHILD|BS_ICON|BS_FLAT|BS_LEFT, list_x, (U16)(47 + i*20), list_w, 20, mainwin, 0, NULL);
     }
     display = CreateWindow(WNDCLASS_STATIC, NULL, WS_CHILD|SS_TEXT|SS_BOARD|SS_MULTILINE, display_x, display_y, display_w, display_h, mainwin, 0, NULL);
     tskbar = CreateWindow(WNDCLASS_TSKBAR, NULL, WS_CHILD|TBS_TYPICAL, 0, 0, 0, 0, mainwin, 0, NULL);
     scroll = CreateWindow(WNDCLASS_SCROLL, NULL, WS_CHILD|SBS_VERT, scroll_x, scroll_y, scroll_w, scroll_h,mainwin, MAKELONG(1, ALLNUM - NUM + 1), NULL);
       
     //显示列表
     for(i = 0; i < NUM; i++)
     {
	     SetWindowText(list[i], gpc + i, NULL); 
     }
     
     pGC = GetGC();



     while(!quit)
	 {
 		  ASIXGetMessage(&msg, NULL, 0, 0); 
		  switch(msg.message)
		  {
		      case WM_PENDOWN:
		           for(i = 0; i < NUM; i++)			//判断点击哪个列表并显示颜色
				   {
					   if(msg.lparam == list[i])
					   {
                           ClearRec(pGC, rgb[i + row - 1], display_x, display_y, display_w, display_h, GPC_REPLACE_STYLE);
                           DrawText(pGC, "色彩测试", display_x, display_y, display_w + display_x, display_h + display_y,NULL, GPC_WHITE, GPC_REPLACE_STYLE);
						   SetWindowText(editor, gpc + i + row - 1, NULL);
					   }
		  
				   }
				   break;
 
 		        
 			  case WM_VSCROLL:
				   if(msg.lparam == scroll)
				   {
					   switch(msg.wparam)
					   {
						   case SB_PAGEUP:
							   row -= NUM; 
							   if (row < 1)		
								   row = 1; 
							   break; 

						   case SB_PAGEDOWN:
							   row += NUM; 
							   if (row > (ALLNUM - NUM + 1))	
								   row = (ALLNUM - NUM + 1); 
							   break;
							   
						   case SB_LINEUP:
						       row -= 1; 
							   if (row < 1)		
								   row = 1; 
							   break; 

						   case SB_LINEDOWN:
						       row += 1; 
							   if (row > (ALLNUM - NUM + 1))	
								   row = (ALLNUM - NUM + 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); 					// 滚动条拖动定位
						    
						   //显示的更新
						   for(i = 0; i < NUM; i++)		
							  SetWindowText(list[i], gpc + row - 1 + i, NULL);
						   
						   //显示颜色
						   ClearRec(pGC, rgb[row - 1], display_x, display_y, display_w, display_h, GPC_REPLACE_STYLE);
                           DrawText(pGC, "色彩测试", display_x, display_y, display_w + display_x, display_h + display_y,NULL, GPC_WHITE, GPC_REPLACE_STYLE);
						   

                           SetWindowText(editor, gpc + row - 1, NULL);
                                                   
                           SetScrollRange(scroll, 1, (U16)(ALLNUM - NUM + 1));
                           SetScrollPos(scroll, (U16)(row + 1), 0,0);
                       }
				   }	   
				   break;
 				   

			  case WM_QUIT:
				   quit = 1; 
				   break; 

		  
		  }
			
          DefWindowProc(msg.message, msg.lparam, msg.data, msg.wparam); 

      }


      DestroyWindow( mainwin ); 
	  EndofTask(); 
	  return;  

}

⌨️ 快捷键说明

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