Click here to Skip to main content
15,887,915 members
Articles / Web Development / HTML

Catch All Bugs with BugTrap!

Rate me:
Please Sign up or sign in to vote.
4.34/5 (84 votes)
31 Jan 2009MIT5 min read 1.8M   9.1K   293  
A tool that can catch unhandled errors and exceptions, and deliver error reports to remote support servers
/*
 * This is a part of the BugTrap package.
 * Copyright (c) 2005-2007 IntelleSoft.
 * All rights reserved.
 *
 * Description: Main dialog.
 * Author: Maksim Pyatkovskiy.
 *
 * This source code is only intended as a supplement to the
 * BugTrap package reference and related electronic documentation
 * provided with the product. See these sources for detailed
 * information regarding the BugTrap package.
 */

#pragma once

#include "BaseTabItem.h"

/// Forward un-handled command messages to the active tab item
#define FORWARD_TAB_MESSAGES() \
	if (uMsg == WM_COMMAND && m_nSelTabItem >= 0) \
	{ \
		CBaseTabItem* pTabItem = m_arrTabs[m_nSelTabItem].m_pItem; \
		if (pTabItem != NULL && pTabItem->m_hWnd != NULL) \
			pTabItem->SendMessage(uMsg, wParam, lParam); \
	}

/// Main dialog class.
class CMainDlg : public CDialogImpl<CMainDlg>,
				 public CMessageFilter
{
public:
	/// Dialog resource identifier.
	enum { IDD = IDD_MAIN };

	/// Override this function to filter window messages before they are dispatched to the Windows functions TranslateMessage() and DispatchMessage().
	virtual BOOL PreTranslateMessage(PMSG pMsg);

	BEGIN_MSG_MAP_EX(CMainDlg)
		MSG_WM_INITDIALOG(OnInitDialog)
		MSG_WM_SYSCOMMAND(OnSysCommand)
		MSG_WM_DESTROY(OnDestroy)
		MSG_WM_SIZE(OnSize)
		MSG_WM_ERASEBKGND(OnEraseBackground)
		COMMAND_ID_HANDLER_EX(IDCANCEL, OnCloseCmd)
		NOTIFY_CODE_HANDLER_EX(TCN_SELCHANGE, OnSelChange)
		FORWARD_TAB_MESSAGES()
	END_MSG_MAP()

	/// Close dialog and terminate application.
	void CloseDialog(int nVal);

protected:
	/// WM_INITDIALOG event handler.
	LRESULT OnInitDialog(HWND hWnd, LPARAM lParam);
	/// WM_DESTROY event handler.
	void OnDestroy();
	/// WM_SIZE event handler.
	void OnSize(UINT uType, CSize size);
	/// Close button command handler.
	void OnCloseCmd(UINT uNotifyCode, int nID, HWND hWndCtl);
	/// WM_SYSCOMMAND event handler.
	void OnSysCommand(UINT uID, CPoint point);
	/// WM_ERASEBKGND event handler.
	BOOL OnEraseBackground(HDC hdc);
	/// TCN_SELCHANGE event handler.
	LRESULT OnSelChange(LPNMHDR pnmh);
	/// WM_KEYDOWN event handler.
	void OnKeyDown(TCHAR chCode, UINT uRepCount, UINT uFlags);

	/// Tab item data.
	struct CTabItemData
	{
		/// Item runtime class.
		const CBaseRuntimeClass* m_pRuntimeClass;
		/// Pointer to item object.
		CBaseTabItem* m_pItem;
	};

	/// Index of selected tab item.
	int m_nSelTabItem;
	/// Modes tab control.
	CTabCtrl m_tcModes;
	/// Array of tab items info.
	static CTabItemData m_arrTabs[];
};

/**
 * @param hdc - handle to the device context.
 * @return nonzero if application erases the background.
 */
inline BOOL CMainDlg::OnEraseBackground(HDC /*hdc*/)
{
	return TRUE;
}

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 MIT License


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions