コード例 #1
0
ファイル: main.cpp プロジェクト: pascaldragon/castle-engine
//-----------------------------------------------------------------------------
bool Init()
{
    try
    {
        InitGL();

        CGE_LoadLibrary();
        CGE_Open(0);
        CGE_Resize(g_windowWidth, g_windowHeight);
        CGE_SetLibraryCallbackProc(OpenGlLibraryCallback);
        CGE_SetUserInterface(true, 96);
        //CGE_LoadSceneFromFile("c:\\projects\\humanoid_stand.wrl");
        ShowOpenFileDialog();
        return true;
    }
    catch (const std::exception &e)
    {
        std::ostringstream msg;

        msg << "Application initialization failed!" << std::endl << std::endl;
        msg << e.what();

        MessageBox(g_hWnd, msg.str().c_str(), "Error", MB_ICONERROR);
        return false;
    }
}
コード例 #2
0
ファイル: main.cpp プロジェクト: eugeneloza/castle-engine
//-----------------------------------------------------------------------------
bool Init()
{
    try
    {
        InitGL();
	
	char applicationConfigDirectory[1000];
	int bytes = GetModuleFileName(NULL, applicationConfigDirectory, 1000);

        CGE_LoadLibrary();
        // Note: the log output is in
        // c:/Users/<username>/AppData/Local/cpp_winapi_library_tester/cpp_winapi_library_tester.log
        // See https://castle-engine.io/manual_log.php
        CGE_Open(ecgeofLog, g_windowWidth, g_windowHeight, 96, applicationConfigDirectory);
        CGE_SetLibraryCallbackProc(OpenGlLibraryCallback);
        CGE_SetUserInterface(true);
        //CGE_LoadSceneFromFile("c:\\projects\\humanoid_stand.wrl");
        ShowOpenFileDialog();
        return true;
    }
    catch (const std::exception &e)
    {
        std::ostringstream msg;

        msg << "Application initialization failed!" << std::endl << std::endl;
        msg << e.what();

        MessageBox(g_hWnd, msg.str().c_str(), "Error", MB_ICONERROR);
        return false;
    }
}
コード例 #3
0
ファイル: WndMain.c プロジェクト: arcanelab/WinGHCi
VOID LoadFileFromFileDialog(HWND hWnd)
{
	TCHAR FileName[MAX_PATH];

	if (ShowOpenFileDialog(hWnd, FileName)) {
		LoadFile(FileName);
	}
}
コード例 #4
0
void MainOpenFile(HWND hWnd)
{
    CHAR FileName[MAX_PATH];
    CHAR Command[2048];

    if (ShowOpenFileDialog(hWnd, FileName)) {
	wsprintf(Command, ":load %s", ExpandFileName((String)FileName));
	FireCommand(Command);
    }
}
コード例 #5
0
void SceneEditorScreenMain::OnOpenPressed(BaseObject *, void *, void *)
{
    if(EditorSettings::Instance()->GetLastOpenedCount())
    {
        Rect rect = btnOpen->GetRect();
        rect.dx = GetRect().dx / 2;
        menuPopup->InitControl(MENUID_OPEN, rect);
        AddControl(menuPopup);
    }
    else
    {
        ShowOpenFileDialog();
    }
}
コード例 #6
0
void SceneEditorScreenMain::MenuSelected(int32 menuID, int32 itemID)
{
    RemoveControl(menuPopup);
    
    switch (menuID) 
    {
        case MENUID_OPEN:
        {
            if(EOMID_OPEN == itemID)
            {
                ShowOpenFileDialog();
            }
            else
            {
                int32 lastIndex = itemID - EOMID_OPENLAST_STARTINDEX;
                String path = EditorSettings::Instance()->GetLastOpenedFile(lastIndex);
                OpenFileAtScene(path);
            }

            break;
        }
            
            
        case MENUID_CREATENODE:
        {
            CreateNode((ResourceEditor::eNodeType)itemID);
            break;
        }
                        
        case MENUID_VIEWPORT:
        {
            SetViewport((ResourceEditor::eViewportType)itemID);
            break;
        }
            
        case MENUID_EXPORTTOGAME:
        {
            ExportAs((ResourceEditor::eExportFormat)itemID);
            break;
        }
            
        default:
            break;
    }
}
コード例 #7
0
ファイル: WndMain.c プロジェクト: arcanelab/WinGHCi
VOID AddFileFromFileDialog(HWND hWnd)
{
	TCHAR FileName[MAX_PATH], RelPath[MAX_PATH], CurrentWorkingDir[MAX_PATH];
	TCHAR Command[2*MAX_PATH];

    GetCurrentDirectory(MAX_PATH,CurrentWorkingDir);

	if (ShowOpenFileDialog(hWnd, FileName)) {
		AddMruFile(FileName);
		

		PathRelativePathTo(RelPath,
                       CurrentWorkingDir,
                       FILE_ATTRIBUTE_DIRECTORY,
                       FileName,
                       FILE_ATTRIBUTE_NORMAL);


		wsprintf(Command, TEXT(":add %s"), ExpandFileName(RelPath));
		FireCommand(Command);
	}

    SetCurrentDirectory(CurrentWorkingDir);
}
コード例 #8
0
ファイル: emulator.c プロジェクト: rockcarry/ffnes
// 函数实现
int WINAPI WinMain(HINSTANCE hCurInst, HINSTANCE hPreInst, LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASS wc             = {0};
    MSG      msg            = {0};
    HWND     hwnd           = NULL;
    RECT     rect           = {0};
    char     file[MAX_PATH] = {0};
    int      w, h, x, y;
    NES      nes;

    // 注册窗口
    wc.lpfnWndProc   = WndProc;
    wc.hInstance     = hCurInst;
    wc.hIcon         = LoadIcon  (NULL, IDI_APPLICATION);
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.lpszClassName = APP_CLASS_NAME;
    wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
    if (!RegisterClass(&wc)) return FALSE;

    // 创建窗口
    hwnd = CreateWindow(
        APP_CLASS_NAME,
        APP_WND_TITLE,
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        NES_WIDTH,
        NES_HEIGHT,
        NULL,
        NULL,
        hCurInst,
        NULL);
    if (!hwnd) return FALSE;

    if (!ShowOpenFileDialog(hwnd, file))
    {
        nCmdShow = SW_HIDE;
        PostQuitMessage(0);
    }

    GetClientRect(hwnd, &rect);
    w = NES_WIDTH  + (NES_WIDTH  - rect.right );
    h = NES_HEIGHT + (NES_HEIGHT - rect.bottom);
    x = (SCREEN_WIDTH  - w) / 2;
    y = (SCREEN_HEIGHT - h) / 2;
    x = x > 0 ? x : 0;
    y = y > 0 ? y : 0;

    // 显示窗口
    MoveWindow(hwnd, x, y, w, h, FALSE);
    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);

    // init nes
    SetWindowLong(hwnd, GWL_USERDATA, (LONG)&nes);
    nes_init  (&nes, file, (DWORD)hwnd);
    nes_setrun(&nes, 1);

    // 进入消息循环
    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage (&msg);
    }

    // free nes
    nes_free(&nes);
    return TRUE;
}
コード例 #9
0
//------------------------------------------------------------------------------
// Name: DlgProc()
// Desc: Dialog box procedure.
//------------------------------------------------------------------------------
INT_PTR CALLBACK DlgProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	HRESULT	hr		= S_OK;
	HICON	hIcon	= NULL;
	RECT	rect;

	switch( uMsg )
	{
	case WM_INITDIALOG:
		
		g_hwndDialog = hwndDlg;

		//
		// Load the application icon
		//
		hIcon = LoadIcon( g_hInst, MAKEINTRESOURCE( IDI_WMAICON ) );
		if( hIcon )
		{
			SendMessage( hwndDlg, WM_SETICON, ICON_SMALL, ( LPARAM )hIcon );
			SendMessage( hwndDlg, WM_SETICON, ICON_BIG, ( LPARAM )hIcon );
		}

		GetWindowRect( hwndDlg, &rect );

		//
		// Store the Window height in a global variable for future reference
		//
		g_iDlgHeight = rect.bottom - rect.top;

        //
        // Ready to open and play a file
        //
		SetCurrentStatus( READY );
		
        //
        // Create and initialize the audio player
        //
        g_pAudioplay = new CAudioPlay;
        if( NULL == g_pAudioplay )
        {
			//
			// Creation has failed. Close the application.
			//
			SendMessage( hwndDlg, WM_CLOSE, 0,0 );
            return TRUE;
        }

		hr = g_pAudioplay->Init();
		if( FAILED(hr) )
		{
			//
			// Init has failed. Close the application.
			//
			SendMessage( hwndDlg, WM_CLOSE, 0,0 );
		}

		return TRUE;

	case WM_COMMAND:

		switch( LOWORD( wParam ) ) 
		{
		case IDC_FILENAME:

			if( EN_CHANGE == HIWORD( wParam ) )
			{
				//
                // Filename has been changed
				// Use this notification for enabling or disabling the Play button
				//
				TCHAR tszFileName[ MAX_PATH ];

				GetDlgItemText( hwndDlg, IDC_FILENAME, tszFileName, MAX_PATH );

                //
                // If filename is not empty, enable the Play button
                //
				if( _tcslen( tszFileName) > 0 )
				{
					EnableWindow( GetDlgItem( hwndDlg, IDC_PLAY ), TRUE );

					SetCurrentStatus( CLOSED );
				}
				else
				{
					EnableWindow( GetDlgItem( hwndDlg, IDC_PLAY ), FALSE );
				}
				
				SetCurrentStatus( READY );
				
				return TRUE;
			}
			
			return FALSE;

		case IDC_OPEN:

            //
            // Show the OpenFile dialog
            //
			if( ShowOpenFileDialog() )
			{
				//
				// Display the file name
				//
				SetDlgItemText( hwndDlg, IDC_FILENAME, g_ptszFileName );

				SetFocus( GetDlgItem( hwndDlg, IDC_PLAY ) );
			}

			return TRUE;
		
		case IDC_STOP:
			
			SetCurrentStatus( STOPPING );

            //
            // Stop the audio player
            //
            if( NULL != g_pAudioplay )
            {
			    hr = g_pAudioplay->Stop();
			    if( FAILED( hr ) )
			    {
				    SetCurrentStatus( g_Status );

				    TCHAR tszErrMesg[128];
                    (void)StringCchPrintf( tszErrMesg, ARRAYSIZE(tszErrMesg), _T( "Unable to Stop (hr=%#X)" ), hr );
				    MessageBox( hwndDlg, tszErrMesg, ERROR_DIALOG_TITLE, MB_OK );
			    }
            }

			return TRUE;
			
		case IDC_PAUSE:
			
            //
            // Pause the audio player
            //
            if( NULL != g_pAudioplay )
            {
			    hr = g_pAudioplay->Pause();
			    if( FAILED( hr ) )
			    {
				    TCHAR tszErrMesg[128];
                    (void)StringCchPrintf( tszErrMesg, ARRAYSIZE(tszErrMesg), _T("Unable to Pause (hr=%#X)"), hr );
				    MessageBox( hwndDlg, tszErrMesg, ERROR_DIALOG_TITLE, MB_OK );
			    }
			    else
			    {
				    SetCurrentStatus( PAUSE );
			    }
            }

			break;
		
		case IDC_PLAY:
			
			return( OnPlay() );

		case IDCANCEL:
			//
			// Close the player before exiting application
			//
            if( NULL != g_pAudioplay )
            {
			    g_pAudioplay->Exit();
			    g_pAudioplay->Release();
            }

			EndDialog( hwndDlg, wParam );

			return TRUE;
		}
		break;

	case WM_HSCROLL:

        if( NULL == g_pAudioplay )
        {
            break;
        }

		//
		// Seek only when the file is seekable
		//
		if( ( LOWORD( wParam ) == TB_THUMBTRACK || 
			  LOWORD( wParam ) == TB_BOTTOM ||
			  LOWORD( wParam ) == TB_PAGEDOWN ||
			  LOWORD( wParam ) == TB_PAGEUP ||
			  LOWORD( wParam ) == TB_TOP ) &&
            g_pAudioplay->IsSeekable() )
		{
			//
			// Set g_IsSeeking, to be referenced when thumb tracking is over
			//
			g_IsSeeking = TRUE;
		}
		else if( LOWORD( wParam ) == TB_ENDTRACK && g_pAudioplay->IsSeekable() && g_IsSeeking )
		{
			DWORD_PTR dwPos = SendDlgItemMessage( hwndDlg, IDC_SLIDER, TBM_GETPOS, 0, 0 );

			// 
			// Start the file from the new position
			//
			hr = g_pAudioplay->Start( ( QWORD )dwPos * 10000 );
			if( FAILED ( hr ) )
			{
				g_IsSeeking = FALSE;
			}
		}

		break;
	}

    return FALSE;
}