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

📄 winmain.cpp

📁 windows ce 下的3D桌面
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		{
			System_SetOverlay( false );
			ShowWindow( hWnd, SW_SHOW );
			SetForegroundWindow( hWnd );
			SetActiveWindow( hWnd );
			MESUI_DrawMenu();
			eglSwapBuffers( eglGetCurrentDisplay(), eglGetCurrentSurface(EGL_DRAW) );
		}
		break;
	}
	return MESUISTATE_MENU;
}

//-----------------------------------------------------------------------------
//	MESUISTATE_WAITAPP
//-----------------------------------------------------------------------------
MESUISTATE MessageProc_WAITAPP ( HWND , UINT Msg, WPARAM wParam, LPARAM  )
{
	switch( Msg )
	{	
	case LOCALEVENT_APPACTIVATE:
		MESUI_ChangeSceneFromWaitToApp( false );
		return MESUISTATE_APP;
	case WM_TIMER:
		if(1 == wParam)
		{
			MESUI_DrawWaitForAppActive();
			eglSwapBuffers( eglGetCurrentDisplay(), eglGetCurrentSurface(EGL_DRAW) );
		}
		break;
	}
	return MESUISTATE_WAITAPP;
}

//-----------------------------------------------------------------------------
//	MESUISTATE_APP
//-----------------------------------------------------------------------------
MESUISTATE MessageProc_APP ( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM  )
{
	switch( Msg )
	{	
	case SYSTEMEVENT_KEYDOWN_MENU:
		MESUI_ChangeSceneAppToMenu( false );
		SetTimer( hWnd, 1, ANIMATION_INTERVAL, NULL ); // run animation timer
		g_CurrentApp = -1;
		return MESUISTATE_MENU;
	case LOCALEVENT_APPEXIT:
		if( g_CurrentApp == (int)wParam )
		{
			MESUI_ChangeSceneAppToMenu( false );
			SetTimer( hWnd, 1, ANIMATION_INTERVAL, NULL ); // run animation timer
			g_CurrentApp = -1;
			return MESUISTATE_MENU;
		}
		break;
	case SYSTEMEVENT_USBISCONNECTED:
		MESUI_ChangeSceneFromAppToUSBStorage( false );
		//System_ConnectUSBStorage();
		SetTimer( hWnd, 1, ANIMATION_INTERVAL, NULL ); // run animation timer
		g_CurrentApp = -1;
		return MESUISTATE_USBSTORAGE;
	case SYSTEMEVENT_KEYDOWN_POWER:
		g_PowerDownQueryState = MESUISTATE_APP;
		MESUI_ChangeSceneToPowerDownQuery( false );
		SetTimer( hWnd, 1, ANIMATION_INTERVAL, NULL ); // run animation timer
		return MESUISTATE_POWERDOWNQUERY;
	case WM_TIMER:
		System_SetOverlay( true );
		glClearColor( 1,0,1,1);
		glClear( GL_COLOR_BUFFER_BIT );
		if( ! MESUI_DrawOSD() )
		{
			// It means the end of OSD animation that MESUI_DrawOSD() returns false.
			KillTimer( hWnd, 1 );
		}
		eglSwapBuffers( eglGetCurrentDisplay(), eglGetCurrentSurface(EGL_DRAW) );
		break;
	}
	return MESUISTATE_APP;
}

//-----------------------------------------------------------------------------
//	MESUISTATE_USBSTORAGE
//-----------------------------------------------------------------------------
MESUISTATE MessageProc_USBSTORAGE ( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM  )
{
	switch( Msg )
	{	
	case SYSTEMEVENT_USBISDISCONNECTED:
		MESUI_ChangeSceneFromUSBStorageToMenu();
		return MESUISTATE_MENU;
	case WM_TIMER:
		if(1 == wParam)
		{
			System_SetOverlay( false );
			ShowWindow( hWnd, SW_SHOW );
			SetForegroundWindow( hWnd );
			SetActiveWindow( hWnd );
			MESUI_DrawUSBStorage();
			eglSwapBuffers( eglGetCurrentDisplay(), eglGetCurrentSurface(EGL_DRAW) );
		}
		break;
	}
	return MESUISTATE_USBSTORAGE;
}

//-----------------------------------------------------------------------------
//	MESUISTATE_UNLOCKQUERY
//-----------------------------------------------------------------------------
MESUISTATE MessageProc_UNLOCKQUERY ( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM  )
{
	switch( Msg )
	{	
	case MESUIMSG_ONUNLOCK :
		MESUI_ChangeSceneFromUnlockQueryToMenu();
		return MESUISTATE_MENU;
	case WM_TIMER:
		if(1 == wParam)
		{
			System_SetOverlay( false );
			ShowWindow( hWnd, SW_SHOW );
			SetForegroundWindow( hWnd );
			SetActiveWindow( hWnd );
			MESUI_DrawUnlockQuery();
			eglSwapBuffers( eglGetCurrentDisplay(), eglGetCurrentSurface(EGL_DRAW) );
		}
		break;
	}
	return MESUISTATE_UNLOCKQUERY;
}

