SApplication::SApplication() : window(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), GetApplicationTitle(0)) { assets.Init(); window.setFramerateLimit(DEFAULT_FPS); buttonExample.Init(assets, BUTTON_EXAMPLE_LABEL); buttonExample.SetPosition(BUTTON_EXAMPLE_POS); buttonExample.handler = [&]() { ++timesPressed; window.setTitle(GetApplicationTitle(timesPressed)); }; }
void CCompositeView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { CChildFrame* pFrame = DYNAMIC_DOWNCAST( CChildFrame, GetParentFrame() ); if( !pFrame || !pFrame->IsWindowVisible() ) return; if( !GetDVController() ) return; // update the comparison doc detail sand frame CString csTitleBarText; CString csComparisonDoc = GetDVController()->GetComparisonDocController().GetComparisonDocumentTitle(); if (pFrame && !csComparisonDoc.IsEmpty()) { // do not keep setting the title text to the same stuff as it forces the tabctrl to relayout and repaint CString existingText; pFrame->GetWindowText(existingText); if (existingText != csComparisonDoc) { pFrame->GetDocument()->SetTitle(csComparisonDoc); if (csComparisonDoc.GetLength()>40) { csComparisonDoc = csComparisonDoc.Left(32); csComparisonDoc.TrimRight(L" "); csComparisonDoc += L"..."; } pFrame->SetWindowText(csComparisonDoc); } } else { // do not keep setting the title text to the same stuff as it forces the tabctrl to relayout and repaint CString existingText; pFrame->GetWindowText(existingText); if (existingText!= GetApplicationTitle()) pFrame->SetWindowText(GetApplicationTitle()); } try { if (GetDocObject()) GetDocObject()->Repaint(); } catch (...) { _ASSERTE(!_T("Catch ... How did we get here?")); } UpdateWindow(); }
void CMainFrame::OnViewToggle() { bool bToggleToClassic = !GetApp()->RevertToClassicUI(); GetApp()->SetRevertToClassicUI( bToggleToClassic ); GetApp()->ShowMessageEx(GetSafeHwnd(), L"The new application style will be applied the next time you start " + GetApplicationTitle() + L".", WsOK, WsDefault, LOG_LOCATION); }
// The main entry point int APIENTRY _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow ) { // Avoid any compiler warnings for an unused variable UNREFERENCED_PARAMETER( hPrevInstance ); // Default configuration will be with one thread g_LaunchInfo.numberOfThreads = 1; // Process the command line arguments and write valid results to globals ProcessCommandLineArguments(); // Build and get a pointer to our application title g_LaunchInfo.applicationTitle = GetApplicationTitle(); // Register our main window ATOM nWindowClassID = RegisterWindowClass( hInstance ); // Check that our registration was successful if( nWindowClassID != 0 ) { // CreateWindow accepts either a class name string or a class ID // Convert our class ID to a 32 bit class string name pointer LPCTSTR pClassName = reinterpret_cast<LPCTSTR>( MAKELRESULT( nWindowClassID, 0 ) ); // Create and initialize our main window HWND hWindow = CreateAndInitializeWindow( hInstance, pClassName, nCmdShow ); // Check that our window creation was successful if( hWindow != NULL ) { // Initialize the game and shutdown if failure if( g_Framework.Init( hInstance, hWindow, g_LaunchInfo ) ) { MSG theMessage; BOOL bGotMessage; // Drive the main windows pump until the application shuts down while( true ) { // Use PeekMessage when running so it doesn't wait. // Retrieve all window or thread messages for the current thread // and removes them from the queue. bGotMessage = PeekMessage( &theMessage, 0, 0, 0, PM_REMOVE ); // If there was a windows message, process it now if( bGotMessage ) { // Received equest to quit the application if( theMessage.message == WM_QUIT ) { // Break from the main loop and shut down break; } // Translate virtual-key messages into character messages. // If the message is translated, the return value is nonzero. // If the message is WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, or WM_SYSKEYUP, // the return value is nonzero, regardless of the translation. // If the message is not translated, the return value is zero. TranslateMessage( &theMessage ); // Dispatch the message to a window procedure. // Return value is whatever the window procedure returns. DispatchMessage( &theMessage ); } // Pump the framework g_Framework.Update(); } } else { OutputDebugString( _T("Could not initialize the game framework\n") ); } // Shutdown the game object g_Framework.Shutdown(); } else { OutputDebugString( _T("Could not create window\n") ); } UnregisterClass( pClassName, hInstance ); } else { OutputDebugString( _T("Could not register window\n") ); } return 0; }