hi all,
i want to flash a screen with picture for few mins in mfc program, is there any method can do that? thanks!!
hi all,
i want to flash a screen with picture for few mins in mfc program, is there any method can do that? thanks!!
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?
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
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
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
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()]
Last edited by novacain; 05-02-2008 at 02:58 AM.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
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.