Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

WTL Toolbar Helper

, 11 Dec 2006
Add text, drop-down menus, and comboboxes to a WTL toolbar.
toolbarhelper.zip
toolbarhelpersample.zip
toolbarhelpersamples.zip
ToolbarHelperSampleVS6
Release
ToolbarHelperSampleVS6.exe
res
mainfram.bmp
toolbar.bmp
ToolbarHelperSampleVS6.exe.manifest
ToolbarHelperSampleVS6.ico
ToolbarHelperSampleVS6.dsp
ToolbarHelperSampleVS6.dsw
ToolbarHelperSample
Release
ToolbarHelperSample.exe
res
mainfram.bmp
Toolbar.bmp
ToolbarHelperSample.ico
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

#include "toolbarhelper.h"
#include "toolbarhelpersampleview.h"

#define RED	RGB(0xFF, 0x00, 0x00)
#define	GREEN	RGB(0x00, 0xFF, 0x00)
#define BLUE	RGB(0x00, 0x00, 0xFF)

class CMainFrame : public CFrameWindowImpl<CMainFrame>, public CUpdateUI<CMainFrame>,
		public CMessageFilter, public CIdleHandler,
		public CToolBarHelper<CMainFrame>
{
public:
	DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)

	CToolbarHelperSampleView m_view;
	CCommandBarCtrl m_CmdBar;
	CComboBox m_wndCombo;	

	virtual BOOL PreTranslateMessage(MSG* pMsg);
	virtual BOOL OnIdle();

	void OnToolBarCombo(HWND hWndCombo, UINT nID, int nSel, LPCTSTR lpszText, DWORD dwItemData);
	virtual void PrepareToolBarMenu(UINT nMenuID, HMENU hMenu);

	BEGIN_UPDATE_UI_MAP(CMainFrame)
		UPDATE_ELEMENT(ID_VIEW_TOOLBAR, UPDUI_MENUPOPUP)
		UPDATE_ELEMENT(ID_VIEW_STATUS_BAR, UPDUI_MENUPOPUP)
		UPDATE_ELEMENT(ID_VIEW_RED, UPDUI_MENUPOPUP)
		UPDATE_ELEMENT(ID_VIEW_GREEN, UPDUI_MENUPOPUP)
		UPDATE_ELEMENT(ID_VIEW_BLUE, UPDUI_MENUPOPUP)
	END_UPDATE_UI_MAP()

	BEGIN_MSG_MAP(CMainFrame)
		MESSAGE_HANDLER(WM_CREATE, OnCreate)
		COMMAND_ID_HANDLER(ID_APP_EXIT, OnFileExit)
		COMMAND_ID_HANDLER(ID_FILE_NEW, OnFileNew)
		COMMAND_ID_HANDLER(ID_VIEW_TOOLBAR, OnViewToolBar)
		COMMAND_ID_HANDLER(ID_VIEW_STATUS_BAR, OnViewStatusBar)
		COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)
		COMMAND_ID_HANDLER(ID_VIEW_RED, OnViewColour)
		COMMAND_ID_HANDLER(ID_VIEW_GREEN, OnViewColour)
		COMMAND_ID_HANDLER(ID_VIEW_BLUE, OnViewColour)
		COMMAND_ID_HANDLER(ID_VIEW_COLOUR, OnViewColourCycle)
		COMMAND_ID_HANDLER(ID_NEW_FILE, OnNewThing)
		COMMAND_ID_HANDLER(ID_NEW_DOCUMENT, OnNewThing)
		COMMAND_ID_HANDLER(ID_NEW_TEMPLATE, OnNewThing)
		CHAIN_MSG_MAP(CUpdateUI<CMainFrame>)
		CHAIN_MSG_MAP(CFrameWindowImpl<CMainFrame>)
		CHAIN_MSG_MAP(CToolBarHelper<CMainFrame>)
	END_MSG_MAP()

// Handler prototypes (uncomment arguments if needed):
//	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
//	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
//	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

	LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnFileNew(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnViewToolBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnViewStatusBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnViewColour(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnViewColourCycle(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnNewThing(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
};

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)

About the Author


| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 11 Dec 2006
Article Copyright 2006 by Rob Caldecott
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid