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

📄 mainform.c

📁 中芯微camera 图像处理芯片演示
💻 C
字号:
#include "../inc/nucleus.h"
#include "../inc/winconfig.h"
#include "MMI.h"
#include "../inc/windows.h"
#include "icon.h"
//#include "Extern.h"
#include "../inc/nu_sd.h"

extern NU_SERIAL_PORT  port;   
int mainSelectedItem = 1;


//int g_CameraSign;

LRESULT CALLBACK mainproc(HWND,UINT,WPARAM,LPARAM);

int WINAPI MWinMainForm(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   PSTR szCmdLine, int iCmdShow)
{
        static CHAR szAppName[]="MMIMainForm";
        HWND hwnd;
        MSG msg;
        WNDCLASS wndclass;

	MwRegisterButtonControl(NULL);
	MwRegisterEditControl(NULL);

        wndclass.style          = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
        wndclass.lpfnWndProc    = (WNDPROC)mainproc;
        wndclass.cbClsExtra     =0;
        wndclass.cbWndExtra     =0;
        wndclass.hInstance      =0;
        wndclass.hIcon          =0;
        wndclass.hCursor        =0;
        wndclass.hbrBackground  =(HBRUSH)GetStockObject(WHITE_BRUSH);

        wndclass.lpszMenuName   =NULL;
        wndclass.lpszClassName  = szAppName;


        RegisterClass(&wndclass);
        hwnd=CreateWindowEx(0L,
                          szAppName,
                          "858DEMO",
                          WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                          CW_USEDEFAULT,
                          CW_USEDEFAULT,
 			  MAINFRAME_WIDTH_DEFAULT,
                          MAINFRAME_HEIGHT_DEFAULT,
                          NULL,
                          NULL,
                          NULL,
                          NULL);
          
        ShowWindow(hwnd,iCmdShow);
        UpdateWindow(hwnd);
        while (GetMessage(&msg,NULL,0,0)) {

       // while (1) {
  Uart_Printf("\n GUI MainForm start 0x%x",msg.message);

                TranslateMessage(&msg);
               DispatchMessage(&msg);
  Uart_Printf("\n GUI MainForm end");
        }      
        return msg.wParam;
}
CHAR mainItemword[] = "Item  ";

void Init_GUI(void)
{
	InitGUI(0, NULL,MainMenu_MainList);//MWinMainForm);
}

static int mainMatrix[9][4] = 
{
	{7,4,3,2},
	{8,5,1,3},
	{9,6,2,1},
	{1,7,6,5},
	{2,8,4,6},
	{3,9,5,4},
	{4,1,9,8},
	{5,2,7,9},
	{6,3,8,7}
};

extern NU_TIMER video_timer;
InitMWindow initMyMainList;

static vmMMIApp gMyMMIMainList[] = 
{
	{"文件夹",		files,	        	Menu_DocumentList},
	{"照相机",		camera,			Menu_Camera},
	{"设置",			setting,			Menu_SettingList},
	{"录像",			multimedia,		Menu_Camera},
	{"录音",			game,			NULL},
	{"短消息",		mms,			NULL},
	{"电话本",		phonebook,		NULL},
	{"通话",			phonerecord,	NULL},
	{"U-DISK",			tools,			Menu_UDisk}
};

void User_TimerProcess(UNSIGNED val)
{
	VIM_HAPI_Timer();
}

int SetMainList(InitMWindow init)
{
	//NU_Create_Timer(&video_timer,"display video",User_TimerProcess,1,10,2,NU_DISABLE_TIMER);
	initMyMainList=init;
	initMyMainList();
	return 1;
}

// 消息循环函数
LRESULT CALLBACK mainproc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{      
      HDC hdc;
      PAINTSTRUCT ps;
      RECT rect,rect1,rect2;

	int keyvalue,x,y,i,item;
	BITMAP bmMyBitmap;
	HBRUSH hBrush;
	HBRUSH hSelectBrush;
        switch (iMsg) 
		{
        case WM_PAINT:
		hBrush = CreateSolidBrush(0xf0000f);//GetSysColor(COLOR_3DLIGHT));
		hSelectBrush = CreateSolidBrush(0x1c3248);//GetSysColor(COLOR_MENU));
		hdc=BeginPaint(hwnd,&ps);
	      	GetClientRect(hwnd,&rect);

		i = 0;
		for(y = 0; y < 3; y++)
		for(x = 0; x < 3; x++)
		{
			i++;
		
			rect2.top = 14+ 90*y;
			rect2.left = 8 + 75*x;
			rect2.right = rect2.left + 69;
			rect2.bottom = rect2.top + 69;
			if(mainSelectedItem == i)
				FillRect(hdc,&rect2,hSelectBrush);
//			else
//				FillRect(hdc,&rect2,hBrush);

			if(hwnd == GetActiveWindow())
			{
				bmMyBitmap.bmPositionX=rect2.left+5;
				bmMyBitmap.bmPositionY=rect2.top+18;
				bmMyBitmap.bmBits=gMyMMIMainList[i-1].pBitmap;
				DisplayBitmap(bmMyBitmap);
			}

			rect1.top = rect2.top+75;//36 + 45*y;
			rect1.bottom = rect1.top + 25;
			rect1.left = rect2.left+5;//10 + 35 * x;
			rect1.right = rect1.left + 60;

			DrawText(hdc,gMyMMIMainList[i-1].AppName,-1,&rect1,
                     		DT_SINGLELINE|DT_CENTER|DT_VCENTER);
			SetWindowText(hwnd,mainItemword);
		}
		DeleteObject(hSelectBrush);
		DeleteObject(hBrush);
            	EndPaint(hwnd,&ps);
                break;
        case WM_DESTROY:
                PostQuitMessage(0);
                break;
	case WM_KEYUP:
			keyvalue = wParam - 49;
				switch(keyvalue) //by leon
				{
					case KEY_UP:
						keyvalue=0;
						break;
					case KEY_DOWN:
						keyvalue=1;
						break;
					case KEY_LEFT:
						keyvalue=2;
						break;
					case KEY_RIGHT:
						keyvalue=3;
						break;
					default:
						//keyvalue=0;
						break;
				}
			if((keyvalue >= 0) && (keyvalue < 4))
			//if(keyvalue==KEY_UP||keyvalue==KEY_DOWN||keyvalue==KEY_LEFT||keyvalue==KEY_RIGHT)
			{
				// 按下方向键,重绘

				item = mainMatrix[mainSelectedItem-1][keyvalue];
				if(item > 0)
				{
					mainSelectedItem = item;
					PostMessage(hwnd,WM_PAINT,0,0);
				}
			}
			else
			{
				//if(keyvalue == 4) // 选中键
				if(keyvalue == KEY_OK) 
				{
					// 根据当前选择的项目,调用相应的主函数
					/*
					MainEntry main = gMyMMIMainList[mainSelectedItem-1].event;
					if(main != NULL)
						main(NULL, NULL, NULL, SW_SHOW);
					*/
					
					KeyEvent MyEvent=gMyMMIMainList[mainSelectedItem-1].event;
					//g_CameraSign=mainSelectedItem-1;
					if(MyEvent != NULL)
						MyEvent(0,0,0);

				}
			}
			break;
        default:		
                return DefWindowProc(hwnd,iMsg,wParam,lParam);
        }  
        return (0);
}


int MMI_GetMainFormSelectItem()
{	
	return mainSelectedItem;
}

⌨️ 快捷键说明

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