Click here to Skip to main content
15,895,256 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/candy/set.hpp>
#include "./get_menu_item_count.hpp"
#include "./get_menu_item_id.hpp"

namespace pstade { namespace tomato {


#if !defined(_WIN32_WCE)

	inline BOOL modify_menu(HMENU hMenu, UINT uPosition, UINT uFlags, UINT uIDNewItem = 0, LPCTSTR lpNewItem = NULL)
	{
		return ::ModifyMenu(hMenu, uPosition, uFlags, uIDNewItem, lpNewItem);
	}

#else

	inline BOOL modify_menu(HMENU hMenu, UINT uPosition, UINT uFlags, UINT uIDNewItem = 0, LPCTSTR lpNewItem = NULL)
	{
		// See: wec400/STANDARDSDK/Mfc/Src/wcealt.cpp

		// Handle MF_BYCOMMAND case; MF_BYCOMMAND is 0
		if ((uFlags & MF_BYPOSITION) != MF_BYPOSITION) {
			int count = tomato::get_menu_item_count(hMenu);
			int pos = 0;

			while (uPosition != tomato::get_menu_item_id(hMenu, pos) && (pos < count))
				++pos;

			ATLASSERT(pos < count);

			uPosition = pos;
			candy::set(uFlags, MF_BYPOSITION);
		}

		if (!::DeleteMenu(hMenu, uPosition, uFlags))
			return FALSE;

		return ::InsertMenu(hMenu, uPosition, uFlags, uIDNewItem, lpNewItem);
	}

#endif // !defined(_WIN32_WCE)


} } // 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