Ejemplo n.º 1
0
int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
		LPWSTR lpCmdLine, int nCmdShow) {
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

	MainWnd window;
	if (!window.getWindowHandle()) {
		// If window was not initialized, test failed
		return 1;
	}
	window.Show(nCmdShow);

	MessageBoxW(GetActiveWindow(),
			L"1. The window underneath should have label,\n"
			 "   which will provide further instructions",
			L"Instructions", MB_OK);

	MSG msg;
	while (GetMessage(&msg, NULL, 0, 0)) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	if(MessageBoxW(GetActiveWindow(), L"Was everything according to the instructions?",
			L"Test", MB_YESNO) == IDNO)
		return 1;

	return (int) msg.wParam;
}
Ejemplo n.º 2
0
void SkinDlg::DoApply()
{
    int intOld1 = Profile::intSkin1;
    int intOld2 = Profile::intSkin2;
    string str1 = Profile::strSkinDir1;
    string str2 = Profile::strSkinDir2;

    if(IsDlgButtonChecked(m_hWnd, IDC_SKIN_PLUGIN1))	Profile::intSkin1 = 0;
    else if(IsDlgButtonChecked(m_hWnd, IDC_SKIN_OTHER1))	Profile::intSkin1 = 1;

    if(IsDlgButtonChecked(m_hWnd, IDC_SKIN_PLUGIN2))	Profile::intSkin2 = 1;
    else if(IsDlgButtonChecked(m_hWnd, IDC_SKIN_WINAMP2))	Profile::intSkin2 = 0;
    else if(IsDlgButtonChecked(m_hWnd, IDC_SKIN_OTHER2))	Profile::intSkin2 = 2;

    Profile::strSkinDir1 = GetWindowString(GetDlgItem(m_hWnd, IDC_SKIN_DIR1));
    Profile::strSkinDir2 = GetWindowString(GetDlgItem(m_hWnd, IDC_SKIN_DIR2));

    // 変更されている場合
    if(intOld1 != Profile::intSkin1 || intOld2 != Profile::intSkin2
            || str1 != Profile::strSkinDir1 || str2 != Profile::strSkinDir2)
    {
        Controller* pController = Controller::GetInstance();
        if(pController)
        {
            MainWnd* pMainWnd = pController->GetWindow();
            if(pMainWnd) pMainWnd->UpdateSkin();
        }
    }
}
Ejemplo n.º 3
0
Archivo: main.cpp Proyecto: z80/chassis
int main( int argc, char * argv[] )
{
    QApplication app( argc, argv );
    MainWnd * w = new MainWnd();
    w->show();
    int res = app.exec();
    return res;
}
Ejemplo n.º 4
0
MainWnd *MainWnd::create()
{
    MainWnd *wnd = NULL;

    if (!(wnd = new MainWnd()))
        return(NULL);

    if (!wnd->handle())
    {
        delete wnd;
        return(NULL);
    }

    return(wnd);
}
Ejemplo n.º 5
0
void ConsoleWnd::OnClose (BOOL &cancel) {
	// hide the console window without destroying the handle. This keeps the 
	// messages alive in the window.
	cancel = TRUE;
	
	this->Hide ();
	
	// tell the main window to update its UI when the console window is closed.
	// For e.g. the main window will uncheck the View > Console menu item.
	_mainWindow.UpdateUI ();
}
Ejemplo n.º 6
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd){
	MSG msg;
	MainWnd mainWnd;

	THIS_INSTANCE = hInstance;

	if(MainWnd::registerCls() == NULL){
		MessageBox(NULL, _T("Unable to register main window class"), _T("curve"), MB_OK);
		return -1;
	}

	if(mainWnd.create(0, _T("curve - agnel.kurian at gmail.com"), WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, THIS_INSTANCE, NULL) == NULL){
		MessageBox(NULL, _T("Unable to create main window"), _T("curve"), MB_OK);
		return -1;
	}

	if(CurveWnd::registerCls() == NULL){
		MessageBox(NULL, _T("Unable to register curve window class"), _T("curve"), MB_OK);
		return -1;
	}

	if(mainWnd.createChildren(IDD_CONTROL) == FALSE){
		MessageBox(NULL, _T("Unable to create child windows"), _T("curve"), MB_OK);
		return -1;
	}
	mainWnd.show(nShowCmd);
	mainWnd.update();

	while(GetMessage(&msg, NULL, 0, 0)){
		if(!IsDialogMessage(mainWnd.cd.getHandle(), &msg)){
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	return msg.wParam;
}
Ejemplo n.º 7
0
//-----------------------------------------------------------------------------
// MainWndProc
//
// The window procedure for the main window, deals with the different types
// of messages received
// ----------------------------------------------------------------------------
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg,
                             WPARAM wParam, LPARAM lParam)
{
	
	// If the message is WM_NCCREATE, associate Window pointer with this window
	// Note: WM_NCCREATE is not the first message that this WndProc will process
	// What happens here is that we assigned some extra space for the window which
	// was of size of a pointer to a MainWnd object. Now in the WM_NCREATE message the
	// lParam method is actually the class structure used to make the window i.e. 
	// CREATESTRUCT. In this stucture is a pointer to a MainWnd object. SetWindowLong in
	// this usage sets the extra window data to this which can only be done on creation
	if (msg == WM_NCCREATE) {
		
		LPCREATESTRUCT cs = (LPCREATESTRUCT) lParam;
		SetWindowLong(hWnd, GWL_USERDATA, (long) cs->lpCreateParams);
	}
	// get the MainWnd structure and pass the data to that
	MainWnd* w = (MainWnd *) GetWindowLong(hWnd, GWL_USERDATA); 
	if (w)
		return w->WndProc(hWnd, msg, wParam, lParam);
	else
		return DefWindowProc(hWnd, msg, wParam, lParam);
} // --- MainWndProc ----------------------------------------------------------
Ejemplo n.º 8
0
Archivo: main.cpp Proyecto: vadmium/tul
LRESULT CALLBACK MainWnd::WindowProc(
  HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
) {
  if(WM_NCCREATE == uMsg) {
    if(!DefWindowProc(hWnd, uMsg, wParam, lParam)) {
      return FALSE;
    }
    /* Cannot find /this/ pointer if a message (e.g. WM_GETMINMAXINFO) is
    sent before this message. */
    new MainWnd(hWnd);
    return TRUE;
  }
  
  MainWnd *wnd =
    reinterpret_cast< MainWnd * >(GetWindowLong(hWnd, GWL_USERDATA));
  switch(uMsg) {
  case WM_NCDESTROY:
    delete wnd; // if NC create failed, wnd should be NULL so this is OK
    break; // chain to default handler
  
  case WM_CREATE:
    return wnd->on_create(reinterpret_cast< LPCREATESTRUCT >(lParam));
    
  case WM_DESTROY:
    wnd->on_destroy();
    return 0;
    
  case WM_PAINT:
    wnd->paint();
    return 0;
    
  case WM_COMMAND:
    wnd->on_command(HIWORD(wParam), LOWORD(wParam), reinterpret_cast< HWND >(lParam));
    return 0;
  }
  return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
Ejemplo n.º 9
0
bool OpenGLDisplay::initialize()
{
	switch( theApp.cartridgeType )
	{
	case IMAGE_GBA:
		theApp.sizeX = 240;
		theApp.sizeY = 160;
		break;
	case IMAGE_GB:
		if ( gbBorderOn )
		{
			theApp.sizeX = 256;
			theApp.sizeY = 224;
		}
		else
		{
			theApp.sizeX = 160;
			theApp.sizeY = 144;
		}
		break;
	}


	switch(theApp.videoOption)
	{
	case VIDEO_1X:
		theApp.surfaceSizeX = theApp.sizeX;
		theApp.surfaceSizeY = theApp.sizeY;
		break;
	case VIDEO_2X:
		theApp.surfaceSizeX = theApp.sizeX * 2;
		theApp.surfaceSizeY = theApp.sizeY * 2;
		break;
	case VIDEO_3X:
		theApp.surfaceSizeX = theApp.sizeX * 3;
		theApp.surfaceSizeY = theApp.sizeY * 3;
		break;
	case VIDEO_4X:
		theApp.surfaceSizeX = theApp.sizeX * 4;
		theApp.surfaceSizeY = theApp.sizeY * 4;
		break;
	case VIDEO_320x240:
	case VIDEO_640x480:
	case VIDEO_800x600:
	case VIDEO_OTHER:
		{
			if( theApp.fullScreenStretch ) {
				theApp.surfaceSizeX = theApp.fsWidth;
				theApp.surfaceSizeY = theApp.fsHeight;
			} else {
				float scaleX = (float)theApp.fsWidth / (float)theApp.sizeX;
				float scaleY = (float)theApp.fsHeight / (float)theApp.sizeY;
				float min = ( scaleX < scaleY ) ? scaleX : scaleY;
				if( theApp.fsMaxScale )
					min = ( min > (float)theApp.fsMaxScale ) ? (float)theApp.fsMaxScale : min;
				theApp.surfaceSizeX = (int)((float)theApp.sizeX * min);
				theApp.surfaceSizeY = (int)((float)theApp.sizeY * min);
			}
		}
		break;
	}

	theApp.rect.left = 0;
	theApp.rect.top = 0;
	theApp.rect.right = theApp.sizeX;
	theApp.rect.bottom = theApp.sizeY;

	theApp.dest.left = 0;
	theApp.dest.top = 0;
	theApp.dest.right = theApp.surfaceSizeX;
	theApp.dest.bottom = theApp.surfaceSizeY;

	DWORD style = WS_POPUP | WS_VISIBLE;
	DWORD styleEx = 0;

	if( theApp.videoOption <= VIDEO_4X )
		style |= WS_OVERLAPPEDWINDOW;
	else
		styleEx = 0;

	if( theApp.videoOption <= VIDEO_4X )
		AdjustWindowRectEx( &theApp.dest, style, TRUE, styleEx );
	else
		AdjustWindowRectEx( &theApp.dest, style, FALSE, styleEx );    

	int winSizeX = theApp.dest.right - theApp.dest.left;
	int winSizeY = theApp.dest.bottom - theApp.dest.top;
	int x = 0, y = 0;

	if( theApp.videoOption <= VIDEO_4X ) {
		x = theApp.windowPositionX;
		y = theApp.windowPositionY;
	} else {
		winSizeX = theApp.fsWidth;
		winSizeY = theApp.fsHeight;
	}

	// Create a window
	MainWnd *pWnd = new MainWnd;
	theApp.m_pMainWnd = pWnd;

	pWnd->CreateEx(
		styleEx,
		theApp.wndClass,
		"VisualBoyAdvance",
		style,
		x,y,winSizeX,winSizeY,
		NULL,
		0 );
	
	if (!(HWND)*pWnd) {
		winlog("Error creating Window %08x\n", GetLastError());
		return FALSE;
	}
	
	theApp.updateMenuBar();
	
	theApp.adjustDestRect();
	
	theApp.mode320Available = FALSE;
	theApp.mode640Available = FALSE;
	theApp.mode800Available = FALSE;

	CDC *dc = pWnd->GetDC();
	HDC hDC = dc->GetSafeHdc();

	PIXELFORMATDESCRIPTOR pfd = { 
		sizeof(PIXELFORMATDESCRIPTOR),
		1,                     // version number 
		PFD_DRAW_TO_WINDOW |   // support window 
		PFD_SUPPORT_OPENGL |   // support OpenGL 
		PFD_DOUBLEBUFFER,      // double buffered 
		PFD_TYPE_RGBA,         // RGBA type 
		24,                    // 24-bit color depth 
		0, 0, 0, 0, 0, 0,      // color bits ignored 
		0,                     // no alpha buffer 
		0,                     // shift bit ignored 
		0,                     // no accumulation buffer 
		0, 0, 0, 0,            // accum bits ignored 
		32,                    // 32-bit z-buffer     
		0,                     // no stencil buffer 
		0,                     // no auxiliary buffer 
		PFD_MAIN_PLANE,        // main layer 
		0,                     // reserved 
		0, 0, 0                // layer masks ignored 
	};
	
	int  iPixelFormat; 
	if( !(iPixelFormat = ChoosePixelFormat( hDC, &pfd )) ) {
		winlog( "Failed ChoosePixelFormat\n" );
		return false;
	}
	
	// obtain detailed information about
	// the device context's first pixel format
	if( !( DescribePixelFormat(
		hDC,
		iPixelFormat,
		sizeof(PIXELFORMATDESCRIPTOR),
		&pfd ) ) )
	{
		winlog( "Failed DescribePixelFormat\n" );
		return false;
	}
	
	if( !SetPixelFormat( hDC, iPixelFormat, &pfd ) ) {
		winlog( "Failed SetPixelFormat\n" );
		return false;
	}
	
	if( !( hglrc = wglCreateContext( hDC ) ) ) {
		winlog( "Failed wglCreateContext\n" );
		return false;
	}
	
	if( !wglMakeCurrent(hDC, hglrc) ) {
		winlog( "Failed wglMakeCurrent\n" );
		return false;
	}
	
	pWnd->ReleaseDC( dc );
	
	// setup 2D gl environment
	glPushAttrib( GL_ENABLE_BIT );
	glDisable( GL_DEPTH_TEST );
	glDisable( GL_CULL_FACE );
	glEnable( GL_TEXTURE_2D );

	initializeMatrices( theApp.surfaceSizeX, theApp.surfaceSizeY );

	setVSync( theApp.vsync );

#ifdef MMX
	if(!theApp.disableMMX)
		cpu_mmx = theApp.detectMMX();
	else
		cpu_mmx = 0;
#endif

	systemRedShift = 3;
	systemGreenShift = 11;
	systemBlueShift = 19;
	systemColorDepth = 32;
	theApp.fsColorDepth = 32;
	
	Init_2xSaI(32);
	
	utilUpdateSystemColorMaps();
	theApp.updateFilter();
	theApp.updateIFB();
	
	if(failed)
		return false;
	
	pWnd->DragAcceptFiles(TRUE);

	return TRUE;  
}
Ejemplo n.º 10
0
bool VBA::preInitialize()
{
	switch( cartridgeType )
	{
	case IMAGE_GBA:
		sizeX = 240;
		sizeY = 160;
		break;
	}

	switch( videoOption )
	{
	case VIDEO_1X:
		surfaceSizeX = sizeX;
		surfaceSizeY = sizeY;
		break;
	case VIDEO_2X:
		surfaceSizeX = sizeX * 2;
		surfaceSizeY = sizeY * 2;
		break;
	case VIDEO_3X:
		surfaceSizeX = sizeX * 3;
		surfaceSizeY = sizeY * 3;
		break;
	case VIDEO_4X:
		surfaceSizeX = sizeX * 4;
		surfaceSizeY = sizeY * 4;
		break;
	case VIDEO_320x240:
	case VIDEO_640x480:
	case VIDEO_800x600:
	case VIDEO_1024x768:
	case VIDEO_1280x1024:
	case VIDEO_OTHER:
		float scaleX = (float)fsWidth / sizeX;
		float scaleY = (float)fsHeight / sizeY;
		float min = ( scaleX < scaleY ) ? scaleX : scaleY;
		if( fullScreenStretch ) {
			surfaceSizeX = fsWidth;
			surfaceSizeY = fsHeight;
		} else {
			surfaceSizeX = (int)( sizeX * min );
			surfaceSizeY = (int)( sizeY * min );
		}
		break;
	}

	rect.left = 0;
	rect.top = 0;
	rect.right = sizeX;
	rect.bottom = sizeY;

	dest.left = 0;
	dest.top = 0;
	dest.right = surfaceSizeX;
	dest.bottom = surfaceSizeY;


	DWORD style = WS_POPUP | WS_VISIBLE;
	DWORD styleEx = 0;

	if( videoOption <= VIDEO_4X ) {
		style |= WS_OVERLAPPEDWINDOW;
	} else {
		styleEx = 0;
	}

	if( videoOption <= VIDEO_4X ) {
		AdjustWindowRectEx( &dest, style, TRUE, styleEx );
	} else {
		AdjustWindowRectEx( &dest, style, FALSE, styleEx );
	}

	int winSizeX = dest.right-dest.left;
	int winSizeY = dest.bottom-dest.top;

	if( videoOption > VIDEO_4X ) {
		winSizeX = fsWidth;
		winSizeY = fsHeight;
	}

	int x = 0, y = 0;

	if( videoOption <= VIDEO_4X ) {
		x = windowPositionX;
		y = windowPositionY;
	}


	// Create a window
	MainWnd *pWnd = new MainWnd;
	m_pMainWnd = pWnd;

	pWnd->CreateEx(
		styleEx,
		wndClass,
		_T(VBA_NAME_AND_SUBVERSION),
		style,
		x, y,
		winSizeX, winSizeY,
		NULL,
		0
		);

	if( !((HWND)*pWnd) ) {
		// error creating window
		return false;
	}
	pWnd->DragAcceptFiles( TRUE );
	updateMenuBar();
	adjustDestRect();

	return true;
}
Ejemplo n.º 11
0
bool DirectDrawDisplay::initialize()
{
  theApp.sizeX = 240;
  theApp.sizeY = 160;

  switch(theApp.videoOption) {
  case VIDEO_1X:
    theApp.surfaceSizeX = theApp.sizeX;
    theApp.surfaceSizeY = theApp.sizeY;
    break;
  case VIDEO_2X:
    theApp.surfaceSizeX = theApp.sizeX * 2;
    theApp.surfaceSizeY = theApp.sizeY * 2;
    break;
  case VIDEO_3X:
    theApp.surfaceSizeX = theApp.sizeX * 3;
    theApp.surfaceSizeY = theApp.sizeY * 3;
    break;
  case VIDEO_4X:
    theApp.surfaceSizeX = theApp.sizeX * 4;
    theApp.surfaceSizeY = theApp.sizeY * 4;
    break;
  case VIDEO_320x240:
  case VIDEO_640x480:
  case VIDEO_800x600:
  case VIDEO_OTHER:
    {
      int scaleX = (theApp.fsWidth / theApp.sizeX);
      int scaleY = (theApp.fsHeight / theApp.sizeY);
      int min = scaleX < scaleY ? scaleX : scaleY;
      if(theApp.fsMaxScale)
        min = min > theApp.fsMaxScale ? theApp.fsMaxScale : min;
      theApp.surfaceSizeX = theApp.sizeX * min;
      theApp.surfaceSizeY = theApp.sizeY * min;
      if(theApp.fullScreenStretch) {
        theApp.surfaceSizeX = theApp.fsWidth;
        theApp.surfaceSizeY = theApp.fsHeight;
      }
    }
    break;
  }
  
  theApp.rect.left = 0;
  theApp.rect.top = 0;
  theApp.rect.right = theApp.sizeX;
  theApp.rect.bottom = theApp.sizeY;

  theApp.dest.left = 0;
  theApp.dest.top = 0;
  theApp.dest.right = theApp.surfaceSizeX;
  theApp.dest.bottom = theApp.surfaceSizeY;

  DWORD style = WS_POPUP | WS_VISIBLE;
  DWORD styleEx = 0;
  
  if(theApp.videoOption <= VIDEO_4X)
    style |= WS_OVERLAPPEDWINDOW;
  else
    styleEx = WS_EX_TOPMOST;

  if(theApp.videoOption <= VIDEO_4X)
    AdjustWindowRectEx(&theApp.dest, style, TRUE, styleEx);
  else
    AdjustWindowRectEx(&theApp.dest, style, FALSE, styleEx);    

  int winSizeX = theApp.dest.right-theApp.dest.left;
  int winSizeY = theApp.dest.bottom-theApp.dest.top;

  int x = 0;
  int y = 0;

  if(theApp.videoOption <= VIDEO_4X) {
    x = theApp.windowPositionX;
    y = theApp.windowPositionY;
  }

  // Create a window
  MainWnd *pWnd = new MainWnd;
  theApp.m_pMainWnd = pWnd;

  pWnd->CreateEx(styleEx,
                 theApp.wndClass,
                 "VisualBoyAdvance",
                 style,
                 x,y,winSizeX,winSizeY,
                 NULL,
                 0);
  
  if (!(HWND)*pWnd) {
    winlog("Error creating Window %08x\n", GetLastError());
    return FALSE;
  }

  
  theApp.updateMenuBar();
  
  theApp.adjustDestRect();
  
  GUID *guid = NULL;
  if(theApp.ddrawEmulationOnly)
    guid = (GUID *)DDCREATE_EMULATIONONLY;

  if(theApp.pVideoDriverGUID)
    guid = theApp.pVideoDriverGUID;

  ddrawDLL = AfxLoadLibrary("DDRAW.DLL");
  HRESULT (WINAPI *DDrawCreateEx)(GUID *,LPVOID *,REFIID,IUnknown *);  
  if(ddrawDLL != NULL) {    
    DDrawCreateEx = (HRESULT (WINAPI *)(GUID *,LPVOID *,REFIID,IUnknown *))
      GetProcAddress(ddrawDLL, "DirectDrawCreateEx");

    if(DDrawCreateEx == NULL) {
      theApp.directXMessage("DirectDrawCreateEx");
      return FALSE;
    }
  } else {
    theApp.directXMessage("DDRAW.DLL");
    return FALSE;
  }

  theApp.ddrawUsingEmulationOnly = theApp.ddrawEmulationOnly;
  
  HRESULT hret = DDrawCreateEx(guid,
                               (void **)&pDirectDraw,
                               IID_IDirectDraw7,
                               NULL);
    
  if(hret != DD_OK) {
    winlog("Error creating DirectDraw object %08x\n", hret);
    if(theApp.ddrawEmulationOnly) {
      // disable emulation only setting in case of failure
      regSetDwordValue("ddrawEmulationOnly", 0);
    }
    //    errorMessage(myLoadString(IDS_ERROR_DISP_DRAWCREATE), hret);
    return FALSE;
  }

  if(theApp.ddrawDebug) {
    DDCAPS driver;
    DDCAPS hel;
    ZeroMemory(&driver, sizeof(driver));
    ZeroMemory(&hel, sizeof(hel));
    driver.dwSize = sizeof(driver);
    hel.dwSize = sizeof(hel);
    pDirectDraw->GetCaps(&driver, &hel);
    int i;
    DWORD *p = (DWORD *)&driver;
    for(i = 0; i < (int)driver.dwSize; i+=4)
      winlog("Driver CAPS %2d: %08x\n", i>>2, *p++);
    p = (DWORD *)&hel;
    for(i = 0; i < (int)hel.dwSize; i+=4)
      winlog("HEL CAPS %2d: %08x\n", i>>2, *p++);
  }
Ejemplo n.º 12
0
bool NutcrackerApp::OnInit()
{
	gParameters = std::make_unique<cz::Parameters>();
	gParameters->set(argc, argv);

    // call the base class initialization method, currently it only parses a
    // few common command-line options but it could be do more in the future
	// NOTE: Not calling it, as it will show an error message because the I try to use my own command lines
    // if ( !wxApp::OnInit() )
    //   return false;


 #if wxUSE_XPM
	wxImage::AddHandler(new wxXPMHandler);
#endif
#if wxUSE_LIBPNG
	wxImage::AddHandler(new wxPNGHandler);
#endif
#if wxUSE_LIBJPEG
	wxImage::AddHandler(new wxJPEGHandler);
#endif
#if wxUSE_GIF
	wxImage::AddHandler(new wxGIFHandler);
#endif


	//
	// Initialize image lists
	//
	for (int i = 0; i < SMALLIMG_IDX_MAX; i++)
		gImageListSmall.Add(wxArtProvider::GetBitmap(wxART_MISSING_IMAGE, wxART_OTHER, wxSize(16, 16)));
	gImageListSmall.Replace(SMALLIMG_IDX_FOLDER, wxArtProvider::GetBitmap(wxART_FOLDER, wxART_OTHER, wxSize(16, 16)));
	gImageListSmall.Replace(SMALLIMG_IDX_FILE_OTHER, wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16, 16)));
	gImageListSmall.Replace(SMALLIMG_IDX_FILE_NUT, wxBITMAP_PNG(APP_IMG_16x16_FILE_NUT));
	gImageListSmall.Replace(SMALLIMG_IDX_REFRESH, wxBITMAP_PNG(APP_IMG_16x16_REFRESH));
	gImageListSmall.Replace(SMALLIMG_IDX_FOLDER_ADD, wxBITMAP_PNG(APP_IMG_16x16_FOLDER_ADD));
	gImageListSmall.Replace(SMALLIMG_IDX_NUT, wxBITMAP_PNG(APP_IMG_16x16_NUT));
	gImageListSmall.Replace(SMALLIMG_IDX_CALLSTACK_CURRENT, wxBITMAP_PNG(APP_IMG_16x16_CALLSTACK_CURRENT));

	for (int i = 0; i < BIGIMG_IDX_NUT; i++)
		gImageList32x32.Add(wxArtProvider::GetBitmap(wxART_MISSING_IMAGE, wxART_OTHER, wxSize(32, 32)));
	gImageList32x32.Replace(BIGIMG_IDX_NUT, wxBITMAP_PNG(APP_IMG_32x32_NUT));

	gWorkspace = std::make_shared<Workspace>();
	// create the main application window
    MainWnd *mainWnd = new MainWnd();

    mainWnd->Show(true);

	if (gParameters->has("workspace"))
	{
		try
		{
			gWorkspace->load(gParameters->get("workspace"));
		}
		catch (std::exception& e)
		{
			showException(e);
		}
	}

	/*
	postAppLambdaEvent([]()
	{
		fireAppEvent(AppEventID::OpenWorkspace);
	});
	*/

	std::shared_ptr<std::function<void()>> func;

	//
	// Test project handling
	//

    // success: wxApp::OnRun() will be called which will enter the main message
    // loop and the application will run. If we returned false here, the
    // application would exit immediately.
    return true;
}
Ejemplo n.º 13
0
XERCES_CPP_NAMESPACE_USE

// ----------------------------------------------------------------------------
// WinMain
//
// Windows equivalent of main. 
// ----------------------------------------------------------------------------
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,
				   LPSTR lpCmdLine, int nCmdShow)
{
	// the message thats collected and dispatched
	MSG   Msg;
	// the name of the class to build a window
	char *ClsName = "Main window class";
	// the name printed on an individual window
	char *WndName = "Mamoview";

	CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
	// Some code thats necessary to initialise gdi, don;t know how it
	// works must just call some things in the dll
    Gdiplus::GdiplusStartupInput gdiplusStartupInput; 
	ULONG_PTR gdiplusToken; 
	Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

	try {
	 XMLPlatformUtils::Initialize();
	}
	catch (const XMLException& toCatch) {
    // Do your failure processing here
    return 1;
	}

  // Do your actual work with Xerces-C++ here.

  


	
	// Declare and initialize the application class, which contains data needed
	// to make a window in the first place
	WApplication WinApp(hInstance, ClsName, WndProc, IDR_MENU1);
	WinApp.Register();

	// // Declare a MainWnd object which represents what is seen graphically
	// and then create it
	MainWnd Wnd;
	/*HWND Create(HINSTANCE hinst,                        // application instance
		        LPCTSTR clsname,						// the name of the window class
     		    LPCTSTR wndname,						// the name of the window
	            HWND parent   = NULL,					// the parent window reference
	            DWORD dStyle  = WS_OVERLAPPEDWINDOW,	// the window style
	            DWORD dXStyle = 0,						// extended window style
		        int x         = 10,			// x position of the window
                int y         = 10,			// y position of the window
		        int width     = 300,			// width of the window
                int height    = 300);			// height of the window*/
	Wnd.Create(hInstance, ClsName, WndName, NULL, WS_OVERLAPPEDWINDOW | 
				WS_CLIPCHILDREN,WS_EX_LAYERED | WS_EX_OVERLAPPEDWINDOW );
	// Display the main window
	Wnd.Show();
	

	//prepareGraphics();
	// Process the main window's messages
	while( GetMessage(&Msg, NULL, 0, 0) )
	{
		// convert virtual key messages to character ones and put back into message queue
		TranslateMessage(&Msg);
		// send to window procedure, of which there might be a few in 1 app
		DispatchMessage(&Msg);
	}
	Gdiplus::GdiplusShutdown(gdiplusToken); 
	XMLPlatformUtils::Terminate();
	return 0;
} // --- WinMain --------------------------------------------------------------
Ejemplo n.º 14
0
LRESULT CALLBACK gameOfLife3D::MainWnd::WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
#ifdef DEBUG_MAINWND
    LOG_ENTER(SEVERITY_LEVEL_DEBUG);
    LOG(SEVERITY_LEVEL_DEBUG) << util::WMessage(util::WMessageArgs(hWnd, message, wParam, lParam));
#endif

    LRESULT result = 0;
    if (message == WM_CREATE) {
        LPCREATESTRUCT pcs = (LPCREATESTRUCT) lParam;
        MainWnd *pMainWnd = (MainWnd*) pcs->lpCreateParams;
        SetWindowLongPtr(hWnd, GWLP_USERDATA, PtrToUlong(pMainWnd));
        result = 1;
    } else {
        MainWnd *pMainWnd = reinterpret_cast<MainWnd*>(
                                static_cast<LONG_PTR>(GetWindowLongPtr(hWnd, GWLP_USERDATA)));
        bool wasHandled = false;

        if (pMainWnd) {
            switch (message) {
            case WM_COMMAND: {
                // Accelerator
                switch (LOWORD(wParam)) {
                case ID_ACCELERATOR_FPS:
                    pMainWnd->SetFPSEnable(!pMainWnd->IsFPSEnabled());
                }
            }
            result = 0;
            wasHandled = true;
            break;
            case WM_SIZE:
                if (pMainWnd->m_canvasPanel.get() != nullptr
                        && pMainWnd->m_canvasPanel->IsInitialized()) {
                    pMainWnd->m_canvasPanel->ResizeByParentResized();
                }
                break;
            case WM_NCCREATE:
                result = 1;
                wasHandled = true;
                break;
            case WM_ACTIVATE:
                if (WA_INACTIVE == LOWORD(wParam)) {
                    // do nothing
                    break;
                }
                // do SetFocus
            case WM_SETFOCUS:
                ::SetFocus(pMainWnd->m_canvasPanel->GetHWnd());
                result = 1;
                wasHandled = true;
                break;
            case WM_RIBBON_RESIZED:
                if (pMainWnd->m_canvasPanel.get() != nullptr
                        && !pMainWnd->m_canvasPanel->IsInitialized()) {
                    pMainWnd->OnCreate(hWnd, message, wParam, lParam);
                } else if (pMainWnd->m_canvasPanel->IsInitialized()) {
                    pMainWnd->m_canvasPanel->ResizeByRibbonResized(static_cast < UINT >(wParam));
                }
                result = 0;
                wasHandled = true;
                break;
            case WM_DESTROY:
                PostQuitMessage(0);
                result = 1;
                wasHandled = true;
                break;
            }
        }
        if (!wasHandled) {
            result = DefWindowProc(hWnd, message, wParam, lParam);
        }
    }

#ifdef DEBUG_MAINWND
    LOG_LEAVE(SEVERITY_LEVEL_DEBUG);
#endif
    return result;
}
Ejemplo n.º 15
0
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

	MSG msg;
	HACCEL hAccelTable;
	WNDCLASSEX wcex;

#ifdef _DEBUG
	INIT_CRT_DEBUG_REPORT();
	//_CrtSetBreakAlloc(290);
#endif

	wcex.cbSize = sizeof(WNDCLASSEX);

	wcex.style = CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc = MainWnd::WndProc;
	wcex.cbClsExtra = 0;
	wcex.cbWndExtra = 0;
	wcex.hInstance = hInstance;
	wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
	wcex.lpszMenuName = MAKEINTRESOURCE(IDC_APIGATE);
	wcex.lpszClassName = MainWnd::szClassName;
	wcex.hIconSm = wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APIGATE));

	if (!RegisterClassEx(&wcex))
	{
		return -1;
	}

	g_hInstance = hInstance;

	//if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
	//	TRACE("AfxWinInit failed.\n");

	s_hRichEdit = LoadLibrary(_T("RICHED20.DLL"));

	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);
//	if (!AfxInitRichEdit2())
//		TRACE("AfxInitRichEdit failed.\n");

	g_api = new ApiMan();
	g_svr = new SvrMan();

	if (!g_mainwnd.Create(nCmdShow))
	{
		goto _finish;
	}

	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_APIGATE));

	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

_finish:
	g_mainwnd.Destroy();
	delete g_svr;
	delete g_api;
	FreeLibrary(s_hRichEdit);
	UnregisterClass(MainWnd::szClassName, hInstance);

	return 0;// (int)msg.wParam;
}