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

📄 mmi.cpp

📁 MTK手机平台的MMI部分的源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
		ReadKeyProfile,
		ResetKeyMemory,
		lcd_dspl_init,
		shutdown_system_operation,
		launch_nw_simulator,
		on_timer,
		IN_PC_SIMULATOR | IN_LEVEL_1_RELEASE
	);
	/* wait the dll UI up */
	Sleep(1000);
	SetCurrentDirectory("..\\");
#endif

#ifndef USING_DLL_UI
	/************* Vijay *****************/
	/* Main message loop: */
	while (GetMessage(&msg, NULL, 0, 0)) 
	{

	/*	if(!gbIsCustomizerOn) */
	/*	{ */
			if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
	/*	} */
	}

    {
        fclose(DebugFile);
    }

	return msg.wParam;
#endif

#ifdef USING_DLL_UI
	return 0;
#endif
} /* end of WinMain */

/*****************************************************************************
* FUNCTION
*  AutomaticBoopup
* DESCRIPTION
*   MTK added by JL 040319 for level 1 auto bootup release
*
* PARAMETERS
*  hwnd		IN		HWND
*  uMsg		IN		UINT
*	idEvent	IN		UINT
*	dwTime	IN		DWORD
* RETURNS
*	nil
* GLOBALS AFFECTED
*	nil
*****************************************************************************/
#if defined(__CUSTOMER_LEVEL_1_RELEASE__)
void CALLBACK AutomaticBoopup(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime )
{
	/*----------------------------------------------------------------*/
   /* Local Variables                                                */
   /*----------------------------------------------------------------*/
   static bool is_first_time_bootup = FALSE;

	/*----------------------------------------------------------------*/
   /* Code Body                                                      */
   /*----------------------------------------------------------------*/
	

	bFlagNWSimulatorStart = TRUE;
	
	if (!is_first_time_bootup)
	{
		InitPCSimulatorBootup();
		is_first_time_bootup = TRUE;
	}
} /* end of AutomaticBoopup */
#endif


/*****************************************************************************
* FUNCTION
*  MyRegisterClass
* DESCRIPTION
*	Registers the window class.
*	This function and its usage is only necessary if you want this code
*	to be compatible with Win32 systems prior to the 'RegisterClassEx'
*	function that was added to Windows 95. It is important to call this function
*	so that the application will get 'well formed' small icons associated
*	with it.
*
* PARAMETERS
*  hInstance	IN		HINSTANCE
* RETURNS
*	ATOM
* GLOBALS AFFECTED
*	nil
*****************************************************************************/
ATOM MyRegisterClass(HINSTANCE hInstance)
{
	/*----------------------------------------------------------------*/
   /* Local Variables                                                */
   /*----------------------------------------------------------------*/
	WNDCLASSEX wcex;

	/*----------------------------------------------------------------*/
   /* Code Body                                                      */
   /*----------------------------------------------------------------*/
	wcex.cbSize = sizeof(WNDCLASSEX); 

	wcex.style				= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc		= (WNDPROC)WndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance			= hInstance;
	wcex.hIcon				= LoadIcon(hInstance, (LPCTSTR)IDI_L_MTK);
	wcex.hCursor			= LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW + 1);
	wcex.lpszMenuName		= /*(LPCSTR)*/MAKEINTRESOURCE(IDC_MTK_SIMULATOR);
	wcex.lpszClassName	= szWindowClass;
	wcex.hIconSm			= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_S_MTK/*IDI_SMALL*/);

	return RegisterClassEx(&wcex);
} /* end of MyRegisterClass */


/*****************************************************************************
* FUNCTION
*  InitInstance
* DESCRIPTION
*	Saves instance handle and creates main window. Load the default skin.
*	In this function, we save the instance handle in a global variable and
*	create and display the main program window.
*
* PARAMETERS
*  hInstance	IN		HINSTANCE
*  nCmdShow		IN		int
* RETURNS
*	BOOL
* GLOBALS AFFECTED
*	nil
*****************************************************************************/
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   /*----------------------------------------------------------------*/
   /* Local Variables                                                */
   /*----------------------------------------------------------------*/
	RECT	rcClient;
	char	buffer1[BUFFER_LENGTH], buffer2[BUFFER_LENGTH];

	/*----------------------------------------------------------------*/
   /* Code Body                                                      */
   /*----------------------------------------------------------------*/
	/* Store instance handle in our global variable */
	hInst = hInstance;

