bool ApplicationWin32Imp::createWindow()
{
    if( isWindowCreated() ) return false;

    hInstance_ = ( HINSTANCE )GetModuleHandle( NULL );

    if( false == MyRegisterClass( hInstance_ ) )
        return false;

    const int x = getScreenX();
    const int y = getScreenY();
    const int width = getScreenWidth();
    const int height = getScreenHeight();
    hWnd_ = InitInstance( hInstance_, SW_SHOW, x, y, width, height );

    return NULL != hWnd_;
}
//----------------------------------------------------------------------------//
void AndroidAppHelper::handleCmd (struct android_app* app, int32_t cmd)
{
    switch (cmd)
    {
    case APP_CMD_SAVE_STATE:
        break;
    case APP_CMD_INIT_WINDOW:
        if (app->window != NULL)
        {
            if (!isWindowCreated())
            {
                CEGuiEGLBaseApplication::getSingleton().setNativeWindow(app->window);
#ifdef CEGUI_GLES3_SUPPORT
                CEGuiEGLBaseApplication::getSingleton().init (3);
#else
                CEGuiEGLBaseApplication::getSingleton().init (2);
#endif
                setWindowCreated (true);
            }
            else
            {
                CEGuiEGLBaseApplication::getSingleton().setNativeWindow(app->window);
                CEGuiEGLBaseApplication::getSingleton().resume ();
            }
        }
        break;
    case APP_CMD_TERM_WINDOW:
        CEGuiEGLBaseApplication::getSingleton().terminate();
        break;
    case APP_CMD_GAINED_FOCUS:
        CEGuiEGLBaseApplication::getSingleton().setNativeWindow(app->window);
        CEGuiEGLBaseApplication::getSingleton().resume ();
        break;
    case APP_CMD_LOST_FOCUS:
        CEGuiEGLBaseApplication::getSingleton().suspend();
        CEGuiEGLBaseApplication::getSingleton().clearFrame();
        break;
    }
}
void GSoftKeyManager::MarkForStatistics()
{
	if( !isWindowCreated() || m_pTestWindow == NULL)
		return; // no graphics available

	const int CiMaxKeys = 1 + GKeypadService::eKeyR4 - GKeypadService::eKeyL1;
	UINT  uQty = 0;
	UINT8 u8KeyFrecuency = 0;
	UINT8 aryu8KeyCodes[CiMaxKeys];

	memset(aryu8KeyCodes, 0, sizeof(aryu8KeyCodes));

	for(int i = GKeypadService::eKeyL1; i <= GKeypadService::eKeyR4; i++)
	{
		u8KeyFrecuency = GetKeyStatistics( UINT8(i) );
		if( u8KeyFrecuency == 0 || u8KeyFrecuency == 0xFF )
			continue;

		aryu8KeyCodes[uQty++] = UINT8(i);
	}

	m_pTestWindow->MarkForStatistics(uQty, aryu8KeyCodes, true, true);
}
ApplicationWin32Imp::~ApplicationWin32Imp() {
    if( isWindowCreated() )
        destroyWindow();
    g_app_ = NULL;
}