Click here to Skip to main content
16,007,072 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralDrawing Tools Pin
Flatline22-Feb-02 10:12
Flatline22-Feb-02 10:12 
GeneralRe: Drawing Tools Pin
Mazdak22-Feb-02 10:17
Mazdak22-Feb-02 10:17 
GeneralRe: Drawing Tools Pin
Christian Graus22-Feb-02 21:40
protectorChristian Graus22-Feb-02 21:40 
GeneralRe: Drawing Tools Pin
Flatline25-Feb-02 20:32
Flatline25-Feb-02 20:32 
GeneralRe: Drawing Tools Pin
Christian Graus26-Feb-02 10:49
protectorChristian Graus26-Feb-02 10:49 
GeneralRe: Drawing Tools Pin
Flatline1-Mar-02 9:37
Flatline1-Mar-02 9:37 
GeneralATL based spash screen Pin
koteswara22-Feb-02 9:45
koteswara22-Feb-02 9:45 
GeneralRe: ATL based spash screen Pin
Paul M Watt22-Feb-02 18:15
mentorPaul M Watt22-Feb-02 18:15 
This code is off of the top of my head. I have done a few splash screens this way, I know there are other ways to accomplish this, but this has worked for me.

<br />
class CSplashDlg : public CDialogImpl<CSplashDlg><br />
{<br />
private:<br />
	int m_CurTime;<br />
	int m_DisplayTime;<br />
<br />
public:<br />
	enum { IDD = IDD_ABOUTBOX, SPLASH_TIMER = 100 };<br />
<br />
	BEGIN_MSG_MAP(CAboutDlg)<br />
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)<br />
		COMMAND_ID_HANDLER(IDOK, OnCloseCmd)<br />
		COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)<br />
		MESSAGE_HANDLER(WM_TIMER, OnTimer)<br />
		MESSAGE_HANDLER(WM_DESTROY, OnDestroy)<br />
	END_MSG_MAP()<br />
<br />
	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)<br />
	{<br />
		CenterWindow(GetParent());<br />
<br />
		m_CurTime = 0;<br />
		m_DisplayTime = 6; // 6 half-second counts equals 3 seconds before the window disappears.<br />
		//C: The timer is set for half second resolution.<br />
		this->SetTimer(SPLASH_TIMER, 500, NULL);<br />
<br />
		return TRUE;<br />
	}<br />
<br />
	LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)<br />
	{<br />
		EndDialog(wID);<br />
		return 0;<br />
	}<br />
<br />
	LRESULT OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)<br />
	{<br />
		if (SPLASH_TIMER == wParam)<br />
		{<br />
			++m_CurTime;<br />
<br />
			if (m_CurTime > m_DisplayTime)<br />
			{<br />
				this->DestroyWindow();<br />
			}<br />
		}<br />
		return TRUE;<br />
	}<br />
<br />
	LRESULT OnDestroy(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)<br />
	{<br />
		this->KillTimer(SPLASH_TIMER);<br />
		return TRUE;<br />
	}<br />
};<br />


Like I said this is off the top of my head, so you may need to fix any compiler errors that I have made. There is probably a better way to destroy the timer that I have created.

Create this dialog with a modeless call with something like this:

<br />
CSplashDlg dlgSplash;<br />
dlgSplash.ShowWindow(SW_NORMAL);<br />
<br />


With the way that it is currently written, it will disappear after 3 seconds. You can change the m_DisplayTime value in order to lengthen or shorten the time that the dialog is displayed.

ONe more thing you may want to mess around with the window styles in order to make this dialog top most and whatever else.
QuestionHow do u use AfxGetMainWnd & GetDC Pin
John Cruz22-Feb-02 9:42
John Cruz22-Feb-02 9:42 
AnswerRe: How do u use AfxGetMainWnd & GetDC Pin
Tim Smith22-Feb-02 9:46
Tim Smith22-Feb-02 9:46 
GeneralRe: How do u use AfxGetMainWnd & GetDC Pin
John Cruz22-Feb-02 10:02
John Cruz22-Feb-02 10:02 
GeneralRe: How do u use AfxGetMainWnd & GetDC Pin
John Cruz22-Feb-02 10:07
John Cruz22-Feb-02 10:07 
GeneralRe: How do u use AfxGetMainWnd & GetDC Pin
Nish Nishant22-Feb-02 10:04
sitebuilderNish Nishant22-Feb-02 10:04 
GeneralRe: How do u use AfxGetMainWnd & GetDC Pin
John Cruz22-Feb-02 18:20
John Cruz22-Feb-02 18:20 
GeneralRe: How do u use AfxGetMainWnd & GetDC Pin
Nish Nishant22-Feb-02 20:00
sitebuilderNish Nishant22-Feb-02 20:00 
Generalwinsock packet delimiter separation Pin
Kuniva22-Feb-02 7:59
Kuniva22-Feb-02 7:59 
GeneralRe: winsock packet delimiter separation Pin
Tim Smith22-Feb-02 8:18
Tim Smith22-Feb-02 8:18 
Generalopening a dialog box Pin
Rajveer22-Feb-02 7:37
Rajveer22-Feb-02 7:37 
GeneralRe: opening a dialog box Pin
Sonu Kapoor22-Feb-02 7:51
Sonu Kapoor22-Feb-02 7:51 
GeneralRe: opening a dialog box Pin
Paul M Watt22-Feb-02 8:00
mentorPaul M Watt22-Feb-02 8:00 
GeneralRe: opening a dialog box Pin
Tili2-Dec-02 22:03
Tili2-Dec-02 22:03 
GeneralRe: opening a dialog box Pin
Jon Hulatt22-Feb-02 8:06
Jon Hulatt22-Feb-02 8:06 
GeneralRe: opening a dialog box Pin
mr200322-Feb-02 11:48
mr200322-Feb-02 11:48 
GeneralThread Problems Pin
Jon Hulatt22-Feb-02 7:37
Jon Hulatt22-Feb-02 7:37 
GeneralRe: Thread Problems Pin
Paul M Watt23-Feb-02 16:10
mentorPaul M Watt23-Feb-02 16:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.