#ifndef __MMI_SUBLCD__
	hWnd = CreateWindow(	szWindowClass, szTitle, WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU,
								CW_USEDEFAULT, 0, 238/*simulator_skin_sub_LCD_x*/, 540, NULL, NULL, hInstance, NULL);
#else
	hWnd = CreateWindow(	szWindowClass, szTitle, WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU,
								CW_USEDEFAULT, 0, 238/*simulator_skin_sub_LCD_x*/+SUB_LCD_device_width+14, 540, NULL, NULL, hInstance, NULL);
#endif
   /* WindowHandle(hWnd); */
	/* gets rect pos for console window */ 
	GetClientRect(hWnd, &rcClient); 

	/* sets console window pos */ 
	SetWindowPos(hWnd, HWND_TOP, rcClient.left + 20, rcClient.top + 40, 0, 0, SWP_NOSIZE); 
   
	/* Remove the unwanted menu items. */
	if (hWnd != NULL)
	{
		HMENU menu = ::GetSystemMenu(hWnd, FALSE);
		if (menu != NULL)
		{
			::RemoveMenu(menu, SC_SIZE, MF_BYCOMMAND);	/* Size isn't supported for the same reason. */
		}
	}

	if (!hWnd)
	{
		return FALSE;
	}

	GetCurrentDirectory(BUFFER_LENGTH, cwd);

	/* check if the previous loaded skin exists, or load the default skin */
	GetPrivateProfileString("Log", "LAST_SKIN_NAME", NULL, buffer1, BUFFER_LENGTH, "../Skins/SkinStyleLog.ini");
	/* get currect working directory */
	GetCurrentDirectory(BUFFER_LENGTH, buffer2);
	/* no key value or the directory does not exist */
	if (strcmp(buffer1, "") == 0 || SetCurrentDirectory(buffer1) == 0)
	{
		/* restore to the current working directory */
		SetCurrentDirectory(buffer2);

		/* load the default skin */
		GetPrivateProfileString("Default", "DEFAULT_SKIN_PATH", NULL, buffer1, BUFFER_LENGTH, "../Skins/SkinStyleLog.ini");
		GetPrivateProfileString("Default", "DEFAULT_SKIN_STYLE", NULL, buffer2, BUFFER_LENGTH, "../Skins/SkinStyleLog.ini");
		sprintf(skin_name_buffer, "%s%s", buffer1, buffer2);
		
		/* write current skin style to the last used skin name */
		WritePrivateProfileString("Log", "LAST_SKIN_NAME", skin_name_buffer, "../Skins/SkinStyleLog.ini");
	}
	else
	{
		/* restore to the current working directory */
		SetCurrentDirectory(buffer2);

		/* Get the last used skin name */
		strcpy(skin_name_buffer, buffer1);
	}
	
	ResetKeyMemory();
	strcpy(old_skin_name_buffer, skin_name_buffer);
	ReadKeyProfile(skin_name_buffer, hWnd);
	
	lcd_screen_init(hWnd, 0);

	FeedBackFeelingKeyInit(hWnd, NULL, NULL/*(HBITMAP)hBitmap*/);

   ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);

	return TRUE;
} /* end of InitInstance */


/*****************************************************************************
* FUNCTION
*  WndProc
* DESCRIPTION
*	Processes messages for the main window.
*	WM_COMMAND	- process the application menu
*	WM_PAINT	- Paint the main window
*	WM_DESTROY	- post a quit message and return
*
* PARAMETERS
*  hWnd		IN		HWND
*  message	IN		UINT
*	wParam	IN		WPARAM
*	lParam	IN		LPARAM
* RETURNS
*	LRESULT CALLBACK
* GLOBALS AFFECTED
*	nil
*****************************************************************************/
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	/*----------------------------------------------------------------*/
   /* Local Variables                                                */
   /*----------------------------------------------------------------*/
	int				wmId, wmEvent;
	PAINTSTRUCT		ps;
	HDC				hdc;
	static MYQUEUE	Message;
	HINSTANCE		hInstance;
	static bool		flg;

	/*----------------------------------------------------------------*/
   /* Code Body                                                      */
   /*----------------------------------------------------------------*/
	switch (message) 
	{
		case WM_COMMAND:
			wmId    = LOWORD(wParam); 
			wmEvent = HIWORD(wParam); 
			/* Parse the menu selections: */
			switch (wmId)
			{
				case IDM_ABOUT:
				   DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
					break;
				case IDM_EXIT:
					{
						flg = true;
						if (flg == true)
						{
							flg = false;
							ShutdownSystemOperation();
							#ifndef __CUSTOMER_LEVEL_1_RELEASE__
								NWSimEngine.SendShutDownMsg();
							#endif
						}
				   	/* DestroyWindow(hWnd); */
					}
				   break;
/* MTK added by JL 040319 for level 1 auto bootup release */
//#if !defined(__CUSTOMER_LEVEL_1_RELEASE__)

/* Vincent: move this compile option to the body of launch_nw_simulator()
 *				for compatible with DLL_UI
 */
				case ID_FILE_NETWORKS:
					launch_nw_simulator();
					break;
//#endif	
				/* when the ser pressed the load skin menu item */
				case ID_LOAD_SKINS:
					GetCurrentDirectory(BUFFER_LENGTH, old_cwd);
					SetCurrentDirectory(cwd);
					hInstance = GetModuleHandle(NULL);
					LoadSkins(hInstance, hWnd);
					//SetCurrentDirectory(old_cwd);
					break;
				default:
				   return DefWindowProc(hWnd, message, wParam, lParam);
			}
			break; 
/* MTK added by JL 040319 for level 1 auto bootup release */
//#if defined(__CUSTOMER_LEVEL_1_RELEASE__)

/* Vincent: move this compile option to the body of automatic_power_on()
 *				for compatible with DLL_UI
 */
		case WM_SHOWWINDOW:
			automatic_power_on();
			break;
//#endif
		case WM_PAINT:
			hdc = BeginPaint(hWnd, &ps);
			SkinDisplay(hWnd);
			RefereshWindow(hWnd);
			EndPaint(hWnd, &ps);
			break;
		case WM_LBUTTONDOWN:
			keydown_by_mouse(hWnd, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
			break;
		case WM_LBUTTONUP:
			keyup_by_mouse(hWnd);
			break;

		case WM_MOUSEMOVE:
			mouse_move_enable(hWnd, GET_X_LPARAM(lParam), GET_X_LPARAM(lParam));
			break;

		case WM_KEYUP:
			keyup_by_shortcut(hWnd, wParam);
			break;
		case WM_KEYDOWN:
			keydown_by_shortcut(hWnd, (int)wParam);
			break;
		case WM_CLOSE:
			{
				flg = true;
				if (flg == true)
				{
					flg = false;
					ShutdownSystemOperation();
					#ifndef __CUSTOMER_LEVEL_1_RELEASE__
						NWSimEngine.SendShutDownMsg();
					#endif
				}
			}
			break;
		case MM_MCINOTIFY:
			break;
		case WM_TIMER:
			on_timer((unsigned int)wParam);
			break;
		case WM_DESTROY:
			PostQuitMessage(0);

		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
	}
   return 0;
} /* end of WndProc */


/*****************************************************************************
* FUNCTION
*  About
* DESCRIPTION
*   Mesage handler for about box.
*
* PARAMETERS
*  hWnd		IN		HWND
*  message	IN		UINT
*	wParam	IN		WPARAM
*	lParam	IN		LPARAM
* RETURNS
*	LRESULT CALLBACK
* GLOBALS AFFECTED
*	nil
*****************************************************************************/
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	/*----------------------------------------------------------------*/
   /* Local Variables                                                */
   /*----------------------------------------------------------------*/

	/*----------------------------------------------------------------*/
   /* Code Body                                                      */
   /*----------------------------------------------------------------*/
	switch (message)
	{
		case WM_INITDIALOG:
				return TRUE;

		case WM_COMMAND:
			if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
			{
				EndDialog(hDlg, LOWORD(wParam));
				return TRUE;
			}
			break;
	}
    return FALSE;
} /* end of About */





/*****************************************************************************
* FUNCTION
*	LoadSkins
* DESCRIPTION
*	Setup the dialog for loading skin
*
* PARAMETERS
*  hInstance	IN		HINSTANCE
*	hwnd			IN		HWND

⌨️ 快捷键说明

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