Click here to Skip to main content
15,881,089 members
Articles / Desktop Programming / MFC

Microsoft WORD 2007 Style Semi-transparent Minibar

Rate me:
Please Sign up or sign in to vote.
4.96/5 (13 votes)
29 Jun 2010CPOL3 min read 33.8K   815   18  
Create a very basic Microsoft WORD 2007 style semi-transparent Minibar with tooltip like behaviour
#pragma once
#include "afxwin.h"

#include "../resource.h"

#include "MiniToolBar.h"
#include "../CommandBar/CommandBarObj.h"

// CMiniToolBarDlg dialog

class CMiniToolBarDlg : public CDialog, public ICommandBarEventHandler
{
	DECLARE_DYNAMIC(CMiniToolBarDlg)

public:
	CMiniToolBarDlg(CWnd* pParent = NULL);   // standard constructor
	virtual ~CMiniToolBarDlg();

	BOOL Create();

// Dialog Data
	enum { IDD = IDD_MINI_TOOLBAR_DLG };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	virtual BOOL	OnInitDialog();

	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg LRESULT OnMouseLeave(WPARAM wp,LPARAM lp);
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);

	afx_msg void OnPaint();
	afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);

	DECLARE_MESSAGE_MAP()	

public:	

	// Sets the parent window hovering over which should show the minibar
	void SetHoverWindow(CWnd* pParent)
	{
		m_miniToolBar.SetParentWindow(pParent);
	}

	// Call this for the activation  and popping up of the mini bar 
	// after given delay time is ellapsed
	//
	// ptMousePoint	:	mouse point client coordinates
	void Activate(CPoint ptMousePoint)
	{
		m_miniToolBar.Activate(ptMousePoint);
	}

	// Sets the hover rect
	void SetHoverRect(const CRect& rcHover)
	{
		m_miniToolBar.SetHoverRect(rcHover);
	}

	// Gets the hover rect
	const CRect& GetHoverRect()
	{
		return m_miniToolBar.GetHoverRect();
	}	

	// Hides the minibar
	virtual void HideMiniBar()
	{
		m_miniToolBar.HideMiniBar();
	}

protected:
	
	// Mini Tool Bar instance
	CMiniToolBar m_miniToolBar;
	
	// Notify button event to the attached window of the command bar object
	//
	//	 nCode		: Specifies the event code
	//	 nButtonID	: Specifies the command button object ID
	//	 ptScreen		: Specifies the mouse point in screen coordinates
	//
	virtual void OnCmdBtnEvent(UINT nCode, int nButtonID, CPoint ptScreen);
	
	// Command bar object pointer
	CCommandBarObj* m_pCommandBarObj;
	// Command bar image list
	CImageList m_imgListCommandBar;	

protected:

	virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
};

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 Code Project Open License (CPOL)


Written By
Technical Lead Kotha Technologies
Bangladesh Bangladesh
If you are not in - you are out !
- Chapter 1

Comments and Discussions