Example #1
0
//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: Creates/regisgters main window
//-----------------------------------------------------------------------------
int WINAPI WinMain(	HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	MSG		 msg;		// generic message
	WNDCLASS winclass;	// this will hold the class created
	bool bDone = true;
	
	// save the window handle and instance in a global
	main_window_handle = SetupWindow(&winclass, hInstance);
	main_instance      = hInstance;

	ShowWindow(main_window_handle,nCmdShow);
	UpdateWindow(main_window_handle);
	SetFocus(main_window_handle);
	ShowCursor(FALSE);
	if( (strcmp(lpCmdLine,"debug") == 0) || (strcmp(lpCmdLine,"Debug") == 0) )
		bDebugMode = true;

	// perform all game console specific initialization
	InitDD();
	InitSprites();
	gameTimer.StartTimer();
	gameTimer2.StartTimer();
	fFrameTime=0;
	frameTimer.StartTimer();

	// enter main event loop
	while(bDone)
	{
		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
		{ 
			// test if this is a quit message
			if (msg.message == WM_QUIT)
				break;
	
			// translate any accelerator keys
			TranslateMessage(&msg);

			// send the message to the window proc
			DispatchMessage(&msg);
		} // end if
		
		if(bActiveApp)//only process frames if window is active
			bDone = main();
		else
			Sleep(10);
	
	} // end while

	ShutDown();

	// return to Windows like this
	return(msg.wParam);

} // end WinMain
Example #2
0
static int dxf_init(void)
{
    int r;

    getdimens(&dxf_driver.width, &dxf_driver.height);
    r = InitDD(1);
    if (!r)
	return r;

    if (!dx_imgparams())
	return 0;
    uiw_no_menuitems_i18n = 0;
    add_resizeitems();
    add_cutpasteitems();
    return r;
}
Example #3
0
static int dxw_init(void)
{
    int r;

    r = InitDD(0);
    if (!r)
	return r;

    if (!dx_imgparams())
	return 0;
    win32_createrootmenu();
    getres(&dxw_driver.width, &dxw_driver.height);
    uiw_no_menuitems_i18n = 0;
    add_cutpasteitems();
    return r;
}
Example #4
0
HWND CDisplayDD::Initialize( const uint32 _width, const uint32 _height, const bool _bFullscreen )
{
	m_WindowHandle = createwindow( _width, _height, _bFullscreen );
	m_ParentWindowHandle = m_WindowHandle;
	if( m_WindowHandle == 0 )
		return 0;

	//	Show or Hide cursor.
	ShowCursor( !_bFullscreen );

	if (!_bFullscreen)
	{
		RECT rcClient, rcWindow;
		POINT ptDiff;
		GetClientRect(m_WindowHandle, &rcClient);
		GetWindowRect(m_WindowHandle, &rcWindow);
		ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right;
		ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom;
		MoveWindow(m_WindowHandle, rcWindow.left, rcWindow.top, _width + ptDiff.x, _height + ptDiff.y, TRUE);
	}
	//	Get window dimensions.
	RECT rect;
    GetClientRect( m_WindowHandle, &rect );
    m_Width = rect.right;
    m_Height = rect.bottom;

    ShowWindow( m_WindowHandle, SW_SHOW );
    SetForegroundWindow( m_WindowHandle );
    SetFocus( m_WindowHandle );

	InitDD(m_WindowHandle);
	
	if (m_Width == 0 && m_Height == 0)
	{
		m_Width = m_dd.GetSize().cx;
		m_Height = m_dd.GetSize().cy;
	}

	return	m_WindowHandle;
}
Example #5
0
bool	CDisplayDD::Initialize( HWND _hWnd, bool _bPreview )
{
	m_bScreensaver = true;
	m_bPreview = _bPreview;

	HMODULE    hInstance = GetModuleHandle( NULL );

	WNDCLASS wc = {0};

	wc.style = CS_VREDRAW | CS_HREDRAW;
	wc.lpfnWndProc = (WNDPROC)CDisplayDD::wndProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = LoadIcon (GetModuleHandle(NULL), MAKEINTRESOURCE(1));
	wc.hCursor = NULL;
	wc.hbrBackground = NULL;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = L"ElectricsheepWndClass";
	RegisterClass( &wc );

	if( _bPreview )
	{
		RECT rc;
		//GetWindowRect( _hWnd, &rc );
        GetClientRect( _hWnd, &rc );
		int32 cx = rc.right - rc.left;
		int32 cy = rc.bottom - rc.top;

		g_Log->Info( "rc: %d, %d", cx, cy );

		DWORD dwStyle = WS_VISIBLE | WS_CHILD;
		AdjustWindowRect( &rc, dwStyle, FALSE );
		m_ParentWindowHandle = _hWnd;
		m_WindowHandle = CreateWindow( L"ElectricsheepWndClass", L"Preview", dwStyle, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, _hWnd, NULL, hInstance, this );

		if( m_WindowHandle == NULL )
			return false;

		m_Width = cx;
		m_Height = cy;

		g_Log->Info( "Screensaver preview (%dx%d)", cx, cy );

		// In preview mode, "pause" (enter a limited message loop) briefly before proceeding, so the display control panel knows to update itself.
		m_bWaitForInputIdleDS = true;

		// Post a message to mark the end of the initial group of window messages
		PostMessage( m_WindowHandle, WM_USER, 0, 0 );

		InvalidateRect( GetParent( _hWnd ), NULL, FALSE );    // Invalidate the hwnd so it gets drawn
		UpdateWindow( GetParent( _hWnd ) );
		UpdateWindow( GetParent( _hWnd ) );
		MSG msg;
		while( m_bWaitForInputIdleDS )
		{
			if( !GetMessage( &msg, m_WindowHandle, 0, 0 ) )
			{
				PostQuitMessage(0);
				break;
			}

			TranslateMessage( &msg );
			DispatchMessage( &msg );
		}
		InitDD( _hWnd );
		SetFocus( _hWnd );
		ShowCursor( true );
	}
	else
	{
		RECT rc;
		GetWindowRect( _hWnd, &rc );
		m_Width = rc.right;
		m_Height = rc.bottom;

		m_WindowHandle = _hWnd;
		m_ParentWindowHandle = _hWnd;
		if( m_WindowHandle == NULL )
			return false;

		g_Log->Info( "Screensaver (%dx%d)", m_Width, m_Height );

		//	Hide cursor.
		ShowCursor( false );

		InitDD( m_WindowHandle );
	}

	return true;
}