Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. closing the splash-screen when any keyboard key is pressed

closing the splash-screen when any keyboard key is pressed

Scheduled Pinned Locked Moved C / C++ / MFC
graphicstutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Veeresh Hiremath
    wrote on last edited by
    #1

    In my start-up i have a splash-screen which waits for 30 seconds and then the main application starts up. Now i have to do this :-- Within this interval if any keyboard key is pressed i want to hide/close the splash-screeen and move to the application directly I have implemented the splash-screen as : BOOL CSplashWnd::ShowSplashScreen(UINT uTimeOut, UINT uBitmapID, CWnd* pParentWnd /*= NULL*/) { ASSERT(uTimeOut && uBitmapID); if (!m_bShowSplashWnd || m_pSplashWnd != NULL) { return FALSE; } // Allocate a new splash screen, and create the window. m_pSplashWnd = new CSplashWnd; if (!m_pSplashWnd->m_bitmap.LoadBitmap(uBitmapID)) { return FALSE; } BITMAP bm; m_pSplashWnd->m_bitmap.GetBitmap(&bm); CString strWndClass = AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)); if (!m_pSplashWnd->CreateEx(0, strWndClass, NULL, WS_POPUP | WS_VISIBLE, 0, 0, bm.bmWidth, bm.bmHeight, pParentWnd->GetSafeHwnd(), NULL)) { TRACE0("Failed to create splash screen.\n"); delete m_pSplashWnd; return FALSE; } // Center the window. m_pSplashWnd->CenterWindow(); m_pSplashWnd->UpdateWindow(); // Set a timer to destroy the splash screen. m_pSplashWnd->SetTimer(1, uTimeOut, NULL); return TRUE; } where CSplashWnd is derived from CWnd Can any body plz tell me how to do it?

    R 1 Reply Last reply
    0
    • V Veeresh Hiremath

      In my start-up i have a splash-screen which waits for 30 seconds and then the main application starts up. Now i have to do this :-- Within this interval if any keyboard key is pressed i want to hide/close the splash-screeen and move to the application directly I have implemented the splash-screen as : BOOL CSplashWnd::ShowSplashScreen(UINT uTimeOut, UINT uBitmapID, CWnd* pParentWnd /*= NULL*/) { ASSERT(uTimeOut && uBitmapID); if (!m_bShowSplashWnd || m_pSplashWnd != NULL) { return FALSE; } // Allocate a new splash screen, and create the window. m_pSplashWnd = new CSplashWnd; if (!m_pSplashWnd->m_bitmap.LoadBitmap(uBitmapID)) { return FALSE; } BITMAP bm; m_pSplashWnd->m_bitmap.GetBitmap(&bm); CString strWndClass = AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)); if (!m_pSplashWnd->CreateEx(0, strWndClass, NULL, WS_POPUP | WS_VISIBLE, 0, 0, bm.bmWidth, bm.bmHeight, pParentWnd->GetSafeHwnd(), NULL)) { TRACE0("Failed to create splash screen.\n"); delete m_pSplashWnd; return FALSE; } // Center the window. m_pSplashWnd->CenterWindow(); m_pSplashWnd->UpdateWindow(); // Set a timer to destroy the splash screen. m_pSplashWnd->SetTimer(1, uTimeOut, NULL); return TRUE; } where CSplashWnd is derived from CWnd Can any body plz tell me how to do it?

      R Offline
      R Offline
      Ranjan Shrestha
      wrote on last edited by
      #2

      Well one simple solution would be using WM_KEYDOWN message or OnKeyDown() in MFC which i hope you already know. Another way out is to use Keyboard Hook. When the splash screen is created, create a keyboard hook and use a callback function to trap any(really any) key pressed. Destroy the Splash Screen window in the callback function. And also don't forget to unhook the Keyboard callback as soon as the splash screen is destroyed (important). Refer to following functions in MSDN: SetWindowsHookEx() KeyboardProc() UnhookWindowsHookEx()

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups