Click here to Skip to main content
Click here to Skip to main content

Delay MessageBox with auto-close option

By , , 13 Aug 2002
 
#pragma once

// COkayWnd

class COkayWnd : public CWnd
{
	DECLARE_DYNAMIC(COkayWnd)

public:
	COkayWnd();
	virtual ~COkayWnd();

protected:
	DECLARE_MESSAGE_MAP()
public:		
protected:
	virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
};


class CDelayMessageBox : public CWnd
{
	DECLARE_DYNAMIC(CDelayMessageBox)

public:
	CDelayMessageBox(CWnd* pParent);
	virtual ~CDelayMessageBox();	

	enum MBIcon
	{
		MBICONNONE = 0,
		MBICONSTOP = MB_ICONSTOP,
		MBICONQUESTION = MB_ICONQUESTION,
		MBICONEXCLAMATION = MB_ICONEXCLAMATION,
		MBICONINFORMATION = MB_ICONINFORMATION
	};

	int MessageBox(LPCTSTR lpszText, int count, bool bclose = false, MBIcon icon = MBICONNONE );	

protected:
	HHOOK m_hHook;
	HWND m_hMsgBoxWnd;
	HWND m_hOK;
	int m_count;
	bool m_autoclose;	
	COkayWnd m_OkayWnd;

	static LRESULT CALLBACK CBTProc(int nCode,WPARAM wParam, LPARAM lParam);
	static BOOL CALLBACK EnumChildProc( HWND hwnd, LPARAM lParam );
	static CMapPtrToPtr m_map;

	CString FormTitle(int num);

protected:
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnTimer(UINT nIDEvent);
};


By viewing downloads associated with this article you agree to the Terms of use and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

About the Authors

Shog9
Software Developer
United States United States
Member
Poke...

Nish Sivakumar
United States United States
Member
Nish is a real nice guy who has been writing code since 1990 when he first got his hands on an 8088 with 640 KB RAM. Originally from sunny Trivandrum in India, he has been living in various places over the past few years and often thinks it’s time he settled down somewhere.
 
Nish has been a Microsoft Visual C++ MVP since October, 2002 - awfully nice of Microsoft, he thinks. He maintains an MVP tips and tricks web site - www.voidnish.com where you can find a consolidated list of his articles, writings and ideas on VC++, MFC, .NET and C++/CLI. Oh, and you might want to check out his blog on C++/CLI, MFC, .NET and a lot of other stuff - blog.voidnish.com.
 
Nish loves reading Science Fiction, P G Wodehouse and Agatha Christie, and also fancies himself to be a decent writer of sorts. He has authored a romantic comedy Summer Love and Some more Cricket as well as a programming book – Extending MFC applications with the .NET Framework.
 
Nish's latest book C++/CLI in Action published by Manning Publications is now available for purchase. You can read more about the book on his blog.
 
Despite his wife's attempts to get him into cooking, his best effort so far has been a badly done omelette. Some day, he hopes to be a good cook, and to cook a tasty dinner for his wife.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 14 Aug 2002
Article Copyright 2002 by Shog9, Nish Sivakumar
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid