Click here to Skip to main content
15,887,442 members
Articles / Desktop Programming / MFC

Pretty WinAPI Class

Rate me:
Please Sign up or sign in to vote.
4.90/5 (36 votes)
23 May 20074 min read 96.1K   2.7K   80  
New library version that is not WTL/MFC dependent
// MenuSpawn.h: interface for the CMenuSpawn class.
//
//////////////////////////////////////////////////////////////////////
/*
 * <F> CMenuSpawn.h		1.0  23/09/2003
 *
 * Copyright 2003 Francisco Campos. All rights reserved.
 * BEYONDATA  PROPRIETARY. Use is subject to license terms. </F>
 *
 *			 \|||/
 *			 |o_o|
 *	----o00o-------o00o---      
 **/


#if !defined(AFX_MENUSPAWN_H__BB6F2F01_91FA_11D1_8B78_0000B43382FE__INCLUDED_)
#define AFX_MENUSPAWN_H__BB6F2F01_91FA_11D1_8B78_0000B43382FE__INCLUDED_

#pragma once


class CMenuSpawn  
{
public:
	struct ToolBarData	
	{ // struct for toolbar resource; guess you already know it ;)
		WORD wVersion;
		WORD wWidth;			
		WORD wHeight;			
		WORD wItemCount;		
	};
	struct SpawnItem
	{
		int		iImageIdx;
		int		iCmd;
		char	cText[128];
		
	};
	struct ImageItem
	{
		int		iImageIdx;
		int		iCmd;
	};

	struct FlotMenu
	{
		int iCmd;
		int Width;
		int iSubMenu;
	};

public:
	bool IsSpawnMenu(CMenu pMenu, const int iItem, const bool bByPos);
	bool GetMenuItemText(LPSTR csText, CMenu * pMenu, const int cmd, bool bByPos);
	void SetBackBitmap(const int iRes, COLORREF crBackColor);
	void SetBackBitmap(const int iRes);
	void SetTextColor(const COLORREF crNormal, const COLORREF crSelected);
	bool FindKeyboardShortcut(UINT nChar, UINT nFlags, HMENU pMenu, LRESULT &lRes);
	bool SetFont(LOGFONT * lf);
	
	HFONT	hMenuFont, hGuiFont;
	CSize szImage;
	bool MeasureItem(LPMEASUREITEMSTRUCT lpm);
	bool DrawItem(LPDRAWITEMSTRUCT lp);
	int FindImageItem(const int cmd);
	SpawnItem * AddSpawnItem(const char * txt, const int cmd);
	void RemapMenu(HMENU pMenu);
	void AddImageItem(const int idx, WORD cmd);

	CImageCtrl ilList;
	CImageCtrl ilOther;

	COLORREF crMenuText, crMenuTextSel;
	COLORREF cr3dFace, crMenu, crHighlight, cr3dHilight, cr3dShadow, crGrayText;
	COLORREF m_clrBtnFace, m_clrBtnHilight, m_clrBtnShadow;

	int iSpawnItem;
	SpawnItem ** pSpawnItem;

	int iImageItem;
	ImageItem * pImageItem;
	FlotMenu  fltMenu;
	bool bIsPopup;
	bool bBackBitmap;
	CBitmap	bmpBack;

	bool LoadToolBarResource(unsigned int resId, UINT uBitmap=-1);
	bool AddToolBarResource(unsigned int resId, UINT uBitmap=-1);
	void EnableMenuItems(CMenu * pMenu, CWin * pParent);
	CMenuSpawn();
	CMenuSpawn(const bool _IsPopup);
	virtual ~CMenuSpawn();

protected:
	void Init();
};

#endif // !defined(AFX_MENUSPAWN_H__BB6F2F01_91FA_11D1_8B78_0000B43382FE__INCLUDED_)

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
Colombia Colombia
My name is Francisco Campos, A developer as you.I have the title of Engineer of Systems of the Universidad Autonoma de Colombia.My real Job Information Security officer, experience in security assessment, applications, and other related subjects.

Francisco.camposg@outlook.com

Comments and Discussions