Example #1
0
INT CLcNetSlctA::Query(char* sCmd, void* pData)
{
	if(0==_stricmp("Get Client Number", sCmd))
	{
		*((INT*)pData) = m_iNsck-1;
		return 0;
	}

	else if(0==_stricmp("Set Window Handle", sCmd))
	{
		m_hWnd = *((HWND*)pData);
		return 0;
	}

	else if(0==_stricmp("Set Message Value", sCmd))
	{
		m_dwMsg = *((DWORD*)pData);
		return 0;
	}

	else if(0==_stricmp("Client Close", sCmd))
	{
		struct _T
		{
			INT		n;
			SOCKET	s;
		} *t = (_T*)pData;

		SOCKET scT = t->s;
		SOCKET scH = t->s;
		LcNet_SocketClose(&scT);
		int n = Fd_Clr(scH);

		printf("Close: %d Remain: %d\n", scH, (m_iNsck-1));
		// 삭제할 소켓리스트에 등록
		ScLstClosePush(scH, n-1);

		return 0;
	}

	else if(0==_stricmp("Window Procedure", sCmd))
	{
		struct _T
		{
			HWND	hWnd;
			UINT	uMsg;
			WPARAM	wPar;
			LPARAM  lPar;
		} *t = (_T*)pData;

		return MsgProc(t->hWnd, t->uMsg, t->wPar, t->lPar);
	}

	return CLcNet::Query(sCmd, pData);
}
Example #2
0
void EngineApp::SingleLoop( void )
   {
   static double fAppTime = 0.0;
   static double fAbsoluteTime = 0.0;
   static float  fElapasedTime = 0.0f;
   MsgProc();
   GetGlobalTimer()->GetTimeValues( &fAppTime, &fAbsoluteTime, &fElapasedTime );

   OnUpdateGame( fAppTime, fElapasedTime );

   OnFrameRender( fAppTime, fElapasedTime );
   }
Example #3
0
// This is a WINDOWS dedicated function
// LATER: This function doesn't work as expected, it won't "blink" on and off, and I cann't find a solution yet
void EngineApp::FlashWhileMinimized( void )
   {
#if !defined( _WINDOWS ) && !defined( WINDOWS )
   return;
#endif

   if( !m_pWindow )
      {
      return;
      }
   HWND hwnd = GetHwnd();
   ENG_ASSERT( hwnd );
   // If the window is minized
   if( GetWindowState() & SDL_WINDOW_MINIMIZED )
      {
      GetGlobalTimer()->GetElapsedTime();
      float totalTime = 0.f;
      SDL_Event event;
      FlashWindow( hwnd, true );

      while( true )
         {
         SDL_PumpEvents();
         if( SDL_PeepEvents( &event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT ) > 0 )
            {
            // wait for processing if close or other window event is called
            if( event.type != SDL_WINDOWEVENT ||  event.type != SDL_QUIT )
               {
               MsgProc();
               }
            // Not minimized anymore, flash for once and break
            if( !( GetWindowState() & SDL_WINDOW_MINIMIZED ) )
               {
               FlashWindow( GetHwnd(), false );
               break;
               }
            }
         else // The window has no upcoming message, keep flashing 
            {
            totalTime += GetGlobalTimer()->GetElapsedTime();
            
            if( totalTime > 1.0f )
               {
               totalTime -= 1.0f;
               FlashWindow( GetHwnd(), true );
               }
            }
         }
      }

   }
Example #4
0
		bool Window::SetWindow()
		{
			UNREFERENCED_PARAMETER( hInstance );

			// Register the window class
			WNDCLASSEX wc =
			{
				sizeof( WNDCLASSEX )
				, CS_HREDRAW | CS_VREDRAW	//CS_CLASSDC
				, []( HWND hwnd , UINT msg , WPARAM wParam , LPARAM lParam )->LRESULT
				{
					auto win = Gumgine::Singleton::ThreadSingleton< Window >::GetInstance().GetPtr();
					if ( win != nullptr )
					{
						return win->MsgProc( hwnd , msg , wParam , lParam );
					}
					return NULL;
				}
					, 0
					, 0
					, hInstance//GetModuleHandle( nullptr )
					, nullptr
					, nullptr
					, nullptr	//(HBRUSH)GetStockObject(WHITE_BRUSH)
					, nullptr
					, L"Gumgine_Ver0.01"
					, nullptr
			};
			RegisterClassEx( &wc );

			RECT rc;
			SetRect( &rc , 0 , 0 , width , height );
			AdjustWindowRect( &rc , WS_OVERLAPPEDWINDOW , false );

			// Create the application's window
			this->hWnd = CreateWindow( wc.lpszClassName , titleName.c_str()
									   , WS_OVERLAPPEDWINDOW
									   , 0 , 0
									   , rc.right - rc.left , rc.bottom - rc.top
									   , nullptr
									   , nullptr
									   , wc.hInstance
									   , nullptr
									   );
			IF_NULL_MSGBOX_RETURN_FALSE( this->hWnd , L"CreateWindow Failed." );
			return true;
		}
Example #5
0
//
// class GameCodeApp::PumpUntilMessage			- Chapter 10, page 295
//
int EngineApp::PumpUntilMessage( Uint32& eventEnd, Sint32& code )
{
   SDL_Event event;
	int currentTime = timeGetTime();
	for ( ;; )
	   {
      SDL_PumpEvents();
		if ( SDL_PeepEvents( &event, 1, SDL_PEEKEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT ) > 0 )
		   {
         // it should be the event we want
			if ( event.type == eventEnd )
			   {
				SDL_PeepEvents( &event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT );
            eventEnd = event.user.type;
            code = event.user.code;
				break;
			   }
			else
			   {
            // Default processing
				MsgProc();
			   }
		   }
		else
		   {
			// Update the game views, but nothing else! ( actor & game logic state skipped ) 
			// Remember this is a modal screen.
			if ( m_pEngineLogic )
			   {
				double fAppTime = 0.0;
            double fAbsoluteTime = 0.0;
            float  fElapasedTime = 0.0f;
            GetGlobalTimer()->GetTimeValues( &fAppTime, &fAbsoluteTime, &fElapasedTime );
            m_pEngineLogic->VOnUpdate( fAppTime, fElapasedTime );
				OnFrameRender( fAppTime, fElapasedTime );
			   }
		   }
	}
	

	return 0;
}
Example #6
0
void EngineApp::MainLoop( void )
   {
   double fAppTime = 0.0;
   double fAbsoluteTime = 0.0;
   float  fElapasedTime = 0.0f;
   while( true  )
      {
      MsgProc();
      if( !m_bIsRunning )
         {
         break;
         }
      GetGlobalTimer()->GetTimeValues( &fAppTime, &fAbsoluteTime, &fElapasedTime );

      OnUpdateGame( fAppTime, fElapasedTime );
      
      OnFrameRender( fAppTime, fElapasedTime );

      }

   OnClose();
   }
Example #7
0
#include <iostream>
#include "DXWindow.h"

LRESULT MsgProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	switch ( msg )
	{
	case WM_DESTROY:
		PostQuitMessage( 0 );
		return 0;
	default:
		return DefWindowProc( hwnd, msg, wParam, lParam );
	}
}
static WNDPROC MainWndProc = []( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { return MsgProc( hwnd, msg, wParam, lParam ); };

int WINAPI WinMain( HINSTANCE appInstance, HINSTANCE prevInstance, LPSTR cmdLine, int showCmd )
{
	std::cout << "This will be a Terrain Generator!" << std::endl;

	WindowParams windowParams;
	windowParams.HInstance = appInstance;
	windowParams.Width = 800;
	windowParams.Height = 600;
	windowParams.Name = L"Randdom Terrain";
	windowParams.WndProcedure = MainWndProc;
	DXWindow* window = new DXWindow( &windowParams );

	system( "pause" );

	delete window;
Example #8
0
void CUIControl::SendMessage( SUIMsg *pMsg )
{
	MsgProc( pMsg );
}