hi all,
i want to flash a screen with picture for few mins in mfc program, is there any method can do that? thanks!!
Printable View
hi all,
i want to flash a screen with picture for few mins in mfc program, is there any method can do that? thanks!!
What does "flash a screen" mean? Pop up a typical splash window or something?
I think so.
So just set a timer in the flash window after creating it for how ever long you want it up, then make the timer message kill the window.
You writing adware?
thanks for reply, actually i'm writing mfc smart device that i want to have a splash screen before the application start, but i found that traditional mfc splash screen code which just splash bitmap can't work on smart device, so i think using dialogue to set timer is right, but i dun know how to use timer on this issue, can any body help me? thanks!!
Use mfc's CWnd::SetTimer() and use OnTimer to "catch" the timer - at that point, close the window and kill the timer (CWnd::KillTimer()). Make sure you pick a unique timer ID, in case there are other timers running in the system.
--
Mats
It doesn't matter.
SetTimer will initiate a timer of n seconds. It will then either send a message or do a callback to a function of choice.
All you need to do is catch that message. MFC will call the OnTimer function when it receives such a message.
Assuming you want modless splash dlg to allow app to continue and do not want to ownerdraw image.
I would try......
Add the splash image as a bitmap resource.
Open bitmap in resource editor
Set the ID.
Insert a new dialog into project.
Open dialog in resource editor
Remove the buttons from dialog and set style required (Border = none, application window = false, topmost = true).
Set the ID.
Add a Picture control over all of dialogs client area.
In Picture boxes properties set style (type = bitmap and Image = to your images ID)
Create a class derived from CDialog for your splash screen (ie CSplashDlg) using the new dialogs ID
Add handlers for OnTimer() [WM_TIMER] and OnInitDialog() [WM_INITDIALOG]
Add header to main app
Either call CSplashDlg as local or member (in main apps InitInstance() or as required)
[edit: I would call it from the main apps InitInstance().
Remove the calls to ShowWindow(SW_MAXIMIZE) and UpdateWindow()]
[This example is CSplashDlg killing itself, you could also have the main app kill CSplashDlg when required. The running CSplashDlg would have to be a member of the main app.]
CSplashDlg::OnInitDialog()
StartTimer()
CSplashDlg::OnTimer()
//kill this one
KillTimer() [best not to leave it hanging round]
DestroyWindow() (or EndDialog if used DoModal)
[edit:
//show main app
GetParent()->ShowWindow()
GetParent()->UpdateWindow()]