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

📄 appfilelist.c

📁 中芯微camera 图像处理芯片演示
💻 C
字号:
/*-------------------------------------------------------------------------------
//appFileList
// 文件列表的主程序
// Create by jsguo 2005.9.8
--------------------------------------------------------------------------------*/


#include "../inc/nucleus.h"
#include "../inc/winconfig.h"
#include "MMI.h"
#include "../inc/windows.h"

#include "../inc/nucleus.h"
#include "../inc/nu_sd.h"

extern NU_SERIAL_PORT  port;   
//int gnShowFileListMenu;
int gnFileListselectItem;

LRESULT CALLBACK VMFileListProc(HWND,UINT,WPARAM,LPARAM);
static char listpath[50];
//--------------------------------------------------------------------------------
// 菜单响应函数

InitMWindow initMyFileList;
//Form gMyFormFileListList;
//extern int fileLevel;
extern Form gMyFormFileListList;//[fileLevel];
extern char BPath[30];
CloseMWindow closeMyFileList;
//int SetFileList(InitMWindow init,CloseMWindow close,Form FormFileListList)
int SetFileList(InitMWindow init,CloseMWindow close)
{
	initMyFileList=init;
	initMyFileList();
	closeMyFileList=close;
	//gMyFormFileListList=FormFileListList;
	return 1;
}

int MMI_GetFileListSelectItem()
{
	//return gnShowFileListMenu;
	return gnFileListselectItem;
}

char* MMI_GetFileListSelectItem_Name()
{
	return gMyFormFileListList.MenuList[gnFileListselectItem].MenuName;
}

int WINAPI VMFileListMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   PSTR szCmdLine, int iCmdShow)
{
        static char szAppName[]="FileListApp";
        HWND hwnd;
        MSG msg;
        WNDCLASS wndclass1;

	
        wndclass1.style          = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
        wndclass1.lpfnWndProc    = (WNDPROC)VMFileListProc;
        wndclass1.cbClsExtra     =0;
        wndclass1.cbWndExtra     =0;
        wndclass1.hInstance      =0;
        wndclass1.hIcon          =0;
        wndclass1.hCursor        =0;
        wndclass1.hbrBackground  =(HBRUSH)GetStockObject(WHITE_BRUSH);
        wndclass1.lpszMenuName   =NULL;
        wndclass1.lpszClassName  = szAppName;
	
	if(initMyFileList==NULL)
	{
		return 0;
	}

     	RegisterClass(&wndclass1);
 	hwnd=CreateWindowEx(0L,
                          szAppName,
                          "FileList",
                          WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                          CW_USEDEFAULT,
                          CW_USEDEFAULT,
                          MAINFRAME_WIDTH_DEFAULT,
                          MAINFRAME_HEIGHT_DEFAULT,
                          NULL,
                          NULL,
                          NULL,
                          NULL);
               
         gnFileListselectItem=0;      
        ShowWindow(hwnd,iCmdShow);
        UpdateWindow(hwnd);
     
        while (GetMessage(&msg,NULL,0,0)) {
Uart_Printf("GUI filelist start\r\n");			
                TranslateMessage(&msg);
                DispatchMessage(&msg);
Uart_Printf("GUI filelist end\r\n");					
        }      
           return msg.wParam;
}  

SLIDER_Obj gScrollBarFileList={0x40c1ff,0xffff00,2,5,MAINFRAME_HEIGHT_DEFAULT-25,5,5};

int FileList_DeleteItem(int DeleteItem)
{
	int MyDeleteItem;
	int i;
	MyDeleteItem=DeleteItem;
	for(i=MyDeleteItem;i<=gMyFormFileListList.MenuSize-1;i++)
	{
		strcpy(gMyFormFileListList.MenuList[i].MenuName, gMyFormFileListList.MenuList[i+1].MenuName);
	    	gMyFormFileListList.MenuList[i].event=gMyFormFileListList.MenuList[i+1].event;
	}
	gMyFormFileListList.MenuSize--;
	return 1;//succ
}
int gDeleteSign=1;

LRESULT CALLBACK VMFileListProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{       
        HDC hdc;    
        PAINTSTRUCT ps;
	RECT rect1;
 	int i,keyvalue,y,nSliderValue=0,filedata;
	HBRUSH hBrush,hBgBrush;

	KeyEvent event;

	switch (iMsg) {
        case WM_CREATE:
//		gnShowFileListMenu = 1;
	        break;
        case WM_PAINT:
		hBrush = CreateSolidBrush(COLOR_SELECT);//0xa3138);//GetSysColor(COLOR_MENU));
		hBgBrush = CreateSolidBrush(COLOR_NORMAL);

		hdc=BeginPaint(hwnd,&ps);

		if((gMyFormFileListList.CurrentMenuItem-2)!=0)
			nSliderValue=(gScrollBarFileList.slnEndX-gScrollBarFileList.slnStartX)/(gMyFormFileListList.CurrentMenuItem-2);
		else
			nSliderValue=gScrollBarFileList.slnEndX;

		rect1.left = 10;
		rect1.right = MAINFRAME_WIDTH_DEFAULT;
		rect1.top = 0;
		rect1.bottom = LIST_HEIGHT_DEFAULT+1;
		for( i = 0;(i < LIST_DATA_DEFAULT)&&(gnFileListselectItem<LIST_DATA_DEFAULT); i++)
		{
			if(gnFileListselectItem == i)
			{
				FillRect(hdc,&rect1,hBrush);
			}
			else
			{
				FillRect(hdc,&rect1,hBgBrush);
			}
			if(i<gMyFormFileListList.CurrentMenuItem)
			{
				DrawText(hdc,gMyFormFileListList.MenuList[i].MenuName,-1,&rect1,
					DT_SINGLELINE|DT_CENTER|DT_VCENTER);
				Uart_SendString(gMyFormFileListList.MenuList[i].MenuName);//FileListMenu[gMyFormFileListList.MenuSize].MenuName);
			}
			rect1.top += LIST_HEIGHT_DEFAULT+1+1;
			rect1.bottom += LIST_HEIGHT_DEFAULT+1+1;
			
		}
		
		if((gnFileListselectItem>=LIST_DATA_DEFAULT))
		{
			for(y=gnFileListselectItem,rect1.bottom=MAINFRAME_HEIGHT_DEFAULT+8;rect1.bottom>=LIST_HEIGHT_DEFAULT/2+1;rect1.bottom-=(LIST_HEIGHT_DEFAULT+1+1),y--)
			{	
				rect1.top=rect1.bottom-LIST_HEIGHT_DEFAULT-1;
				if(y  == gnFileListselectItem-1)
				{
					FillRect(hdc,&rect1,hBrush);
				}
				else
				{
					FillRect(hdc,&rect1,hBgBrush);
				}
				DrawText(hdc,gMyFormFileListList.MenuList[y+1].MenuName,-1,&rect1,
				DT_SINGLELINE|DT_CENTER|DT_VCENTER);
			}
		}

		gScrollBarFileList.slnCurrentX=nSliderValue*gnFileListselectItem;
		DisplaySlider(hwnd,gScrollBarFileList);
		//gMyFormFileListList.CurrentMenuItem=0;
	      	DeleteObject(hBgBrush);
		DeleteObject(hBrush);

            	EndPaint(hwnd,&ps);
		break;
	case WM_DESTROY:
                PostQuitMessage(0);
                break;
	case WM_KEYUP:
		keyvalue = wParam - 49;
		if(keyvalue == KEY_CANCEL)
		{
			if(closeMyFileList != NULL)
			{
				closeMyFileList();
			}
			PostMessage(hwnd,WM_CLOSE,0,0);
			break;
		}
		if(keyvalue==KEY_DELETE)
		{
			VMDeleteFileMain(NULL,NULL,NULL,SW_SHOW);
			if(gDeleteSign==0)
			{
				break;
			}
			USER_FileList_Delete(gMyFormFileListList.MenuList[gnFileListselectItem].MenuName);
			FileList_DeleteItem(gnFileListselectItem);
			PostMessage(hwnd,WM_PAINT,0,0);
			gDeleteSign=1;
		}
		if((keyvalue == KEY_UP) || (keyvalue == KEY_DOWN)||(keyvalue == KEY_OK))			
		{
			if((keyvalue == KEY_OK))
			{						
				event = NULL;
				event = gMyFormFileListList.MenuList[gnFileListselectItem].event;
				if((event == NULL)||(strcmp("..",gMyFormFileListList.MenuList[gnFileListselectItem].MenuName)==0))
				{					
					fn_chdir(gMyFormFileListList.MenuList[gnFileListselectItem].MenuName);//MMD_FILE_ChangeDir(gMyFormFileListList.MenuList[gnFileListselectItem].MenuName);
					gMyFormFileListList.CurrentMenuItem=0;
					AppInit_FileList();
					gnFileListselectItem=0;		
				}
				else
				{					
					event(iMsg, wParam, lParam);
					return 1;
				}
			}
			if(keyvalue == KEY_DOWN)
				gnFileListselectItem ++;
			else if (keyvalue == KEY_UP)
				gnFileListselectItem --;
			if(gnFileListselectItem < 0)
				gnFileListselectItem = gMyFormFileListList.CurrentMenuItem - 1;
			else if(gnFileListselectItem >= gMyFormFileListList.CurrentMenuItem)
				gnFileListselectItem = 0;
			PostMessage(hwnd,WM_PAINT,0,0);
		}
		break;
       default:
                return DefWindowProc(hwnd,iMsg,wParam,lParam);
        }
        return (0);
}

⌨️ 快捷键说明

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