Esempio n. 1
0
void GAPI_VideoQuit(_THIS)
{
	writeDebugInfo("GAPI_VideoQuit");
	/* Destroy the window and everything associated with it */
	if ( SDL_Window ) 
	{
		/* Delete the screen bitmap (also frees screen->pixels) */
		if ( this->screen ) 
		{
#ifdef HAVE_OPENGL //maks
			if ( this->screen->flags & SDL_OPENGL ) 
			{
				WIN_GL_ShutDown(this);
			}
#endif

			if ( this->screen->flags & SDL_FULLSCREEN ) 
			{
				SHFullScreen(SDL_Window, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
				bShowTaskBar = 1;
			}


#ifndef NO_CHANGEDISPLAYSETTINGS
			if ( this->screen->flags & SDL_FULLSCREEN ) {
				ChangeDisplaySettings(NULL, 0);
				ShowWindow(SDL_Window, SW_HIDE);
			}
#endif


			
			this->screen->pixels = NULL;
		}
		
		GAPI_QuitGamma(this);
		GAPI_DestroyWindow(this);
		FlushMessageQueue();

		SDL_Window = NULL;

		CloseGAPI();		
	}

	if(gxHandle)
	{
		FreeLibrary(gxHandle);
		gxHandle = NULL;
	}	

	//Make sure restore task bar
	SHFullScreen(GetForegroundWindow(), SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
}
Esempio n. 2
0
ProgressWindow::ProgressWindow(ContainerWindow &parent)
{
  set(parent,
      InfoBoxLayout::landscape
      ? (LPCTSTR)IDD_PROGRESS_LANDSCAPE
      : (LPCTSTR)IDD_PROGRESS);

  TCHAR Temp[1024];
  _stprintf(Temp, _T("%s %s"), gettext(_T("Version")), XCSoar_Version);
  set_item_text(IDC_VERSION, Temp);

#ifdef WINDOWSPC
  RECT rc = parent.get_client_rect();
  RECT rcp = get_client_rect();

  move(rc.left, rc.top, rcp.right - rcp.left, rcp.bottom - rcp.top);
#else
#ifndef GNAV
  SHFullScreen(hWnd, SHFS_HIDETASKBAR|SHFS_HIDESIPBUTTON|SHFS_HIDESTARTICON);
#endif
#endif

  insert_after(HWND_TOP, true);

  set_range(0, 100);
  set_step(5);

#ifndef ENABLE_SDL
  ::SetForegroundWindow(hWnd);
#endif /* !ENABLE_SDL */
  update();
}
Esempio n. 3
0
void CMainFrame::OnViewFullscreen() 
{
	COsmo4 *app = GetApp();
	if (!app->m_open) return;
	u32 disp_w = app->m_screen_width;
	u32 disp_h = app->m_screen_height;
	
	Bool is_full_screen = !m_full_screen;

	/*prevent resize messages*/
	m_full_screen = 1;

	HWND hWnd = GetSafeHwnd();
	::SetForegroundWindow(hWnd);
	::CommandBar_Show(m_wndCommandBar.GetSafeHwnd(), is_full_screen ? FALSE : TRUE);
	SHFullScreen(hWnd, SHFS_HIDESTARTICON | SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON);

	if (is_full_screen) {
		m_dumbWnd.ShowWindow(SW_HIDE);

		::MoveWindow(m_hWnd, 0, 0, disp_w, disp_h, 0);
		m_wndView.GetWindowRect(&m_view_rc);
		m_wndView.SetWindowPos(this, 0, 0, disp_w, disp_h, SWP_NOZORDER);
		gf_term_set_option(app->m_term, GF_OPT_FULLSCREEN, is_full_screen);
		m_full_screen = 1;
	} else {
		gf_term_set_option(app->m_term, GF_OPT_FULLSCREEN, is_full_screen);
		m_full_screen = 0;
		OnSetSize(0,0);
		m_dumbWnd.ShowWindow(SW_SHOW);
		gf_term_set_option(app->m_term, GF_OPT_REFRESH, 0);
	}
}
void
nsSoftKeyBoardService::CloseSIP()
{
#ifdef WINCE

  HWND hWndSIP = FindWindow( _T( "SipWndClass" ), NULL );
  if (hWndSIP)
  {
    ShowWindow( hWndSIP, SW_HIDE );
  }

  hWndSIP = FindWindow( _T( "MS_SIPBUTTON" ), NULL );
  if (hWndSIP) 
  {
    ShowWindow( hWndSIP, SW_HIDE );
    SetWindowPos(hWndSIP, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  }

  SHSipPreference(NULL, SIP_DOWN);

  SHFullScreen(GetForegroundWindow(), SHFS_HIDESIPBUTTON);
#endif

  nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
  if (observerService)
    observerService->NotifyObservers(nsnull, "software-keyboard", NS_LITERAL_STRING("close").get());

}
Esempio n. 5
0
//***************************************************************************
// Function Name: InitWindow
//
// Purpose: Initializes dialog and soft key menus
//
BOOL InitWindow(const HWND hDlg, UINT nToolBarId)
{
        // Specify that the dialog box should stretch full screen
        SHINITDLGINFO shidi;
        ZeroMemory(&shidi, sizeof(shidi));
        shidi.dwMask = SHIDIM_FLAGS;
        shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN;
        shidi.hDlg = hDlg;

        // set up Soft Keys menu
        SHMENUBARINFO mbi;
        ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
        mbi.cbSize = sizeof(SHMENUBARINFO);
        mbi.hwndParent = hDlg;
        mbi.nToolBarId = nToolBarId;
        mbi.hInstRes = g_hInst;

        // If we could not initialize the dialog box, return an error
        if (FALSE == (SHInitDialog(&shidi) && SHCreateMenuBar(&mbi)))
        {
            return FALSE;
        }
		//SHDoneButton(hDlg, FALSE);
		SHFullScreen(hDlg, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);

        // set the title bar
        SetWindowText(hDlg, tszTitle);

        return TRUE;
}
Esempio n. 6
0
static void show_taskbar(Bool show_it)
{
#ifdef _WIN32_WCE
	HWND wnd;
	if (!is_ppc) return;

	wnd = GetForegroundWindow();
	wnd = g_hwnd;
	if (show_it) {
		SHFullScreen(wnd, SHFS_SHOWSTARTICON | SHFS_SHOWTASKBAR| SHFS_SHOWSIPBUTTON);
		::ShowWindow(::FindWindow(_T("HHTaskbar"),NULL), SW_SHOWNA);
	} else {
		::ShowWindow(::FindWindow(_T("HHTaskbar"),NULL), SW_HIDE);
		SHFullScreen(wnd, SHFS_HIDESTARTICON | SHFS_HIDETASKBAR| SHFS_HIDESIPBUTTON);
	}
#endif
}
Esempio n. 7
0
/**
\brief
	Método para execução pós inicialização
\details
	Funções executadas neste método:
	- Pintar o fundo da tela cliente
	- Reposicionar o dialog, para incluir o SIP
	- Enviar a mensagem a janela pai que a tela acabou de carregar

\param
	void
\return
	void
*/
void CUIDialog::PostInitDialog()
{
	CRect rectB;
	GetClientRect(&rectB);
#ifdef _WIN32_WCE
	if(m_banner.GetSafeHwnd() != NULL && IsWindow(m_banner.GetSafeHwnd()))
		m_banner.GetClientRect(&rectB);
#endif

	if(m_panel.GetSafeHwnd() == NULL)
	{
		VERIFY(m_panel.Create(this, 
					   CRect(0, 
					   rectB.Height(), 
					   rectB.Width() - SCROLL_WIDTH, 
					   rectB.Height() + PANEL_HEIGHT), 
					   (UINT)-1));

		m_panel.SetBkColor(RGB(255, 255, 255));
	}

	// Reposiciona o dialog, pois o SIP esta visivel...
	if(m_bKeepSIPUp)
	{
		CRect rectCli;
		GetWindowRect(&rectCli);

		// Descontar o SIP e o CommandBar...
		rectCli.bottom -= 80 + 26;
		SetWindowPos(NULL, 
					 0, 
					 0, 
					 rectCli.Width(), 
					 rectCli.Height(), 
					 SWP_NOMOVE|SWP_NOZORDER);
	}

	SetTimer(1, 10, NULL);

#ifdef _WIN32_WCE
	/*** Deprecated: Banner antigo ***/ 
	//m_banner.ShowWindow(SW_SHOW);
#endif

	// Avisar o pai que a inicializacao encerrou...
	// Encerra o Wait cursor...
	if(GetParent() != NULL)
		GetParent()->PostMessage(CModParam::WM_MODULE_READY, 0, (LPARAM) GetSafeHwnd());

	SetForegroundWindow();  
	// Resize the window over the taskbar area.
	CRect rect;
	rect = CRect(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
	MoveWindow(&rect, TRUE);
#ifdef _WIN32_WCE
	SHFullScreen(m_hWnd, SHFS_HIDESTARTICON|SHFS_HIDETASKBAR|SHFS_SHOWSIPBUTTON);
#endif
}
Esempio n. 8
0
void DIB_VideoQuit(_THIS)
{
	/* Destroy the window and everything associated with it */
	if ( SDL_Window ) {
		/* Delete the screen bitmap (also frees screen->pixels) */
		if ( this->screen ) {
#ifdef WIN32_PLATFORM_PSPC
			if ( this->screen->flags & SDL_FULLSCREEN ) {
				/* Unhide taskbar, etc. */
				SHFullScreen(SDL_Window, SHFS_SHOWTASKBAR);
				SHFullScreen(SDL_Window, SHFS_SHOWSIPBUTTON);
				ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_SHOWNORMAL);
			}
#endif
#ifndef NO_CHANGEDISPLAYSETTINGS
			if ( this->screen->flags & SDL_FULLSCREEN ) {
				ChangeDisplaySettings(NULL, 0);
				ShowWindow(SDL_Window, SW_HIDE);
			}
#endif
#ifdef HAVE_OPENGL //maks
			if ( this->screen->flags & SDL_OPENGL ) {
				WIN_GL_ShutDown(this);
			}
#endif
			this->screen->pixels = NULL;
		}
		if ( screen_bmp ) {
			DeleteObject(screen_bmp);
			screen_bmp = NULL;
		}
		if ( screen_icn ) {
			DestroyIcon(screen_icn);
			screen_icn = NULL;
		}
		DIB_QuitGamma(this);
		DIB_DestroyWindow(this);
		FlushMessageQueue();

		SDL_Window = NULL;
	}
}
Esempio n. 9
0
void CUIDialog::OnDelayedEvent( int nEventId )
{
	if ( nEventId == DelayEvent_HideSipButton )
	{
		DWORD dwFlag = SHFS_HIDESIPBUTTON;
		BOOL bResult = SHFullScreen( this->GetSafeHwnd(), dwFlag );   
		if ( !bResult )
		{
			Log() << _T( "SHFullScreen Fail!" ) << endl;
		}
//		_ASSERT( bResult );
	}
}
Esempio n. 10
0
/***********************************************************************

FUNCTION: 
  WndProc

PURPOSE: 
  Processes messages sent to the main window.
  
***********************************************************************/
LRESULT FileInfo::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
    SHINITDLGINFO shidi;

    switch( msg )
    {
    case WM_INITDIALOG: 
        shidi.dwMask = SHIDIM_FLAGS;
        shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
            SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
        shidi.hDlg = hwnd;
        SHInitDialog( &shidi );
        CreateTreeView( hwnd );
        UpdateWindow( hwnd );
        SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
        break;

    case WM_CLOSE:
        EndDialog( hwnd, LOWORD( wp ) );
        break;

    case WM_SETFOCUS:
        SHSipPreference( hwnd, SIP_DOWN ); 
        SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
        break;

    case WM_COMMAND:
        if ( LOWORD(wp) == IDOK )
        {
            EndDialog( hwnd, LOWORD( wp ) );
        }
        break;

    default:
        break;
    }

    return FALSE;
}
Esempio n. 11
0
bool ShowFilePropertiesDialog ( FileList_t & tList )
{
	if ( g_tConfig.fullscreen )
		SHFullScreen ( g_hMainWindow, SHFS_SHOWTASKBAR );

	if ( tList.OneFile () && IsStorageCard ( tList.m_dFiles [0]->m_tData.cFileName ) )
		ShowCardDlg ( tList );
	else
	{
		bool bLnk = tList.OneFile () && Str_c ( tList.m_dFiles [0]->m_tData.cFileName ).Ends ( L".lnk" );
		ShowCommonFilesDlg ( tList, bLnk );
	}

	return false;
}
//! destructor
CIrrDeviceWinCE::~CIrrDeviceWinCE()
{
	// unregister environment

	if (ChangedToFullScreen)
		SHFullScreen(HWnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);

	irr::core::list<SEnvMapper>::Iterator it = EnvMap.begin();
	for (; it!= EnvMap.end(); ++it)
		if ((*it).hWnd == HWnd)
		{
			EnvMap.erase(it);
			break;
		}
}
Esempio n. 13
0
/* Exported for the windows message loop only */
static void GAPI_WinPAINT(_THIS, HDC hdc)
{
	if(bShowTaskBar)
	{
		//Blank

		/*RECT rect;
		HBRUSH brush;

		rect.left = 0;
		rect.top = 0;
		rect.right = sdlWindowSize.right;
		rect.bottom = sdlWindowSize.bottom - (26 + 24);

		brush = CreateSolidBrush(RGB(255, 255, 255));
		FillRect(hdc, &rect, brush);
		DeleteObject(brush);*/
		
		//Bitmap
		if(srcBitmap)
		{
			int topBorder, bottomBorder;
			HDC mdc = CreateCompatibleDC(hdc);			
			
			SelectObject(mdc, srcBitmap);

			GetTopBottomBorder(&topBorder, &bottomBorder);

			BitBlt(hdc, 0, 0, sdlWindowSize.right, sdlWindowSize.bottom - (topBorder + bottomBorder), mdc, 0, topBorder, SRCCOPY);

			DeleteDC(mdc);
		}

		//Refresh navigation bar
		SHFullScreen(SDL_Window, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
		SDL_WM_SetCaption(GetGameTitle(), NULL);		
	}
	/*else if(backBufer)
	{
		videoBuffer = GXBeginDraw();

		memcpy(videoBuffer + this->hidden->m_nBufferStartOffset, backBufer, 
			(this->hidden->m_nBufferEndOffset - this->hidden->m_nBufferStartOffset + 1) * 2);

		GXEndDraw();
	}*/
}
Esempio n. 14
0
static BOOL
CE_SHFullScreen(HWND hwndRequester, DWORD dwState)
{
    if (SHFullScreen == 0 && aygshell_loaded == 0) {
        aygshell_loaded = 0;
        void *lib = SDL_LoadObject("aygshell.dll");
        if (lib) {
            SHFullScreen =
                (BOOL(WINAPI *) (HWND, DWORD)) SDL_LoadFunction(lib,
                                                                "SHFullScreen");
        }
    }

    if (SHFullScreen) {
        SHFullScreen(hwndRequester, dwState);
        //printf("SHFullscreen(%i)\n",dwState);
    }
}
Esempio n. 15
0
LRESULT CUIDialog::OnFullScreenCmd( WPARAM, LPARAM )
{
	DWORD dwFlag = 0;
	if ( this->HasCmd( FS_HideSipButton ) )
	{
		dwFlag |= SHFS_HIDESIPBUTTON;

		// 隐藏输入法按钮需要延时调用。
		this->CreateDelayedEvent( DelayEvent_HideSipButton, 10 );

	}
	else if( this->HasCmd( FS_ShowSipButton ) )
	{
		dwFlag |= SHFS_SHOWSIPBUTTON;
	}

	if ( this->HasCmd( FS_HideTaskBar ) )
	{
		dwFlag |= SHFS_HIDETASKBAR | SHFS_HIDESTARTICON;		
	}
	else if( this->HasCmd( FS_ShowTaskBar ) )
	{
		dwFlag |= SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON;
	}
	if ( dwFlag )
	{
		BOOL bResult = SHFullScreen( this->GetSafeHwnd(), dwFlag );   
		if ( !bResult )
		{
			Log() << _T( "SHFullScreen Fail!" ) << endl; 
		}
		//_ASSERT( bResult );
	}

	// 遍历窗口,干掉下面一条.
	::EnumWindows( WindowsEnumCBForFulscreenS, (LPARAM)GetSafeHwnd() );
	
	


	return S_OK;
}
Esempio n. 16
0
bool wxToolBoxMinimalTestApp::OnInit()
{
    wxImage::AddHandler(new wxPNGHandler());
	wxImage::AddHandler(new wxXPMHandler());
	wxImage::AddHandler(new wxJPEGHandler());
	wxToolBoxMinimalTestFrame * frame = new wxToolBoxMinimalTestFrame;
	SetTopWindow(frame);
	frame->Centre();
#if defined(__WXMSW__)
	frame->ShowFullScreen(true);
#else
    frame->Show();
#endif
	wxYield();
	frame->CreateToolBox();
#if defined(__WXWINCE__)
	SHFullScreen((HWND)frame->GetHWND(), SHFS_HIDESIPBUTTON|SHFS_HIDETASKBAR|SHFS_HIDESTARTICON);
#endif
	return true;
}
Esempio n. 17
0
void do_layout(Bool notif_size)
{
	u32 w, h;
	if (full_screen) {
		w = screen_w;
		h = screen_h;
		::ShowWindow(g_hwnd_status, SW_HIDE);
#ifdef _WIN32_WCE
		::ShowWindow(g_hwnd_menu, SW_HIDE);
#endif

#ifdef _WIN32_WCE
		SHFullScreen(g_hwnd, SHFS_HIDESIPBUTTON);
#endif
		::MoveWindow(g_hwnd, 0, 0, screen_w, screen_h, 1);
		::MoveWindow(g_hwnd_disp, 0, 0, screen_w, screen_h, 1);
		SetForegroundWindow(g_hwnd_disp);
	} else {
#ifdef _WIN32_WCE
		::ShowWindow(g_hwnd_menu, SW_SHOW);
#endif
		if (show_status) {
			::MoveWindow(g_hwnd, 0, 0, disp_w, disp_h, 1);
			::ShowWindow(g_hwnd_status, SW_SHOW);
			::MoveWindow(g_hwnd_status, 0, 0, disp_w, caption_h, 1);
			::MoveWindow(g_hwnd_disp, 0, caption_h, disp_w, disp_h - caption_h, 1);
			w = disp_w;
			h = disp_h - caption_h*ratio_h;
		} else {
			::ShowWindow(g_hwnd_status, SW_HIDE);
//			::MoveWindow(g_hwnd, 0, caption_h, disp_w, disp_h, 1);
			::MoveWindow(g_hwnd, 0, 0, disp_w, disp_h, 1);
			::MoveWindow(g_hwnd_disp, 0, 0, disp_w, disp_h, 1);
			w = disp_w;
			h = disp_h;
		}
	}
	if (notif_size && term) gf_term_set_size(term, w, h);
}
Esempio n. 18
0
pxError pxWindow::init(int left, int top, int width, int height)
{
    HINSTANCE hInstance = ::GetModuleHandle(NULL);

    TCHAR* className = _T("pxWindow");
    WNDCLASS wc;
    if (!::GetClassInfo(hInstance, className, &wc))
    {

	wc.style         = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc   = (WNDPROC)windowProc;
	wc.cbClsExtra    = 0;
	wc.cbWndExtra    = 0;
	wc.hInstance     = hInstance;
	wc.hIcon         = NULL;
	wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
	wc.lpszMenuName  = 0;
	wc.lpszClassName = className;

	RegisterClass(&wc);
    }

#ifndef MOBILE
    mWindow = ::CreateWindow(className, _T(""), WS_OVERLAPPEDWINDOW, left, top, width, height, NULL, NULL, 
        hInstance, (pxWindowNative*)this);
#else
    mWindow = CreateWindow(className, L"Hi", WS_VISIBLE,
        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, (pxWindowNative*)this);

    if (mWindow)
    {
        SHDoneButton (mWindow, SHDB_SHOW);
        SHFullScreen(mWindow, SHFS_HIDESIPBUTTON);
    }
#endif
    return mWindow?PX_OK:PX_FAIL;
}
Esempio n. 19
0
int GAPI_HideTaskBar()
{
	//Free the backbuffer used when call GAPI_ShowTaskBar
	freeBackBufer();

	if(bShowTaskBar)
	{
		//ShowWindow(SDL_Window, SW_SHOW); 
		SHFullScreen(SDL_Window, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
		bShowTaskBar = 0;
		
		SetWindowPos(SDL_Window, HWND_TOPMOST, sdlWindowSize.left, sdlWindowSize.top, sdlWindowSize.right, sdlWindowSize.bottom, SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_SHOWWINDOW);
		OpenGAPI(-1);

		//Go to the game, monitor task bar
		HookTaskBar();
		
		//SetWindowLong(SDL_Window, GWL_STYLE, GetWindowLong(SDL_Window, GWL_STYLE) | ~WS_EX_CAPTIONOKBTN);


		if(menuBar) 
		{
			CommandBar_Destroy((HWND)menuBar);
			menuBar = NULL;
		}

		if(srcBitmap)
		{
			DeleteObject(srcBitmap);
			srcBitmap = NULL;
		}

		return 1;
	}

	return 0;
}
Esempio n. 20
0
/*****************************************************************************
 * DirectXEventProc: This is the window event processing function.
 *****************************************************************************
 * On Windows, when you create a window you have to attach an event processing
 * function to it. The aim of this function is to manage "Queued Messages" and
 * "Nonqueued Messages".
 * Queued Messages are those picked up and retransmitted by vout_Manage
 * (using the GetMessage and DispatchMessage functions).
 * Nonqueued Messages are those that Windows will send directly to this
 * procedure (like WM_DESTROY, WM_WINDOWPOSCHANGED...)
 *****************************************************************************/
static long FAR PASCAL DirectXEventProc( HWND hwnd, UINT message,
                                         WPARAM wParam, LPARAM lParam )
{
    event_thread_t *p_event;

    if( message == WM_CREATE )
    {
        /* Store vd for future use */
        p_event = (event_thread_t *)((CREATESTRUCT *)lParam)->lpCreateParams;
        SetWindowLongPtr( hwnd, GWLP_USERDATA, (LONG_PTR)p_event );
        return TRUE;
    }
    else
    {
        LONG_PTR p_user_data = GetWindowLongPtr( hwnd, GWLP_USERDATA );
        p_event = (event_thread_t *)p_user_data;
        if( !p_event )
        {
            /* Hmmm mozilla does manage somehow to save the pointer to our
             * windowproc and still calls it after the vout has been closed. */
            return DefWindowProc(hwnd, message, wParam, lParam);
        }
    }
    vout_display_t *vd = p_event->vd;

#ifndef UNDER_CE
    /* Catch the screensaver and the monitor turn-off */
    if( message == WM_SYSCOMMAND &&
        ( (wParam & 0xFFF0) == SC_SCREENSAVE || (wParam & 0xFFF0) == SC_MONITORPOWER ) )
    {
        //if( vd ) msg_Dbg( vd, "WinProc WM_SYSCOMMAND screensaver" );
        return 0; /* this stops them from happening */
    }
#endif
#if 0
    if( message == WM_SETCURSOR )
    {
        msg_Err(vd, "WM_SETCURSOR: %d (t2)", p_event->is_cursor_hidden);
        SetCursor( p_event->is_cursor_hidden ? p_event->cursor_empty : p_event->cursor_arrow );
        return 1;
    }
#endif
    if( message == WM_CAPTURECHANGED )
    {
        for( int button = 0; p_event->button_pressed; button++ )
        {
            unsigned m = 1 << button;
            if( p_event->button_pressed & m )
                vout_display_SendEventMouseReleased( p_event->vd, button );
            p_event->button_pressed &= ~m;
        }
        p_event->button_pressed = 0;
        return 0;
    }

    if( hwnd == p_event->hvideownd )
    {
#ifdef MODULE_NAME_IS_directx
        vlc_mutex_lock( &p_event->lock );
        const bool use_overlay = p_event->use_overlay;
        vlc_mutex_unlock( &p_event->lock );
#endif

        switch( message )
        {
#ifdef MODULE_NAME_IS_directx
        case WM_ERASEBKGND:
        /* For overlay, we need to erase background */
            return !use_overlay ? 1 : DefWindowProc(hwnd, message, wParam, lParam);
        case WM_PAINT:
        /*
        ** For overlay, DefWindowProc() will erase dirty regions
        ** with colorkey.
        ** For non-overlay, vout will paint the whole window at
        ** regular interval, therefore dirty regions can be ignored
        ** to minimize repaint.
        */
            if( !use_overlay )
            {
                ValidateRect(hwnd, NULL);
            }
            // fall through to default
#else
        /*
        ** For OpenGL and Direct3D, vout will update the whole
        ** window at regular interval, therefore dirty region
        ** can be ignored to minimize repaint.
        */
        case WM_ERASEBKGND:
            /* nothing to erase */
            return 1;
        case WM_PAINT:
            /* nothing to repaint */
            ValidateRect(hwnd, NULL);
            // fall through
#endif
        default:
            return DefWindowProc(hwnd, message, wParam, lParam);
        }
    }

    switch( message )
    {

    case WM_WINDOWPOSCHANGED:
        vlc_mutex_lock( &p_event->lock );
        p_event->has_moved = true;
        vlc_mutex_unlock( &p_event->lock );
        return 0;

    /* the user wants to close the window */
    case WM_CLOSE:
        vout_display_SendEventClose(vd);
        return 0;

    /* the window has been closed so shut down everything now */
    case WM_DESTROY:
        msg_Dbg( vd, "WinProc WM_DESTROY" );
        /* just destroy the window */
        PostQuitMessage( 0 );
        return 0;

    case WM_SYSCOMMAND:
        switch (wParam)
        {
        case IDM_TOGGLE_ON_TOP:            /* toggle the "on top" status */
        {
            msg_Dbg(vd, "WinProc WM_SYSCOMMAND: IDM_TOGGLE_ON_TOP");
            HMENU hMenu = GetSystemMenu(vd->sys->hwnd, FALSE);
            vout_display_SendWindowState(vd, (GetMenuState(hMenu, IDM_TOGGLE_ON_TOP, MF_BYCOMMAND) & MF_CHECKED) ?
                    VOUT_WINDOW_STATE_NORMAL : VOUT_WINDOW_STATE_ABOVE);
            return 0;
        }
        default:
            break;
        }
        break;

    case WM_PAINT:
    case WM_NCPAINT:
    case WM_ERASEBKGND:
        return DefWindowProc(hwnd, message, wParam, lParam);

    case WM_KILLFOCUS:
#ifdef MODULE_NAME_IS_wingapi
        GXSuspend();
#endif
#ifdef UNDER_CE
        if( hwnd == p_event->hfswnd )
        {
            HWND htbar = FindWindow( _T("HHTaskbar"), NULL );
            ShowWindow( htbar, SW_SHOW );
        }

        if( !p_event->hparent ||
            hwnd == p_event->hfswnd )
        {
            SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
        }
#endif
        return 0;

    case WM_SETFOCUS:
#ifdef MODULE_NAME_IS_wingapi
        GXResume();
#endif
#ifdef UNDER_CE
        /* FIXME vd->cfg is not lock[ed/able] */
#warning "FIXME: race condition"
        if( p_event->hparent &&
            hwnd != p_event->hfswnd && vd->cfg->is_fullscreen )
            vout_display_SendEventFullscreen(vd, false);

        if( hwnd == p_event->hfswnd )
        {
            HWND htbar = FindWindow( _T("HHTaskbar"), NULL );
            ShowWindow( htbar, SW_HIDE );
        }

        if( !p_event->hparent ||
            hwnd == p_event->hfswnd )
        {
            SHFullScreen( hwnd, SHFS_HIDESIPBUTTON );
        }
#endif
        return 0;

    default:
        //msg_Dbg( vd, "WinProc WM Default %i", message );
        break;
    }

    /* Let windows handle the message */
    return DefWindowProc(hwnd, message, wParam, lParam);
}
Esempio n. 21
0
/*
//  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
//  PURPOSE:  Processes messages for the main window.
*/
LRESULT CALLBACK
MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    PNHMainWindow data;

    switch (message) {
    /*-----------------------------------------------------------------------*/
    case WM_CREATE: {
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
        SHMENUBARINFO menubar;
#endif
        /* set window data */
        data = (PNHMainWindow) malloc(sizeof(NHMainWindow));
        if (!data)
            panic("out of memory");
        ZeroMemory(data, sizeof(NHMainWindow));
        data->mapAcsiiModeSave = MAP_MODE_ASCII12x16;
        SetWindowLong(hWnd, GWL_USERDATA, (LONG) data);

        GetNHApp()->hMainWnd = hWnd;

/* create menu bar */
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
        ZeroMemory(&menubar, sizeof(menubar));
        menubar.cbSize = sizeof(menubar);
        menubar.hwndParent = hWnd;
        menubar.dwFlags = 0;
        menubar.nToolBarId = IDC_WINHACK;
        menubar.hInstRes = GetNHApp()->hApp;
#if defined(WIN_CE_POCKETPC)
        menubar.nBmpId = IDB_MENUBAR;
        menubar.cBmpImages = 2;
#else
        menubar.nBmpId = 0;
        menubar.cBmpImages = 0;
#endif
        if (!SHCreateMenuBar(&menubar))
            panic("cannot create menu");
        GetNHApp()->hMenuBar = menubar.hwndMB;
#else
        GetNHApp()->hMenuBar = CommandBar_Create(GetNHApp()->hApp, hWnd, 1);
        if (!GetNHApp()->hMenuBar)
            panic("cannot create menu");
        CommandBar_InsertMenubar(GetNHApp()->hMenuBar, GetNHApp()->hApp,
                                 IDC_WINHACK, 0);
#endif
        CheckMenuItem(
            _get_main_menu(ID_VIEW), IDM_VIEW_KEYPAD,
            MF_BYCOMMAND | (GetNHApp()->bCmdPad ? MF_CHECKED : MF_UNCHECKED));

    } break;

    /*-----------------------------------------------------------------------*/

    case WM_MSNH_COMMAND:
        onMSNHCommand(hWnd, wParam, lParam);
        break;

    /*-----------------------------------------------------------------------*/

    case WM_KEYDOWN:
        data = (PNHMainWindow) GetWindowLong(hWnd, GWL_USERDATA);

        /* translate arrow keys into nethack commands */
        switch (wParam) {
        case VK_LEFT:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one line left */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_HSCROLL,
                            MAKEWPARAM(SB_LINEUP, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_W));
            }
            return 0;

        case VK_RIGHT:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one line right */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_HSCROLL,
                            MAKEWPARAM(SB_LINEDOWN, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_E));
            }
            return 0;

        case VK_UP:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one line up */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_LINEUP, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_N));
            }
            return 0;

        case VK_DOWN:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one line down */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_LINEDOWN, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_S));
            }
            return 0;

        case VK_HOME:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window to upper left corner */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_THUMBTRACK, 0), (LPARAM) NULL);

                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_HSCROLL,
                            MAKEWPARAM(SB_THUMBTRACK, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_NW));
            }
            return 0;

        case VK_END:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window to lower right corner */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_THUMBTRACK, ROWNO), (LPARAM) NULL);

                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_HSCROLL,
                            MAKEWPARAM(SB_THUMBTRACK, COLNO), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_SW));
            }
            return 0;

        case VK_PRIOR:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one page up */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_PAGEUP, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_NE));
            }
            return 0;

        case VK_NEXT:
            if (STATEON(VK_CONTROL)) {
                /* scroll map window one page down */
                SendMessage(mswin_hwnd_from_winid(WIN_MAP), WM_VSCROLL,
                            MAKEWPARAM(SB_PAGEDOWN, 0), (LPARAM) NULL);
            } else {
                NHEVENT_KBD(KEYTABLE(KEY_SE));
            }
            return 0;

        case VK_DECIMAL:
        case VK_DELETE:
            NHEVENT_KBD(KEYTABLE(KEY_WAITLOOK));
            return 0;

        case VK_INSERT:
            NHEVENT_KBD(KEYTABLE(KEY_INV));
            return 0;

        case VK_SUBTRACT:
            NHEVENT_KBD(KEYTABLE(KEY_MINUS));
            return 0;

        case VK_ADD:
            NHEVENT_KBD(KEYTABLE(KEY_PLUS));
            return 0;

        case VK_CLEAR: /* This is the '5' key */
            NHEVENT_KBD(KEYTABLE(KEY_GOINTERESTING));
            return 0;

        case VK_F4:
            if (IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode)) {
                mswin_select_map_mode(IS_MAP_ASCII(iflags.wc_map_mode)
                                          ? data->mapAcsiiModeSave
                                          : MAP_MODE_TILES);
            } else {
                mswin_select_map_mode(IS_MAP_ASCII(iflags.wc_map_mode)
                                          ? MAP_MODE_ASCII_FIT_TO_SCREEN
                                          : MAP_MODE_TILES_FIT_TO_SCREEN);
            }
            return 0;

        case VK_F5:
            if (IS_MAP_ASCII(iflags.wc_map_mode)) {
                if (IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode)) {
                    mswin_select_map_mode(MAP_MODE_TILES_FIT_TO_SCREEN);
                } else {
                    mswin_select_map_mode(MAP_MODE_TILES);
                }
            } else {
                if (IS_MAP_FIT_TO_SCREEN(iflags.wc_map_mode)) {
                    mswin_select_map_mode(MAP_MODE_ASCII_FIT_TO_SCREEN);
                } else {
                    mswin_select_map_mode(data->mapAcsiiModeSave);
                }
            }
            return 0;

        case VK_RETURN: {
            int x, y;
            if (WIN_MAP != WIN_ERR) {
                mswin_map_get_cursor(mswin_hwnd_from_winid(WIN_MAP), &x, &y);
            } else {
                x = u.ux;
                y = u.uy;
            }
            NHEVENT_MS(CLICK_1, x, y);
        }
            return 0;
        }

#if defined(WIN_CE_SMARTPHONE)
        if (GetNHApp()->bCmdPad
            && NHSPhoneTranslateKbdMessage(wParam, lParam, TRUE))
            return 0;
#endif
        return 1; /* end of WM_KEYDOWN */

/*-----------------------------------------------------------------------*/

#if defined(WIN_CE_SMARTPHONE)
    case WM_KEYUP:
        if (GetNHApp()->bCmdPad
            && NHSPhoneTranslateKbdMessage(wParam, lParam, FALSE))
            return 0;
        return 1; /* end of WM_KEYUP */
#endif
    /*-----------------------------------------------------------------------*/

    case WM_CHAR:
#if defined(WIN_CE_SMARTPHONE)
        /* if smartphone cmdpad is up then translation happens - disable
           WM_CHAR processing
           to avoid double input */
        if (GetNHApp()->bCmdPad) {
            return 1;
        }
#endif

        if (wParam == '\n' || wParam == '\r' || wParam == C('M'))
            return 0; /* we already processed VK_RETURN */

        /* all characters go to nethack except Ctrl-P that scrolls message
         * window up */
        if (wParam == C('P') || wParam == C('p')) {
            SendMessage(mswin_hwnd_from_winid(WIN_MESSAGE), WM_VSCROLL,
                        MAKEWPARAM(SB_LINEUP, 0), (LPARAM) NULL);
        } else {
            NHEVENT_KBD((lParam & 1 << 29) ? M(tolower(wParam)) : wParam);
        }
        return 0;

    /*-----------------------------------------------------------------------*/

    case WM_COMMAND:
        /* process commands - menu commands mostly */
        if (IsWindow(GetNHApp()->hPopupWnd)) {
            return SendMessage(GetNHApp()->hPopupWnd, message, wParam,
                               lParam);
        } else if (onWMCommand(hWnd, wParam, lParam))
            return DefWindowProc(hWnd, message, wParam, lParam);
        else
            return 0;

    /*-----------------------------------------------------------------------*/

    case WM_ACTIVATE:
        if (LOWORD(wParam) != WA_INACTIVE) {
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
            if (GetNHApp()->bFullScreen)
                SHFullScreen(GetNHApp()->hMainWnd,
                             SHFS_HIDETASKBAR | SHFS_HIDESTARTICON);
            else
                SHFullScreen(GetNHApp()->hMainWnd,
                             SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON);
#endif
            mswin_layout_main_window(NULL);
        }
        break;

    case WM_SETTINGCHANGE:
#if defined(WIN_CE_POCKETPC) || defined(WIN_CE_SMARTPHONE)
        if (GetNHApp()->bFullScreen)
            SHFullScreen(GetNHApp()->hMainWnd,
                         SHFS_HIDETASKBAR | SHFS_HIDESTARTICON);
        else
            SHFullScreen(GetNHApp()->hMainWnd,
                         SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON);
#endif
        mswin_layout_main_window(NULL);
        break;

    case WM_SIZE:
        mswin_layout_main_window(NULL);
        break;

    /*-----------------------------------------------------------------------*/

    case WM_SETFOCUS:
        /* if there is a menu window out there -
           transfer input focus to it */
        if (IsWindow(GetNHApp()->hPopupWnd)) {
            SetFocus(GetNHApp()->hPopupWnd);
        }
        break;

    /*-----------------------------------------------------------------------*/

    case WM_CLOSE: {
/* exit gracefully */
#ifdef SAFERHANGUP
        /* destroy popup window - it has its own loop and we need to
           return control to NetHack core at this point */
        if (IsWindow(GetNHApp()->hPopupWnd))
            SendMessage(GetNHApp()->hPopupWnd, WM_COMMAND, IDCANCEL, 0);

        /* tell NetHack core that "hangup" is requested */
        hangup(1);
#else
        dosave0();
        terminate(EXIT_SUCCESS);
#endif
    }
        return 0;

    /*-----------------------------------------------------------------------*/

    case WM_DESTROY: {
        /* apparently we never get here
           TODO: work on exit routines - need to send
           WM_QUIT somehow */

        /* clean up */
        free((PNHMainWindow) GetWindowLong(hWnd, GWL_USERDATA));
        SetWindowLong(hWnd, GWL_USERDATA, (LONG) 0);

        terminate(EXIT_SUCCESS);
    } break;

    /*-----------------------------------------------------------------------*/

    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
//! switches to fullscreen
bool CIrrDeviceWinCE::switchToFullScreen()
{
	ChangedToFullScreen = SHFullScreen(HWnd, SHFS_HIDESIPBUTTON | SHFS_HIDETASKBAR) != 0;
	return ChangedToFullScreen;
}
Esempio n. 23
0
/*
 * Opens a window. Requires a SFG_Window object created and attached
 * to the freeglut structure. OpenGL context is created here.
 */
void fgOpenWindow( SFG_Window* window, const char* title,
                   int x, int y, int w, int h,
                   GLboolean gameMode, GLboolean isSubWindow )
{
#if TARGET_HOST_UNIX_X11
    XSetWindowAttributes winAttr;
    XTextProperty textProperty;
    XSizeHints sizeHints;
    XWMHints wmHints;
    unsigned long mask;
    unsigned int current_DisplayMode = fgState.DisplayMode ;

    /* Save the display mode if we are creating a menu window */
    if( window->IsMenu && ( ! fgStructure.MenuContext ) )
        fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB ;

    window->Window.VisualInfo = fgChooseVisual( );

    if( window->IsMenu && ( ! fgStructure.MenuContext ) )
        fgState.DisplayMode = current_DisplayMode ;

    if( ! window->Window.VisualInfo )
    {
        /*
         * The "fgChooseVisual" returned a null meaning that the visual
         * context is not available.
         * Try a couple of variations to see if they will work.
         */
        if( !( fgState.DisplayMode & GLUT_DOUBLE ) )
        {
            fgState.DisplayMode |= GLUT_DOUBLE ;
            window->Window.VisualInfo = fgChooseVisual( );
            fgState.DisplayMode &= ~GLUT_DOUBLE;
        }

        /*
         * GLUT also checks for multi-sampling, but I don't see that
         * anywhere else in FREEGLUT so I won't bother with it for the moment.
         */
    }

    FREEGLUT_INTERNAL_ERROR_EXIT( window->Window.VisualInfo != NULL,
                                  "Visual with necessary capabilities not found", "fgOpenWindow" );

    /*
     * XXX HINT: the masks should be updated when adding/removing callbacks.
     * XXX       This might speed up message processing. Is that true?
     * XXX
     * XXX A: Not appreciably, but it WILL make it easier to debug.
     * XXX    Try tracing old GLUT and try tracing freeglut.  Old GLUT
     * XXX    turns off events that it doesn't need and is a whole lot
     * XXX    more pleasant to trace.  (Think mouse-motion!  Tons of
     * XXX    ``bonus'' GUI events stream in.)
     */
    winAttr.event_mask        =
        StructureNotifyMask | SubstructureNotifyMask | ExposureMask |
        ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask |
        VisibilityChangeMask | EnterWindowMask | LeaveWindowMask |
        PointerMotionMask | ButtonMotionMask;
    winAttr.background_pixmap = None;
    winAttr.background_pixel  = 0;
    winAttr.border_pixel      = 0;

    winAttr.colormap = XCreateColormap(
        fgDisplay.Display, fgDisplay.RootWindow,
        window->Window.VisualInfo->visual, AllocNone
    );

    mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;

    if( window->IsMenu || ( gameMode == GL_TRUE ) )
    {
        winAttr.override_redirect = True;
        mask |= CWOverrideRedirect;
    }

    window->Window.Handle = XCreateWindow(
        fgDisplay.Display,
        window->Parent == NULL ? fgDisplay.RootWindow :
        window->Parent->Window.Handle,
        x, y, w, h, 0,
        window->Window.VisualInfo->depth, InputOutput,
        window->Window.VisualInfo->visual, mask,
        &winAttr
    );

    /*
     * The GLX context creation, possibly trying the direct context rendering
     *  or else use the current context if the user has so specified
     */
    if( window->IsMenu )
    {
        /*
         * If there isn't already an OpenGL rendering context for menu
         * windows, make one
         */
        if( !fgStructure.MenuContext )
        {
            fgStructure.MenuContext =
                (SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) );
            fgStructure.MenuContext->VisualInfo = window->Window.VisualInfo;
            fgStructure.MenuContext->Context = glXCreateContext(
                fgDisplay.Display, fgStructure.MenuContext->VisualInfo,
                NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
            );
        }

        /* window->Window.Context = fgStructure.MenuContext->Context; */
        window->Window.Context = glXCreateContext(
            fgDisplay.Display, window->Window.VisualInfo,
            NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
        );
    }
    else if( fgState.UseCurrentContext )
    {
        window->Window.Context = glXGetCurrentContext( );

        if( ! window->Window.Context )
            window->Window.Context = glXCreateContext(
                fgDisplay.Display, window->Window.VisualInfo,
                NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
            );
    }
    else
        window->Window.Context = glXCreateContext(
            fgDisplay.Display, window->Window.VisualInfo,
            NULL, ( fgState.DirectContext != GLUT_FORCE_INDIRECT_CONTEXT )
        );

#if !defined( __FreeBSD__ ) && !defined( __NetBSD__ )
    if(  !glXIsDirect( fgDisplay.Display, window->Window.Context ) )
    {
      if( fgState.DirectContext == GLUT_FORCE_DIRECT_CONTEXT )
        fgError( "Unable to force direct context rendering for window '%s'",
                 title );
      else if( fgState.DirectContext == GLUT_TRY_DIRECT_CONTEXT )
        fgWarning( "Unable to create direct context rendering for window '%s'\nThis may hurt performance.",
                 title );
    }
#endif

    /*
     * XXX Assume the new window is visible by default
     * XXX Is this a  safe assumption?
     */
    window->State.Visible = GL_TRUE;

    sizeHints.flags = 0;
    if ( fgState.Position.Use )
        sizeHints.flags |= USPosition;
    if ( fgState.Size.Use )
        sizeHints.flags |= USSize;

    /*
     * Fill in the size hints values now (the x, y, width and height
     * settings are obsolete, are there any more WMs that support them?)
     * Unless the X servers actually stop supporting these, we should
     * continue to fill them in.  It is *not* our place to tell the user
     * that they should replace a window manager that they like, and which
     * works, just because *we* think that it's not "modern" enough.
     */
    sizeHints.x      = x;
    sizeHints.y      = y;
    sizeHints.width  = w;
    sizeHints.height = h;

    wmHints.flags = StateHint;
    wmHints.initial_state = fgState.ForceIconic ? IconicState : NormalState;
    /* Prepare the window and iconified window names... */
    XStringListToTextProperty( (char **) &title, 1, &textProperty );

    XSetWMProperties(
        fgDisplay.Display,
        window->Window.Handle,
        &textProperty,
        &textProperty,
        0,
        0,
        &sizeHints,
        &wmHints,
        NULL
    );
    XFree( textProperty.value );

    XSetWMProtocols( fgDisplay.Display, window->Window.Handle,
                     &fgDisplay.DeleteWindow, 1 );

    glXMakeCurrent(
        fgDisplay.Display,
        window->Window.Handle,
        window->Window.Context
    );

    XMapWindow( fgDisplay.Display, window->Window.Handle );

#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE

    WNDCLASS wc;
    DWORD flags;
    DWORD exFlags = 0;
    ATOM atom;

    /* Grab the window class we have registered on glutInit(): */
    atom = GetClassInfo( fgDisplay.Instance, _T("FREEGLUT"), &wc );
    FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Info Not Found",
                                   "fgOpenWindow" );

    if( gameMode )
    {
        FREEGLUT_INTERNAL_ERROR_EXIT ( window->Parent == NULL,
                                       "Game mode being invoked on a subwindow",
                                       "fgOpenWindow" );

        /*
         * Set the window creation flags appropriately to make the window
         * entirely visible:
         */
        flags = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
    }
    else
    {
#if !TARGET_HOST_WINCE
        if ( ( ! isSubWindow ) && ( ! window->IsMenu ) )
        {
            /*
             * Update the window dimensions, taking account of window
             * decorations.  "freeglut" is to create the window with the
             * outside of its border at (x,y) and with dimensions (w,h).
             */
            w += (GetSystemMetrics( SM_CXSIZEFRAME ) )*2;
            h += (GetSystemMetrics( SM_CYSIZEFRAME ) )*2 +
                GetSystemMetrics( SM_CYCAPTION );
        }
#endif /* TARGET_HOST_WINCE */

        if( ! fgState.Position.Use )
        {
            x = CW_USEDEFAULT;
            y = CW_USEDEFAULT;
        }
        if( ! fgState.Size.Use )
        {
            w = CW_USEDEFAULT;
            h = CW_USEDEFAULT;
        }

        /*
         * There's a small difference between creating the top, child and
         * game mode windows
         */
        flags = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;

        if ( window->IsMenu )
        {
            flags |= WS_POPUP;
            exFlags |= WS_EX_TOOLWINDOW;
        }
#if !TARGET_HOST_WINCE
        else if( window->Parent == NULL )
            flags |= WS_OVERLAPPEDWINDOW;
#endif
        else
            flags |= WS_CHILD;
    }

#if TARGET_HOST_WINCE
    {
        wchar_t* wstr = fghWstrFromStr(title);

        window->Window.Handle = CreateWindow(
            _T("FREEGLUT"),
            wstr,
            WS_VISIBLE | WS_POPUP,
            0,0, 240,320,
            NULL,
            NULL,
            fgDisplay.Instance,
            (LPVOID) window
        );

        free(wstr);

        SHFullScreen(window->Window.Handle, SHFS_HIDESTARTICON);
        SHFullScreen(window->Window.Handle, SHFS_HIDESIPBUTTON);
        SHFullScreen(window->Window.Handle, SHFS_HIDETASKBAR);
        MoveWindow(window->Window.Handle, 0, 0, 240, 320, TRUE);
        ShowWindow(window->Window.Handle, SW_SHOW);
        UpdateWindow(window->Window.Handle);
    }
#else
    window->Window.Handle = CreateWindowExA(
        exFlags,
        "FREEGLUT",
        title,
        flags,
        x, y, w, h,
        (HWND) window->Parent == NULL ? NULL : window->Parent->Window.Handle,
        (HMENU) NULL,
        fgDisplay.Instance,
        (LPVOID) window
    );
#endif /* TARGET_HOST_WINCE */

    if( !( window->Window.Handle ) )
        fgError( "Failed to create a window (%s)!", title );

#if TARGET_HOST_WINCE
    ShowWindow( window->Window.Handle, SW_SHOW );
#else
    ShowWindow( window->Window.Handle,
                fgState.ForceIconic ? SW_SHOWMINIMIZED : SW_SHOW );
#endif /* TARGET_HOST_WINCE */

    UpdateWindow( window->Window.Handle );
    ShowCursor( TRUE );  /* XXX Old comments say "hide cursor"! */

#endif

    fgSetWindow( window );

    window->Window.DoubleBuffered =
        ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0;

    if ( ! window->Window.DoubleBuffered )
    {
        glDrawBuffer ( GL_FRONT );
        glReadBuffer ( GL_FRONT );
    }
}
Esempio n. 24
0
/*
 * Opens a window. Requires a SFG_Window object created and attached
 * to the freeglut structure. OpenGL context is created here.
 */
void fgPlatformOpenWindow( SFG_Window* window, const char* title,
                           GLboolean positionUse, int x, int y,
                           GLboolean sizeUse, int w, int h,
                           GLboolean gameMode, GLboolean isSubWindow )
{

    WNDCLASS wc;
    DWORD flags   = 0;
    DWORD exFlags = 0;
    ATOM atom;

    /* Grab the window class we have registered on glutInit(): */
    atom = GetClassInfo( fgDisplay.pDisplay.Instance, _T("FREEGLUT"), &wc );
    FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Info Not Found",
                                   "fgOpenWindow" );

    /* Determine window style flags*/
    if( gameMode )
    {
        FREEGLUT_INTERNAL_ERROR_EXIT ( window->Parent == NULL,
                                       "Game mode being invoked on a subwindow",
                                       "fgOpenWindow" );

        /*
         * Set the window creation flags appropriately to make the window
         * entirely visible:
         */
        flags = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE;
    }
    else
    {
        flags = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;

        /*
         * There's a small difference between creating the top, child and
         * menu windows
         */
        if ( window->IsMenu )
        {
            flags |= WS_POPUP;
            exFlags |= WS_EX_TOOLWINDOW;
        }
#if defined(_WIN32_WCE)
        /* no decorations for windows CE */
#else
        /* if this is not a subwindow (child), set its style based on the requested window decorations */
        else if( window->Parent == NULL )
            fghGetDefaultWindowStyle(&flags);
#endif
        else
            /* subwindows always have no decoration, but are marked as a child window to the OS */
            flags |= WS_CHILD;
    }

    /* determine window size and position */
    if( gameMode )
    {
        /* if in gamemode, query the origin of specified by the -display
         * command line parameter (if any) and offset the upper-left corner
         * of the window so we create the window on that screen.
         * The -display argument doesn't do anything if not trying to enter
         * gamemode.
         */
        int xoff=0, yoff=0;
        get_display_origin(&xoff,&yoff);
        x += xoff;
        y += yoff;
    }
    if( !positionUse )
    {
        x = CW_USEDEFAULT;
        y = CW_USEDEFAULT;
    }
    if( !sizeUse )
    {
        if( ! window->IsMenu )
        {
            w = CW_USEDEFAULT;
            h = CW_USEDEFAULT;
        }
        else /* fail safe - Windows can make a window of size (0, 0) */
            w = h = 300; /* default window size */
    }
    /* store requested client area width and height */
    window->State.Width = w;
    window->State.Height = h;

#if !defined(_WIN32_WCE)    /* no decorations for windows CE */
    if( sizeUse )
    {
        RECT windowRect;
        /*
         * Update the window dimensions, taking the window decorations
         * into account.  FreeGLUT is to create the window with the
         * topleft outside corner at (x,y) and with client area
         * dimensions (w,h).
         * note: don't need to do this when w=h=CW_USEDEFAULT, so in the
         * if( sizeUse ) here is convenient.
         */
        windowRect.left     = x;
        windowRect.top      = y;
        windowRect.right    = x+w;
        windowRect.bottom   = y+h;

        fghComputeWindowRectFromClientArea_UseStyle(&windowRect,flags,exFlags,TRUE);

        /* NB: w and h are now width and height of window including non-client area! */
        w = windowRect.right - windowRect.left;
        h = windowRect.bottom- windowRect.top;
    }
#endif /* !defined(_WIN32_WCE) */

#if defined(_WIN32_WCE)
    {
        wchar_t* wstr = fghWstrFromStr(title);

        window->Window.Handle = CreateWindow(
            _T("FREEGLUT"),
            wstr,
            WS_VISIBLE | WS_POPUP,
            0,0, 240,320,
            NULL,
            NULL,
            fgDisplay.pDisplay.Instance,
            (LPVOID) window
        );

        free(wstr);

        SHFullScreen(window->Window.Handle, SHFS_HIDESTARTICON);
        SHFullScreen(window->Window.Handle, SHFS_HIDESIPBUTTON);
        SHFullScreen(window->Window.Handle, SHFS_HIDETASKBAR);
        MoveWindow(window->Window.Handle, 0, 0, 240, 320, TRUE);
        ShowWindow(window->Window.Handle, SW_SHOW);
        UpdateWindow(window->Window.Handle);
    }
#else
    window->Window.Handle = CreateWindowEx(
        exFlags,
        _T("FREEGLUT"),
        title,
        flags,
        x, y, w, h,
        (HWND) window->Parent == NULL ? NULL : window->Parent->Window.Handle,
        (HMENU) NULL,
        fgDisplay.pDisplay.Instance,
        (LPVOID) window
    );
#endif /* defined(_WIN32_WCE) */

    if( !( window->Window.Handle ) )
        fgError( "Failed to create a window (%s)!", title );

#if !defined(_WIN32_WCE)
    /* Need to set requested style again, apparently Windows doesn't listen when requesting windows without title bar or borders */
    SetWindowLong(window->Window.Handle, GWL_STYLE, flags);
    SetWindowPos(window->Window.Handle, HWND_TOP, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
#endif /* defined(_WIN32_WCE) */

    /* Make a menu window always on top - fix Feature Request 947118 */
    if( window->IsMenu || gameMode )
        SetWindowPos(
                        window->Window.Handle,
                        HWND_TOPMOST,
                        0, 0, 0, 0,
                        SWP_NOMOVE | SWP_NOSIZE
                    );

    /* Enable multitouch: additional flag TWF_FINETOUCH, TWF_WANTPALM */
    #ifdef WM_TOUCH
        if (fghRegisterTouchWindow == (pRegisterTouchWindow)0xDEADBEEF) 
			fghRegisterTouchWindow = (pRegisterTouchWindow)GetProcAddress(GetModuleHandle("user32"),"RegisterTouchWindow");
		if (fghRegisterTouchWindow)
             fghRegisterTouchWindow( window->Window.Handle, TWF_FINETOUCH | TWF_WANTPALM );
    #endif

#if defined(_WIN32_WCE)
    ShowWindow( window->Window.Handle, SW_SHOW );
#else
    ShowWindow( window->Window.Handle,
                fgState.ForceIconic ? SW_SHOWMINIMIZED : SW_SHOW );
#endif /* defined(_WIN32_WCE) */

    UpdateWindow( window->Window.Handle );
    ShowCursor( TRUE );  /* XXX Old comments say "hide cursor"! */
}
Esempio n. 25
0
int GAPI_ShowTaskBar()
{
	if(!bShowTaskBar)
	{
		int topBorder, bottomBorder;
		RECT rc;

		//Take screen shot
		CreateBitMap();		

		//Need close the GAPI to give key control back to the system
		CloseGAPI(); 	

		
		//ShowWindow(SDL_Window, SW_HIDE); 
		SHFullScreen(SDL_Window, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
		bShowTaskBar = 1;

		GetTopBottomBorder(&topBorder, &bottomBorder);
			
		SDL_WM_SetCaption(GetGameTitle(), NULL);

		SHDoneButton(SDL_Window, SHDB_HIDE);
		
		{
			//http://forum.soft32.com/pda/SHCreateMenuBar-resource-file-ftopict47431.html
			SHMENUBARINFO cbi;
			memset(&cbi, 0, sizeof(SHMENUBARINFO));		
			menuBar = NULL;
			
			cbi.cbSize = sizeof(SHMENUBARINFO); 
			cbi.hwndParent = SDL_Window; 
			cbi.hInstRes = SDL_Instance; 
			cbi.nToolBarId = IDR_MENUBAR;

			//cbi.dwFlags = /*SHCMBF_EMPTYBAR |*/ SHCMBF_HIDESIPBUTTON | SHCMBF_HMENU; //Don't use this with the Smartphone menu
			
			if(SHCreateMenuBar(&cbi))
			{
				menuBar = (HMENU)cbi.hwndMB;				
			}
		}

		//http://msdn.microsoft.com/en-us/library/aa453694.aspx
		SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, FALSE);
        MoveWindow(SDL_Window, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE); //Show the game menu, but not the incoming call menu		
		SetWindowPos(GetForegroundWindow(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE); //Show incoming call window 
		SetWindowPos(SDL_Window, HWND_NOTOPMOST, /*0, 0, 1, 1*/sdlWindowSize.left, sdlWindowSize.top + topBorder, sdlWindowSize.right, sdlWindowSize.bottom - (topBorder + bottomBorder), SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_SHOWWINDOW); //Allow to show the incomming call window

		
		if(menuBar) writeDebugInfo("GAPI_ShowTaskBar Menu Ok"); 
		else
		{
			char buf[64];
			sprintf(buf, "GAPI_ShowTaskBar No Menu, Error: %ld", GetLastError());
			writeDebugInfo(buf); 
		}


		return 1;
	}

	return 0;
}
Esempio n. 26
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  long wdata;

  switch (message)
    {

    case WM_ERASEBKGND:
      return TRUE; // JMW trying to reduce screen flicker
      break;
    case WM_COMMAND:
      return MainMenu(hWnd, message, wParam, lParam);
      break;
    case WM_CTLCOLORSTATIC:
      wdata = GetWindowLong((HWND)lParam, GWL_USERDATA);
      switch(wdata) {
      case 0:
        SetBkColor((HDC)wParam, ColorUnselected);
        SetTextColor((HDC)wParam, RGB(0x00,0x00,0x00));
        return (LRESULT)hBrushUnselected;
      case 1:
        SetBkColor((HDC)wParam, ColorSelected);
        SetTextColor((HDC)wParam, RGB(0x00,0x00,0x00));
        return (LRESULT)hBrushSelected;
      case 2:
	SetBkColor((HDC)wParam, ColorUnselected);
        SetTextColor((HDC)wParam, ColorWarning);
	return (LRESULT)hBrushUnselected;
      case 3:
	SetBkColor((HDC)wParam, ColorUnselected);
        SetTextColor((HDC)wParam, ColorOK);
	return (LRESULT)hBrushUnselected;
      case 4:
	// black on light green
        SetTextColor((HDC)wParam, RGB_BLACK); 
	SetBkColor((HDC)wParam, ColorButton);
	return (LRESULT)hBrushButton;
      case 5:
	// grey on light green
	SetBkColor((HDC)wParam, ColorButton);
        SetTextColor((HDC)wParam, RGB(0x80,0x80,0x80));
	return (LRESULT)hBrushButton;
#ifdef LXMINIMAP
      case 6:
        // black on dark yellow
        SetTextColor((HDC)wParam, RGB_BLACK);
        SetBkColor((HDC)wParam, ColorButtonHasFocus);
        return (LRESULT)hBrushButtonHasFocus;
      case 7:
        // grey on dark yellow
        SetTextColor((HDC)wParam, RGB(0x80,0x80,0x80));
        SetBkColor((HDC)wParam, ColorButtonHasFocus);
        return (LRESULT)hBrushButtonHasFocus;
#endif

      }
      break;
    case WM_CREATE:
#ifdef HAVE_ACTIVATE_INFO
      memset (&s_sai, 0, sizeof (s_sai));
      s_sai.cbSize = sizeof (s_sai);
#endif
      if (iTimerID == 0) {
        iTimerID = SetTimer(hWnd,1000,500,NULL); // 500ms  2 times per second
      }

      break;

    case WM_ACTIVATE:

      if(LOWORD(wParam) != WA_INACTIVE)
        {
          SetWindowPos(hWndMainWindow,HWND_TOP,
                 0, 0, 0, 0,
                 SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE);

#ifdef HAVE_ACTIVATE_INFO
         SHFullScreen(hWndMainWindow,SHFS_HIDETASKBAR|SHFS_HIDESIPBUTTON|SHFS_HIDESTARTICON);
#endif

        }
#ifdef HAVE_ACTIVATE_INFO
      if (api_has_SHHandleWMActivate) {
        SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE);
      } else {
        #ifdef TESTBENCH
        StartupStore(TEXT("... SHHandleWMActivate not available%s"),NEWLINE);
        #endif
        return DefWindowProc(hWnd, message, wParam, lParam);
      }
#endif
      break;

    case WM_SETTINGCHANGE:
#ifdef HAVE_ACTIVATE_INFO
      if (api_has_SHHandleWMSettingChange) {
        SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
      } else {
        #ifdef TESTBENCH
        StartupStore(TEXT("... SHHandleWMSettingChange not available%s"),NEWLINE);
        #endif
        return DefWindowProc(hWnd, message, wParam, lParam);
      }
#endif
      break;

	#if DEBUG_FOCUS
    case WM_KILLFOCUS:
	// This is happening when focus is given to another window, either internally inside LK
	// or externally, for example to explorer..
	// SO: if we select MapWindow, we get here a KILLFOCUS from it.
	// When we select another process/program, or click on the desktop, the old window having focus is
	// receiving KILLFOCUS. So in case MapWindow was working, the signal will be sent over there, not here.
	// 
	StartupStore(_T("............ WNDPROC LOST FOCUS (KILLFOCUS)\n"));
	break;
	#endif

    case WM_SETFOCUS:
	// When explorer/desktop is giving focus to LK, this is where we get the signal.
	// But we must return focus to previous windows otherwise keys will not be working.
	// Mouse is another story, because mouse click is pertinent to a screen area which is mapped.
	// A mouse click will be sent to the window in the background, whose handler will receive the event.
	//
	// Each event handler receiving focus has to save it in hWndWithFocus, in LK.
	// Each event handler must thus handle SETFOCUS!
	//
	#if DEBUG_FOCUS
	StartupStore(_T("............ WNDPROC HAS FOCUS  (SETFOCUS)\n"));
	if (hWndWithFocus==NULL)
		StartupStore(_T(".....(no Wnd to give focus to)\n"));
	else
		StartupStore(_T(".....(passing focus to other window)\n"));
	#endif
	if (hWndWithFocus!=NULL) SetFocus(hWndWithFocus);
      break;

    case WM_KEYUP:
      break;

    case WM_TIMER:
	// WM_TIMER is run at about 2hz.
	LKHearthBeats++; // 100213
      //      ASSERT(hWnd==hWndMainWindow);
      if (ProgramStarted > psInitInProgress) {
	if (SIMMODE)
		SIMProcessTimer();
	else
		ProcessTimer();
	if (ProgramStarted==psFirstDrawDone) {
	  AfterStartup();
	  ProgramStarted = psNormalOp;
          StartupStore(_T(". ProgramStarted=NormalOp %s%s"), WhatTimeIsIt(),NEWLINE);
          StartupLogFreeRamAndStorage();

	}
      }
      break;

    case WM_INITMENUPOPUP:
      if (ProgramStarted > psInitInProgress) {
	  CheckMenuItem((HMENU) wParam,IDM_FILE_LOCK,MF_CHECKED|MF_BYCOMMAND);
	
	if(LoggerActive)
	  CheckMenuItem((HMENU) wParam,IDM_FILE_LOGGER,MF_CHECKED|MF_BYCOMMAND);
	else
	  CheckMenuItem((HMENU) wParam,IDM_FILE_LOGGER,MF_UNCHECKED|MF_BYCOMMAND);
      }
      break;

    case WM_CLOSE:

      LKASSERT(hWnd==hWndMainWindow);
      if((hWnd==hWndMainWindow) && 
         (MessageBoxX(hWndMainWindow,
		// LKTOKEN  _@M198_ = "Confirm Exit?"
               	gettext(TEXT("_@M198_")),
                      TEXT("LK8000"),
                      MB_YESNO|MB_ICONQUESTION) == IDYES)) 
        {
          if(iTimerID) {
            KillTimer(hWnd,iTimerID);
            iTimerID = 0;
          }

          Shutdown();
        }
      break;

    case WM_DESTROY:
      if (hWnd==hWndMainWindow) {
        PostQuitMessage(0);
      }
      break;

#ifdef PNA
#if TESTBENCH
    case WM_DEVICECHANGE:
	 TCHAR serr[50];
	 static WPARAM oldwparam=0;
	 StartupStore(_T("DEVICE CHANGE DETECTED, CODE=0x%x%s"),wParam,NEWLINE);

	 if (wParam!=oldwparam) {
		 oldwparam=wParam;
	 	wsprintf(serr,_T("DEVICE CHANGE DETECTED\nCODE=0x%x"),wParam);
		DoStatusMessage(serr);
        	 // MessageBoxX(hWndMainWindow, serr, TEXT("LK8000"), MB_OK|MB_ICONQUESTION, true);
		 oldwparam=0;
	 }
	 return TRUE; // acknowledge
	 break;
#endif
#endif

    default:
      return DefWindowProc(hWnd, message, wParam, lParam);
    }
  return 0;
}
Esempio n. 27
0
/***********************************************************************

FUNCTION: 
  WndProc

PURPOSE: 
  Processes messages sent to the main window.

***********************************************************************/
LRESULT PrefsDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
    SHINITDLGINFO shidi;
    SHMENUBARINFO mbi;
    RECT rcClient;

    switch( msg )
    {
    case WM_INITDIALOG:
        shidi.dwMask = SHIDIM_FLAGS;
        shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
            SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
        shidi.hDlg = hwnd;
        SHInitDialog( &shidi );

        //Create the menubar
        memset( &mbi, 0, sizeof (SHMENUBARINFO) );
        mbi.cbSize     = sizeof (SHMENUBARINFO);
        mbi.hwndParent = hwnd;
        mbi.dwFlags    = SHCMBF_EMPTYBAR;
        mbi.hInstRes   = hInst;

        if( !SHCreateMenuBar(&mbi) )
        {
            MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK);
            //return -1;
        }

        hwndCB = mbi.hwndMB;

        // Get the client area rect to put the panels in
        GetClientRect(hwnd, &rcClient);

        /* Create the buttons */            
        advanced_checkbox =
            CreateWindow( _T("BUTTON"), _T("Advanced options"),
                        WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
                        5, 10, 15, 15, hwnd, NULL, hInst, NULL );
        SendMessage( advanced_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );

        advanced_label = CreateWindow( _T("STATIC"), _T("Advanced options"),
                        WS_CHILD | WS_VISIBLE | SS_LEFT,
                        5 + 15 + 5, 10, 110, 15,
                        hwnd, NULL, hInst, NULL);

        if( config_GetInt( p_intf, "advanced" ) )
        {
            SendMessage( advanced_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
            /*dummy_event.SetInt(TRUE);
              OnAdvanced( dummy_event );*/
        }

        reset_button = CreateWindow( _T("BUTTON"), _T("Reset All"),
                        WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                        rcClient.right - 5 - 80, 10 - 3, 80, 15 + 6,
                        hwnd, NULL, hInst, NULL );

        /* Create the preferences tree control */
        prefs_tree = new PrefsTreeCtrl( p_intf, this, hwnd, hInst );

        UpdateWindow( hwnd );
        break;

    case WM_CLOSE:
        EndDialog( hwnd, LOWORD( wp ) );
        break;

    case WM_SETFOCUS:
        SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON );
        break;

    case WM_COMMAND:
        if( LOWORD(wp) == IDOK )
        {
            OnOk();
            EndDialog( hwnd, LOWORD( wp ) );
        }
        break;

    case WM_NOTIFY:

        if( lp && prefs_tree &&
            ((LPNMHDR)lp)->hwndFrom == prefs_tree->hwndTV &&
            ((LPNMHDR)lp)->code == TVN_SELCHANGED )
        {
            prefs_tree->OnSelectTreeItem( (NM_TREEVIEW FAR *)(LPNMHDR)lp,
                                          hwnd, hInst );
        }
        break;

    case WM_VSCROLL:
    {
        TVITEM tvi = {0};
        tvi.mask = TVIF_PARAM;
        tvi.hItem = TreeView_GetSelection( prefs_tree->hwndTV );
	if( !tvi.hItem ) break;

        if( !TreeView_GetItem( prefs_tree->hwndTV, &tvi ) ) break;

        ConfigTreeData *config_data =
            prefs_tree->FindModuleConfig( (ConfigTreeData *)tvi.lParam );
        if( config_data && hwnd == config_data->panel->config_window ) 
        {
            int dy;
            RECT rc;
            GetWindowRect( hwnd, &rc);
            int newvalue = config_data->panel->oldvalue;
            switch ( GET_WM_VSCROLL_CODE(wp,lp) ) 
            {
            case SB_BOTTOM       : newvalue = 0; break;
            case SB_TOP          : newvalue = config_data->panel->maxvalue; break;
            case SB_LINEDOWN     : newvalue += 10; break;
            case SB_PAGEDOWN     : newvalue += rc.bottom - rc.top - 25; break; // wrong! one page is notebook actual length
            case SB_LINEUP       : newvalue -= 10; break;
            case SB_PAGEUP       : newvalue -= rc.bottom - rc.top - 25; break;
            case SB_THUMBPOSITION:
            case SB_THUMBTRACK   : newvalue = GET_WM_VSCROLL_POS(wp,lp); break;
            }
            newvalue = max(0,min(config_data->panel->maxvalue,newvalue));
            SetScrollPos( hwnd,SB_VERT,newvalue,TRUE);//SB_CTL si hwnd=hwndScrollBar, SB_VERT si window
            dy = config_data->panel->oldvalue - newvalue;

            ScrollWindowEx( hwnd, 0, dy, NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN );
            UpdateWindow ( hwnd);

            config_data->panel->oldvalue = newvalue;                                
        }
        break;
    }

    default:
        break;
    }

    return FALSE;
}
Esempio n. 28
0
SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
				int width, int height, int bpp, Uint32 flags)
{
	SDL_Surface *video;
	Uint32 prev_flags;
	DWORD style;
	const DWORD directstyle =
			(WS_POPUP);
	const DWORD windowstyle = 
			(WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX);
	const DWORD resizestyle =
			(WS_THICKFRAME|WS_MAXIMIZEBOX);
	int binfo_size;
	BITMAPINFO *binfo;
	HDC hdc;
	RECT bounds;
	int x, y;
	Uint32 Rmask, Gmask, Bmask;
#ifdef HAVE_OPENGL //maks
	/* Clean up any GL context that may be hanging around */
	if ( current->flags & SDL_OPENGL ) { //maks: close only in viewo quit to avoid texture lost when go to game mode
		WIN_GL_ShutDown(this);
	}
#endif

	/* Recalculate the bitmasks if necessary */
	if ( bpp == current->format->BitsPerPixel ) {
		video = current;
	} else {
		switch (bpp) {
			case 15:
			case 16:
				if ( DIB_SussScreenDepth() == 15 ) {
					/* 5-5-5 */
					Rmask = 0x00007c00;
					Gmask = 0x000003e0;
					Bmask = 0x0000001f;
				} else {
					/* 5-6-5 */
					Rmask = 0x0000f800;
					Gmask = 0x000007e0;
					Bmask = 0x0000001f;
				}
				break;
			case 24:
			case 32:
				/* GDI defined as 8-8-8 */
				Rmask = 0x00ff0000;
				Gmask = 0x0000ff00;
				Bmask = 0x000000ff;
				break;
			default:
				Rmask = 0x00000000;
				Gmask = 0x00000000;
				Bmask = 0x00000000;
				break;
		}
		video = SDL_CreateRGBSurface(SDL_SWSURFACE,
					0, 0, bpp, Rmask, Gmask, Bmask, 0);
		if ( video == NULL ) {
			SDL_OutOfMemory();
			return(NULL);
		}
	}

	/* Fill in part of the video surface */
	prev_flags = video->flags;
	video->flags = 0;	/* Clear flags */
	video->w = width;
	video->h = height;
	video->pitch = SDL_CalculatePitch(video);

#ifdef WIN32_PLATFORM_PSPC
	 /* Stuff to hide that $#!^%#$ WinCE taskbar in fullscreen... */
	if ( flags & SDL_FULLSCREEN ) {
		if ( !(prev_flags & SDL_FULLSCREEN) ) {
			SHFullScreen(SDL_Window, SHFS_HIDETASKBAR);
			SHFullScreen(SDL_Window, SHFS_HIDESIPBUTTON);
			ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_HIDE);
		}
		video->flags |= SDL_FULLSCREEN;
	} else {
		if ( prev_flags & SDL_FULLSCREEN ) {
			SHFullScreen(SDL_Window, SHFS_SHOWTASKBAR);
			SHFullScreen(SDL_Window, SHFS_SHOWSIPBUTTON);
			ShowWindow(FindWindow(TEXT("HHTaskBar"),NULL),SW_SHOWNORMAL);
		}
	}
#endif
#ifndef NO_CHANGEDISPLAYSETTINGS
	/* Set fullscreen mode if appropriate */
	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
		DEVMODE settings;

		memset(&settings, 0, sizeof(DEVMODE));
		settings.dmSize = sizeof(DEVMODE);
		settings.dmBitsPerPel = video->format->BitsPerPixel;
		settings.dmPelsWidth = width;
		settings.dmPelsHeight = height;
		settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
		if ( ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL ) {
			video->flags |= SDL_FULLSCREEN;
			SDL_fullscreen_mode = settings;
		}
	}
#endif /* !NO_CHANGEDISPLAYSETTINGS */

	/* Reset the palette and create a new one if necessary */
	if ( screen_pal != NULL ) {
	/*	RJR: March 28, 2000
		delete identity palette if switching from a palettized mode */
		DeleteObject(screen_pal);
		screen_pal = NULL;
	}
	if ( bpp <= 8 )
	{
	/*	RJR: March 28, 2000
		create identity palette switching to a palettized mode */
		screen_pal = DIB_CreatePalette(bpp);
	}

	style = GetWindowLong(SDL_Window, GWL_STYLE);
	style &= ~(resizestyle|WS_MAXIMIZE);
	if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
		style &= ~windowstyle;
		style |= directstyle;
	} else {
#ifndef NO_CHANGEDISPLAYSETTINGS
		if ( (prev_flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
			ChangeDisplaySettings(NULL, 0);
		}
#endif
		if ( flags & SDL_NOFRAME ) {
			style &= ~windowstyle;
			style |= directstyle;
			video->flags |= SDL_NOFRAME;
		} else {
			style &= ~directstyle;
			style |= windowstyle;
			if ( flags & SDL_RESIZABLE ) {
				style |= resizestyle;
				video->flags |= SDL_RESIZABLE;
			}
		}
#if WS_MAXIMIZE
		if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
#endif
	}

	/* DJM: Don't piss of anyone who has setup his own window */
	if ( SDL_windowid == NULL )
		SetWindowLong(SDL_Window, GWL_STYLE, style);

	/* Delete the old bitmap if necessary */
	if ( screen_bmp != NULL ) {
		DeleteObject(screen_bmp);
	}
	if ( ! (flags & SDL_OPENGL) ) {
		BOOL is16bitmode = (video->format->BytesPerPixel == 2);

		/* Suss out the bitmap info header */
		binfo_size = sizeof(*binfo);
		if( is16bitmode ) {
			/* 16bit modes, palette area used for rgb bitmasks */
			binfo_size += 3*sizeof(DWORD);
		} else if ( video->format->palette ) {
			binfo_size += video->format->palette->ncolors *
							sizeof(RGBQUAD);
		}
		binfo = (BITMAPINFO *)malloc(binfo_size);
		if ( ! binfo ) {
			if ( video != current ) {
				SDL_FreeSurface(video);
			}
			SDL_OutOfMemory();
			return(NULL);
		}

		binfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
		binfo->bmiHeader.biWidth = video->w;
		binfo->bmiHeader.biHeight = -video->h;	/* -ve for topdown bitmap */
		binfo->bmiHeader.biPlanes = 1;
		binfo->bmiHeader.biSizeImage = video->h * video->pitch;
		binfo->bmiHeader.biXPelsPerMeter = 0;
		binfo->bmiHeader.biYPelsPerMeter = 0;
		binfo->bmiHeader.biClrUsed = 0;
		binfo->bmiHeader.biClrImportant = 0;
		binfo->bmiHeader.biBitCount = video->format->BitsPerPixel;

		if ( is16bitmode ) {
			/* BI_BITFIELDS tells CreateDIBSection about the rgb masks in the palette */
			binfo->bmiHeader.biCompression = BI_BITFIELDS;
			((Uint32*)binfo->bmiColors)[0] = video->format->Rmask;
			((Uint32*)binfo->bmiColors)[1] = video->format->Gmask;
			((Uint32*)binfo->bmiColors)[2] = video->format->Bmask;
		} else {
			binfo->bmiHeader.biCompression = BI_RGB;	/* BI_BITFIELDS for 565 vs 555 */
			if ( video->format->palette ) {
				memset(binfo->bmiColors, 0,
					video->format->palette->ncolors*sizeof(RGBQUAD));
			}
		}

		/* Create the offscreen bitmap buffer */
		hdc = GetDC(SDL_Window);
		screen_bmp = CreateDIBSection(hdc, binfo, DIB_RGB_COLORS,
					(void **)(&video->pixels), NULL, 0);
		ReleaseDC(SDL_Window, hdc);
		free(binfo);
		if ( screen_bmp == NULL ) {
			if ( video != current ) {
				SDL_FreeSurface(video);
			}
			SDL_SetError("Couldn't create DIB section");
			return(NULL);
		}
		this->UpdateRects = DIB_NormalUpdate;

		/* Set video surface flags */
		if ( bpp <= 8 ) {
			/* BitBlt() maps colors for us */
			video->flags |= SDL_HWPALETTE;
		}
	}

	/* Resize the window */
	if ( SDL_windowid == NULL ) {
		HWND top;
		UINT swp_flags;
		const char *window = getenv("SDL_VIDEO_WINDOW_POS");
		const char *center = getenv("SDL_VIDEO_CENTERED");

		if ( !SDL_windowX && !SDL_windowY ) {
			if ( window ) {
				if ( sscanf(window, "%d,%d", &x, &y) == 2 ) {
					SDL_windowX = x;
					SDL_windowY = y;
				}
				if ( strcmp(window, "center") == 0 ) {
					center = window;
					window = NULL;
				}
			}
		}
		swp_flags = (SWP_NOCOPYBITS | SWP_SHOWWINDOW);

		SDL_resizing = 1;
		bounds.left = SDL_windowX;
		bounds.top = SDL_windowY;
		bounds.right = SDL_windowX+video->w;
		bounds.bottom = SDL_windowY+video->h;
		AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0);
		width = bounds.right-bounds.left;
		height = bounds.bottom-bounds.top;
		if ( (flags & SDL_FULLSCREEN) ) {
			x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
			y = (GetSystemMetrics(SM_CYSCREEN)-height)/2;
		} else if ( SDL_windowX || SDL_windowY || window ) {
			x = bounds.left;
			y = bounds.top;
		} else if ( center ) {
			x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
			y = (GetSystemMetrics(SM_CYSCREEN)-height)/2;
		} else {
			x = y = -1;
			swp_flags |= SWP_NOMOVE;
		}
		if ( y < 0 ) { /* Cover up title bar for more client area */
			y -= GetSystemMetrics(SM_CYCAPTION)/2;
		}
		if ( flags & SDL_FULLSCREEN ) {
			top = HWND_TOPMOST;
		} else {
			top = HWND_NOTOPMOST;
		}
		SetWindowPos(SDL_Window, top, x, y, width, height, swp_flags);
		SDL_resizing = 0;
		SetForegroundWindow(SDL_Window);
	}
#ifdef HAVE_OPENGL //maks
	/* Set up for OpenGL */
	if ( flags & SDL_OPENGL ) 
	{
		/*if ( WIN_GL_SetupWindow(this) < 0 ) {
			return(NULL);
		}

		video->flags |= SDL_OPENGL;*/

		if ( WIN_GL_SetupWindow(this) >= 0 )
		{
			video->flags |= SDL_OPENGL;
		}
	}
#endif

	/* We're live! */
	return(video);
}
Esempio n. 29
0
/*!***********************************************************************
 @Function		OsInitOS
 @description	Saves instance handle and creates main window
				In this function, we save the instance handle in a global variable and
				create and display the main program window.
*************************************************************************/
bool PVRShellInit::OsInitOS()
#ifndef NO_GDI
{
	MONITORINFO sMInfo;
	TCHAR		*appName;
	RECT		winRect;
	POINT		p;

	MyRegisterClass();

#ifdef UNDER_CE
	if(!m_pShell->m_pShellData->bUsingPowerSaving)
	{
		/*
			See "Program Applications to Turn the Smartphone Backlight Off and On":
				<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mobilesdk5/html/mob5tskHowToProgramApplicationsToTurnSmartphoneBacklightOffOn.asp>
		*/
		SetPowerRequirement(_T("BKL1:"), D0, POWER_NAME, NULL, 0);

		/*
			It is also necessary to prevent the display driver entering
			power-saving mode.

			The string used here is hard-coded. The following function can
			probably be used to enumerate available strings:
				RequestDeviceNotifications()
		*/
		SetPowerRequirement(_T("{EB91C7C9-8BF6-4a2d-9AB8-69724EED97D1}\\\\Windows\\ddi.dll"), D0, POWER_NAME, NULL, 0);
    }
#endif

	/*
		Build the window title
	*/
	{
		const char		*pszName, *pszSeparator, *pszVersion;
		size_t			len;
		unsigned int	out, in;

		pszName			= (const char*)m_pShell->PVRShellGet(prefAppName);
		pszSeparator	= STR_WNDTITLE;
		pszVersion		= (const char*)m_pShell->PVRShellGet(prefVersion);

		len = strlen(pszName)+strlen(pszSeparator)+strlen(pszVersion)+1;
		appName = new TCHAR[len];

		for(out = 0; (appName[out] = pszName[out]) != 0; ++out);
		for(in = 0; (appName[out] = pszSeparator[in]) != 0; ++in, ++out);
		for(in = 0; (appName[out] = pszVersion[in]) != 0; ++in, ++out);
		_ASSERT(out == len-1);
	}

	/*
		Retrieve the monitor information.

		MonitorFromWindow() doesn't work, because the window hasn't been
		created yet.
	*/
	{
		HMONITOR	hMonitor;
		BOOL		bRet;

		p.x			= m_pShell->m_pShellData->nShellPosX;
		p.y			= m_pShell->m_pShellData->nShellPosY;
		hMonitor	= MonitorFromPoint(p, MONITOR_DEFAULTTOPRIMARY);
		sMInfo.cbSize = sizeof(sMInfo);
		bRet = GetMonitorInfo(hMonitor, &sMInfo);
		_ASSERT(bRet);
	}

	/*
		Reduce the window size until it fits on screen
	*/
	while(
		(m_pShell->m_pShellData->nShellDimX > (sMInfo.rcMonitor.right - sMInfo.rcMonitor.left)) ||
		(m_pShell->m_pShellData->nShellDimY > (sMInfo.rcMonitor.bottom - sMInfo.rcMonitor.top)))
	{
		m_pShell->m_pShellData->nShellDimX >>= 1;
		m_pShell->m_pShellData->nShellDimY >>= 1;
	}


	/*
		Create the window
	*/

	if(m_pShell->m_pShellData->bFullScreen)
	{
		m_hWnd = CreateWindow(WINDOW_CLASS, appName, WS_VISIBLE | WS_SYSMENU,CW_USEDEFAULT, CW_USEDEFAULT, m_pShell->m_pShellData->nShellDimX, m_pShell->m_pShellData->nShellDimY,
				NULL, NULL, m_hInstance, this);

		SetWindowLong(m_hWnd,GWL_STYLE,GetWindowLong(m_hWnd,GWL_STYLE) &~ WS_CAPTION);
		SetWindowPos(m_hWnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
	}
	else
	{
		int x, y;

		SetRect(&winRect,
			m_pShell->m_pShellData->nShellPosX,
			m_pShell->m_pShellData->nShellPosY,
			m_pShell->m_pShellData->nShellPosX+m_pShell->m_pShellData->nShellDimX,
			m_pShell->m_pShellData->nShellPosY+m_pShell->m_pShellData->nShellDimY);
		AdjustWindowRectEx(&winRect, WS_CAPTION|WS_SYSMENU, false, 0);

		x = m_pShell->m_pShellData->nShellPosX - winRect.left;
		winRect.left += x;
		winRect.right += x;

		y = m_pShell->m_pShellData->nShellPosY - winRect.top;
		winRect.top += y;
		winRect.bottom += y;

		if(m_pShell->m_pShellData->bShellPosWasDefault)
		{
			x = CW_USEDEFAULT;
			y = CW_USEDEFAULT;
		}
		else
		{
			x = winRect.left;
			y = winRect.top;
		}

		m_hWnd = CreateWindow(WINDOW_CLASS, appName, WS_VISIBLE|WS_CAPTION|WS_SYSMENU,
			x, y, winRect.right-winRect.left, winRect.bottom-winRect.top, NULL, NULL, m_hInstance, this);

	}

	if(!m_hWnd)
		return false;

	if(m_pShell->m_pShellData->bFullScreen)
	{
		m_pShell->m_pShellData->nShellDimX = sMInfo.rcMonitor.right;
		m_pShell->m_pShellData->nShellDimY = sMInfo.rcMonitor.bottom;
		SetWindowPos(m_hWnd,HWND_TOPMOST,0,0,m_pShell->m_pShellData->nShellDimX,m_pShell->m_pShellData->nShellDimY,0);

#if UNDER_CE == 420 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)
		/*
			Fix for 'Top menu-bar' corruption (occurring on exiting egltest in
			fullscreen mode on PocketPC).

			See "How To Create Full-Screen Applications for the PocketPC":
				<http://support.microsoft.com/default.aspx?scid=kb;%5Bln%5D;266244>
		*/
		SetForegroundWindow(m_hWnd);
		SHFullScreen(m_hWnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | SHFS_HIDESTARTICON);
		MoveWindow(m_hWnd,
					sMInfo.rcMonitor.left,
					sMInfo.rcMonitor.top,
					sMInfo.rcMonitor.right,
					sMInfo.rcMonitor.bottom,
					TRUE);
#endif
	}

	m_hDC = GetDC(m_hWnd);
	ShowWindow(m_hWnd, m_nCmdShow);
	UpdateWindow(m_hWnd);

	p.x = 0;
	p.y = 0;
	ClientToScreen(m_hWnd, &p);
	m_pShell->m_pShellData->nShellPosX = p.x;
	m_pShell->m_pShellData->nShellPosY = p.y;

	delete [] appName;
	return true;
}
Esempio n. 30
0
SDL_Surface *GAPI_SetVideoMode(_THIS, SDL_Surface *current,
				int width, int height, int bpp, Uint32 flags)
{
	SDL_Surface *video;
	Uint32 prev_flags;
	DWORD style;
	const DWORD directstyle =
			(WS_POPUP);
	const DWORD windowstyle = 
			(WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX);
	const DWORD resizestyle =
			(WS_THICKFRAME|WS_MAXIMIZEBOX);

	
	int x, y;
	BOOL was_visible;
	Uint32 Rmask, Gmask, Bmask;


#ifdef HAVE_OPENGL //maks
	/* Clean up any GL context that may be hanging around */
	if ( current->flags & SDL_OPENGL ) { //maks: close only in video quit to avoid texture lost when go to game mode
		WIN_GL_ShutDown(this);
	}
#endif	
	

#ifdef _USE_POCKET_HAL_

	halWidth = width;
	halHeight = height;

	//Don't use GAPI or PocketHAL with OpenGL
	//Hybrid will show a blank screen
	OpenGAPI(1);	//Can open PocketHAL in Intel 2700G

	//Go to the game, monitor task bar
	HookTaskBar();

	/*if( flags & SDL_FULLSCREEN ) 
	{
		//maks: native resolution only		
		//Causes "Error - not enough memory to execute the game"
		halGetDimensions(&width, &height);
	}*/

	/* Recalculate the bitmasks if necessary */
	if ( bpp == current->format->BitsPerPixel ) 
	{
		video = current;
	} 
	else 
	{
		bpp = 16;		
		
		/* 5-6-5 */
		Rmask = 0x0000f800;
		Gmask = 0x000007e0;
		Bmask = 0x0000001f;	
		
		
		video = SDL_CreateRGBSurface(SDL_SWSURFACE,
					0, 0, bpp, Rmask, Gmask, Bmask, 0);

		if ( video == NULL ) 
		{
			SDL_OutOfMemory();
			return(NULL);
		}
	}
	
#else

	int m_nXPitch, m_nYPitch;
	GXDisplayProperties m_dispProps = GXGetDisplayProperties();

	m_nXPitch = m_dispProps.cbxPitch >> 1;
	m_nYPitch = m_dispProps.cbyPitch >> 1;

	if (m_nXPitch < 0)
	{
		this->hidden->m_nBufferStartOffset = m_nXPitch * (m_dispProps.cxWidth - 1);
	}
	else
	{
		this->hidden->m_nBufferEndOffset = m_nXPitch * (m_dispProps.cxWidth - 1);
	}

	if (m_nYPitch < 0)
	{
		this->hidden->m_nBufferStartOffset += m_nYPitch * (m_dispProps.cyHeight - 1);
	}
	else
	{
		this->hidden->m_nBufferEndOffset += m_nYPitch * (m_dispProps.cyHeight - 1);
	}

	

	
	

	/* Recalculate the bitmasks if necessary */
	if ( bpp == current->format->BitsPerPixel ) 
	{
		video = current;
	} 
	else 
	{
		bpp = m_dispProps.cBPP;		
		
		if(m_dispProps.ffFormat | kfDirect565)
		{
			/* 5-6-5 */
			Rmask = 0x0000f800;
			Gmask = 0x000007e0;
			Bmask = 0x0000001f;
		}
		else if(m_dispProps.ffFormat | kfDirect555)
		{
			/* 5-5-5 */
			Rmask = 0x00007c00;
			Gmask = 0x000003e0;
			Bmask = 0x0000001f;
		}
		else if(m_dispProps.ffFormat | kfDirect888)
		{
			/* 8-8-8 */
			Rmask = 0x00ff0000;
			Gmask = 0x0000ff00;
			Bmask = 0x000000ff;
		}
			
		video = SDL_CreateRGBSurface(SDL_SWSURFACE,
					0, 0, bpp, Rmask, Gmask, Bmask, 0);

		if ( video == NULL ) 
		{
			SDL_OutOfMemory();
			return(NULL);
		}
	}

	if( flags & SDL_FULLSCREEN ) 
	{
		//maks: native resolution only
		width  = m_dispProps.cxWidth;
		height = m_dispProps.cyHeight;
	}
#endif //_USE_POCKET_HAL_


	/* See whether or not we should center the window */
	was_visible = IsWindowVisible(SDL_Window);

	/* Fill in part of the video surface */
	prev_flags = video->flags;
	video->flags = 0;	/* Clear flags */
	video->w = width;
	video->h = height;
	video->pitch = SDL_CalculatePitch(video);

	 /* Stuff to hide that $#!^%#$ WinCE taskbar in fullscreen... */
	if ( flags & SDL_FULLSCREEN ) 
	{
		if ( !(prev_flags & SDL_FULLSCREEN) )
		{
			SHFullScreen(SDL_Window, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);			
			bShowTaskBar = 0;
		}
		video->flags |= SDL_FULLSCREEN;
	} 
	else 
	{
		if ( prev_flags & SDL_FULLSCREEN ) 
		{
			SHFullScreen(SDL_Window, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
			bShowTaskBar = 1;
		}
	}



#ifndef NO_CHANGEDISPLAYSETTINGS
	/* Set fullscreen mode if appropriate */
	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
		DEVMODE settings;

		memset(&settings, 0, sizeof(DEVMODE));
		settings.dmSize = sizeof(DEVMODE);
		settings.dmBitsPerPel = video->format->BitsPerPixel;
		settings.dmPelsWidth = width;
		settings.dmPelsHeight = height;
		settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
		if ( ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL ) {
			video->flags |= SDL_FULLSCREEN;
			SDL_fullscreen_mode = settings;
		}
	}
#endif /* !NO_CHANGEDISPLAYSETTINGS */

	
	

	style = GetWindowLong(SDL_Window, GWL_STYLE);
	style &= ~(resizestyle|WS_MAXIMIZE);

	if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) 
	{
		style &= ~windowstyle;
		style |= directstyle;
	} 
	else 
	{
#ifndef NO_CHANGEDISPLAYSETTINGS
		if ( (prev_flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) 
		{
			ChangeDisplaySettings(NULL, 0);
		}
#endif
		if ( flags & SDL_NOFRAME ) 
		{
			style &= ~windowstyle;
			style |= directstyle;
			video->flags |= SDL_NOFRAME;
		} 
		else 
		{
			style &= ~directstyle;
			style |= windowstyle;

			if ( flags & SDL_RESIZABLE ) 
			{
				style |= resizestyle;
				video->flags |= SDL_RESIZABLE;
			}
		}
#if WS_MAXIMIZE
		if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
#endif
	}

	/* DJM: Don't piss of anyone who has setup his own window */
	if (!SDL_windowid)
		SetWindowLong(SDL_Window, GWL_STYLE, style);	
	

	/* Resize the window */
	if ( SDL_windowid == NULL ) 
	{
		
		HWND top;
		UINT swp_flags;
		//RECT bounds; //Aways full screen, don't need calculate the bounds

		int realW = width, realH = height, screenW, screenH;

		GetPokcetPCScreenDimensions(&screenW, &screenH);

		if(width > height && screenW < screenH)
		{
			//Rotate
			realW = height;
			realH = width;
		}

		SDL_resizing = 1;
		/*bounds.left = 0;
		bounds.top = 0;
		bounds.right = realW;
		bounds.bottom = realH;
		AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0); //If need to use, consider the system screen rotation
		realW = bounds.right-bounds.left;
		realH = bounds.bottom-bounds.top;*/
		x = (screenW-realW)/2;
		y = (screenH-realH)/2;


		//if(x < 0 || y < 0) //maks: to avoid crash when run a 480x640 game in a 240x320 device
		if((realW != screenW && 2*realW != screenW) ||
		   (realH != screenH && 2*realH != screenH)) 
		{
			//maks: Avoid a game running in a different system resolution,
			//but can 240x320 in a 480x640 device
			CloseGAPI();
			return NULL;
		}

	   

		if ( y < 0 ) { /* Cover up title bar for more client area */
			y -= GetSystemMetrics(SM_CYCAPTION)/2;
		}
		swp_flags = (SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_SHOWWINDOW);
		if ( was_visible && !(flags & SDL_FULLSCREEN) ) {
			swp_flags |= SWP_NOMOVE;
		}
		if ( flags & SDL_FULLSCREEN ) {
			top = HWND_TOPMOST;
		} else {
			top = HWND_NOTOPMOST;
		}

		sdlWindowSize.left = x;
		sdlWindowSize.top = y;
		sdlWindowSize.right = realW;
		sdlWindowSize.bottom = realH;

		SetWindowPos(SDL_Window, top, x, y, realW, realH, swp_flags);
		SDL_resizing = 0;
		SetForegroundWindow(SDL_Window);
	}

	/* If not fullscreen, locking is possible, but it doesn't do what 
	   the caller really expects -- if the locked surface is written to,
	   the appropriate portion of the entire screen is modified, not 
	   the application window, as we would like.
	   Note that it is still possible to write directly to display
	   memory, but the application must respect the clip list of
	   the surface.  There might be some odd timing interactions
	   involving clip list updates and background refreshing as
	   Windows moves other windows across our window.
	   We currently don't support this, even though it might be a
	   good idea since BeOS has an implementation of BDirectWindow
	   that does the same thing.  This would be most useful for
	   applications that do complete screen updates every frame.
	    -- Fixme?
	*/


	if ( (flags & SDL_FULLSCREEN) != SDL_FULLSCREEN ) {
		/* Necessary if we're going from fullscreen to window */
		#if 0
		if ( video->pixels == NULL ) {
			video->pitch = (width*video->format->BytesPerPixel);
			/* Pitch needs to be QWORD (8-byte) aligned */
			video->pitch = (video->pitch + 7) & ~7;
			video->pixels = (void *)malloc(video->h*video->pitch);
			if ( video->pixels == NULL ) {
				if ( video != current ) {
					SDL_FreeSurface(video);
				}
				SDL_OutOfMemory();
				return(NULL);
			}
		}
		#endif



		
//#if 0 /* FIXME: enable this when SDL consistently reports lost surfaces */
		if ( (flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
			video->flags |= SDL_HWSURFACE;
		} else {
			video->flags |= SDL_SWSURFACE;
		}
/*#else
		video->flags |= SDL_SWSURFACE;
#endif*/
		if ( (flags & SDL_RESIZABLE) && !(flags & SDL_NOFRAME) ) {
			video->flags |= SDL_RESIZABLE;
		}
		if ( flags & SDL_NOFRAME ) {
			video->flags |= SDL_NOFRAME;
		}
	} else {
		/* Necessary if we're going from window to fullscreen */
		if ( video->pixels != NULL ) {
			free(video->pixels);
			video->pixels = NULL;
		}
		
		video->flags |= SDL_HWSURFACE;
	}


#ifndef _USE_POCKET_HAL_
	backBuferSize = (this->hidden->m_nBufferEndOffset - this->hidden->m_nBufferStartOffset + 1)*2;
	if(!OpenGAPI((video->flags & SDL_FULLSCREEN)?1:0))
	{
		if ( video != current ) 
		{
			SDL_FreeSurface(video);
		}
		SDL_SetError("Couldn't open GAPI");
		
		return NULL;
	}

	//Go to the game, monitor task bar
	HookTaskBar();

#endif //_USE_POCKET_HAL_

#ifdef HAVE_OPENGL
	/* Set up for OpenGL */
	if ( flags & SDL_OPENGL ) 
	{
		if ( WIN_GL_SetupWindow(this) >= 0 )
		{
			video->flags |= SDL_OPENGL;
		}
	}
#endif

	/* We're live! */
	videoSurface = video;
	return(video);
}