Click here to Skip to main content
15,894,825 members
Articles / Programming Languages / C++

Napkin

Rate me:
Please Sign up or sign in to vote.
4.38/5 (4 votes)
12 Mar 20063 min read 39.1K   66   11  
A simple logging library using generic object to streams
#pragma once

#include <pstade/integral_cast.hpp>
#include "../cast/boolean_cast.hpp"
#include "../diagnostic/is_valid.hpp"
#include "../diagnostic/verify.hpp"

namespace pstade { namespace tomato {


// Any window can pretend to be a toolbar:^)

// See: WTL7.5::CFrameWindowImpl<>::AddSimpleReBarBandCtrl
namespace get_rebar_band_info_detail {


	inline int get_button_count(HWND hWnd)
	{
		return pstade::integral_cast<int>(::SendMessage(hWnd, TB_BUTTONCOUNT, 0, 0L));
	}


	inline bool get_first_item_rect(HWND hWnd, RECT& rc)
	{
		int nBtnCount = get_button_count(hWnd);
		if (nBtnCount > 0)
		{
			tomato::api_verify( tomato::boolean_cast<BOOL>(::SendMessage(hWnd, TB_GETITEMRECT, 0, (LPARAM)&rc)) );
			return true;
		}

		return false;
	}


	inline bool get_last_item_rect(HWND hWnd, RECT& rc)
	{
		int nBtnCount = get_button_count(hWnd);
		if (nBtnCount > 0)
		{
			tomato::api_verify( tomato::boolean_cast<BOOL>(::SendMessage(hWnd, TB_GETITEMRECT, nBtnCount-1, (LPARAM)&rc)) );
			return true;
		}

		return false;
	}


} // namespace get_rebar_band_info_detail


inline UINT get_rebar_band_info_cxMinChild(HWND hWnd, bool hasTitle)
{
	ATLASSERT(tomato::is_valid(hWnd));
	
	if (hasTitle)
		return 0;

	RECT rc;
	if (get_rebar_band_info_detail::get_first_item_rect(hWnd, rc))
		return rc.right;

	return 0;
}


inline UINT get_rebar_band_info_cyMinChild(HWND hWnd)
{
	ATLASSERT(tomato::is_valid(hWnd));
	
	RECT rc;
	if (get_rebar_band_info_detail::get_first_item_rect(hWnd, rc))
		return rc.bottom - rc.top;

	return 16;
}


inline UINT get_rebar_band_info_cxIdeal(HWND hWnd)
{
	ATLASSERT(tomato::is_valid(hWnd));
	
	RECT rc;
	if (get_rebar_band_info_detail::get_last_item_rect(hWnd, rc))
		return rc.right;

	return 0;
}


} } // namespace pstade::tomato

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Japan Japan
I am worried about my poor English...

Comments and Discussions