Click here to Skip to main content
15,886,199 members
Articles / Desktop Programming / Windows Forms

MessageBoxManager - A Windows Forms component that provides enhanced MessageBox functionality

Rate me:
Please Sign up or sign in to vote.
4.92/5 (55 votes)
19 Feb 2006Ms-PL4 min read 258.3K   7.8K   171  
MessageBoxManager is a Windows Forms component that you can drag & drop into a Windows Forms project's main form, and it gives you enhanced message box functionality without forcing you to change your existing calls to any of the MessageBox.Show() overloads
/***
	MessageBoxManager - Enhanced message box functionality for .NET

	Author	:	Nishant Sivakumar
	Email	:	voidnish@gmail.com	
	Blog	:	http://blog.voidnish.com
	Web		:	http://www.voidnish.com 	

	You may freely use this code as long as you include
	this copyright. 
	
	You may freely modify and use this code as long
	as you include this copyright in your modified version. 

	This code is provided "as is" without express or implied warranty. 
	
	Copyright � Nishant Sivakumar, 2006.
	All Rights Reserved.
***/

#pragma once

#ifdef MESSAGEBOXHOOK_EXPORTS
#define MESSAGEBOXHOOK_API __declspec(dllexport)
#else
#define MESSAGEBOXHOOK_API __declspec(dllimport)
#endif

#include <string>

namespace std
{
#if defined UNICODE || defined _UNICODE
	typedef wstring tstring;
#else
	typedef string tstring;
#endif
}

LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam);
void SetHook(DWORD dwThreadId);
void UnHook();
bool IsHookOn();
void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
BOOL CALLBACK EnumChildProcSetFont(HWND hwnd, LPARAM lParam);
BOOL CALLBACK EnumChildProcEnableButtons(HWND hwnd, LPARAM lParam);
BOOL CALLBACK EnumChildProcStretch(HWND hwnd, LPARAM lParam);
INT_PTR CALLBACK MessageBoxProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
void SetMessageBoxManager(System::Object^ pMBM);
void ResetMessageBoxManager();
bool IsThisAMessageBox(HWND hWnd);
void StretchWindow(HWND hWnd, int percentage, BOOL bChild = FALSE);
void StretchDialog(HWND hWnd, int percentage);
void CenterWindow(HWND hWndChild, HWND hWndParent);
void SetCustomIcon(HWND hWnd);
void AddCheckBox(RECT& childRect);
int CalculateStretchPercentage();

By viewing downloads associated with this article you agree to the Terms of Service 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)


Written By
United States United States
Nish Nishant is a technology enthusiast from Columbus, Ohio. He has over 20 years of software industry experience in various roles including Chief Technology Officer, Senior Solution Architect, Lead Software Architect, Principal Software Engineer, and Engineering/Architecture Team Leader. Nish is a 14-time recipient of the Microsoft Visual C++ MVP Award.

Nish authored C++/CLI in Action for Manning Publications in 2005, and co-authored Extending MFC Applications with the .NET Framework for Addison Wesley in 2003. In addition, he has over 140 published technology articles on CodeProject.com and another 250+ blog articles on his WordPress blog. Nish is experienced in technology leadership, solution architecture, software architecture, cloud development (AWS and Azure), REST services, software engineering best practices, CI/CD, mentoring, and directing all stages of software development.

Nish's Technology Blog : voidnish.wordpress.com

Comments and Discussions