//-----------------------------------------------------------------------------
//	MESUISTATE_POWERDOWNQUERY
//-----------------------------------------------------------------------------
MESUISTATE MessageProc_POWERDOWNQUERY ( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM  )
{
	switch( Msg )
	{	
	case MESUIMSG_ONPOWERDOWNCANCEL:
		MESUI_ChangeSceneFromPowerDownQuery();
		ShowWindow( hWnd, SW_HIDE );
		return g_PowerDownQueryState;
	case WM_TIMER:
		if(1 == wParam)
		{
			System_SetOverlay( false );
			ShowWindow( hWnd, SW_SHOW );
			SetForegroundWindow( hWnd );
			SetActiveWindow( hWnd );
			MESUI_DrawPowerDownQuery();
			eglSwapBuffers( eglGetCurrentDisplay(), eglGetCurrentSurface(EGL_DRAW) );
		}
		break;
	}
	return MESUISTATE_POWERDOWNQUERY;
}


//-----------------------------------------------------------------------------
//	
//
//
//-----------------------------------------------------------------------------

bool InitOpenGLES ( HWND hWnd )
{
	EGLConfig configs[10];
	EGLint matchingConfigs;	

	/*configAttribs is a integers list that holds the desired format of 
	our framebuffer. We will ask for a framebuffer with 24 bits of 
	color and 16 bits of z-buffer. We also ask for a window buffer, not 
	a pbuffer or pixmap buffer*/	
	const EGLint configAttribs[] =
	{
		EGL_SURFACE_TYPE,   EGL_WINDOW_BIT,
		EGL_NONE,           EGL_NONE
	};

	g_hWnd= hWnd;
	g_hDC = GetWindowDC(hWnd);
	glesDisplay = eglGetDisplay(g_hDC);	 //Ask for an available display

	//Display initialization (we don't care about the OGLES version numbers)
	if(!eglInitialize(glesDisplay, NULL, NULL)) return false;

	/*Ask for the framebuffer confiburation that best fits our 
	parameters. At most, we want 10 configurations*/
	if(!eglChooseConfig(glesDisplay, configAttribs, &configs[0], 10,  &matchingConfigs)) return false;

	//If there isn't any configuration enough good
	if (matchingConfigs < 1)  return false;	  

	/*eglCreateWindowSurface creates an onscreen EGLSurface and returns 
	a handle  to it. Any EGL rendering context created with a 
	compatible EGLConfig can be used to render into this surface.*/
	glesSurface = eglCreateWindowSurface(glesDisplay, configs[0], hWnd, configAttribs);	
	if(!glesSurface) return false;

	// Let's create our rendering context
	glesContext=eglCreateContext(glesDisplay,configs[0],0,configAttribs);

	//if(!glesContext) return false;

	//Now we will activate the context for rendering	
	eglMakeCurrent(glesDisplay, glesSurface, glesSurface, glesContext); 

	return true;
}

void CloseOpenGLES( void )
{
	if(glesDisplay)
	{
		eglMakeCurrent(glesDisplay, NULL, NULL, NULL);  
		if(glesContext) eglDestroyContext(glesDisplay, glesContext);
		if(glesSurface) eglDestroySurface(glesDisplay, glesSurface);
		eglTerminate(glesDisplay);
	}  
}

void TaskBar_OnTop( BOOL bOnTop )
{
	LONG lRet;
	HKEY hkey;
	DWORD dw;
	WCHAR c_szShellOnTop[] = L"Software\\Microsoft\\Shell\\OnTop";

	lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, c_szShellOnTop,
						0, KEY_ALL_ACCESS, &hkey);
	if (lRet != ERROR_SUCCESS)
	{
		lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, c_szShellOnTop,
							  0, NULL, 0, KEY_ALL_ACCESS,
							  NULL, &hkey, &dw);
	}

	if (lRet == ERROR_SUCCESS)
	{
		RegSetValueEx(hkey, L"", 0, REG_DWORD, (LPBYTE)&bOnTop, sizeof(DWORD));
		RegCloseKey(hkey);
	}

	::SendMessage( ::FindWindow(L"HHTaskBar", NULL), WM_WININICHANGE, NULL, 5000 ); // Send OK? Post ?
}	

}; // namespace

⌨️ 快捷键说明

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