Click here to Skip to main content
15,895,011 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.9M   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: Layout manager class.
 * 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

/// Left-side alignment.
const int ALIGN_LEFT    = 0;
/// Top-side alignment.
const int ALIGN_TOP     = 0;
/// Center-side alignment.
const int ALIGN_CENTER  = 1;
/// Right-side alignment.
const int ALIGN_RIGHT   = 2;
/// Bottom-side alignment.
const int ALIGN_BOTTOM  = 2;
/// Alignment range.
const int ALIGN_RANGE   = 2;

/// Layout info block.
struct LAYOUT_INFO
{
	/// Initialize the object.
	LAYOUT_INFO(int nCtlID, int nRatioX1, int nRatioY1, int nRatioX2, int nRatioY2);

	/// Initialize the object.
	LAYOUT_INFO(void);

	/// Control ID.
	int m_nCtlID;
	/// Left coordinate ratio.
	int m_nRatioX1;
	/// Top coordinate ratio.
	int m_nRatioY1;
	/// Right coordinate ratio.
	int m_nRatioX2;
	/// Bottom coordinate ratio.
	int m_nRatioY2;
	/// Original control coordinates.
	RECT m_rcOriginal;
};

/// Window layout manager class.
class CLayoutManager
{
private:
	/// Minimal acceptable window size.
	POINT m_ptMinWindowSize;
	/// Minimal window client size.
	POINT m_ptMinClientSize;
	/// Parent window handle.
	HWND m_hwndParent;
	/// Size-box window handle.
	HWND m_hwndSizeBox;
	/// Array of control layout information.
	LAYOUT_INFO* m_arrLayout;
	/// Number of items in control layouts array.
	int m_nItemCount;

	/// Protect the class from being accidentally copied.
	CLayoutManager(const CLayoutManager& rLayoutManager);
	/// Protect the class from being accidentally copied.
	CLayoutManager& operator=(const CLayoutManager& rLayoutManager);

public:
	/// Initialize the object.
	CLayoutManager(void);
	/// Get minimal window size.
	const POINT& GetMinTrackSize(void) const;
	/// Initialize layout info blocks for child windows.
	void InitLayout(HWND hwndParent, LAYOUT_INFO arrLayout[], int nItemCount, bool bAddSizeBox = true);
	/// Apply layout information to the window.
	void ApplyLayout(void);
};

inline CLayoutManager::CLayoutManager(void)
{
	ZeroMemory(this, sizeof(*this));
}

/**
 * @return minimum window size.
 */
inline const POINT& CLayoutManager::GetMinTrackSize(void) const
{
	return m_ptMinWindowSize;
}

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