Click here to Skip to main content
15,881,715 members
Articles / Desktop Programming / WTL

RSS Reader Plug-in for Internet Explorer

Rate me:
Please Sign up or sign in to vote.
5.00/5 (12 votes)
16 Jul 2007CPOL4 min read 317.2K   1.3K   32  
This is a toolbar for the Internet Explorer which shows information from RSS taken from the Internet.
/*
	Project		: RSS Reader plugin for Internet Explorer	
	File name	: RRPToolbar.h
	Date		: 
	Purpose		: This is the actula toolbar class,provides interface for creation 
				  of toolbar,It handles or forwardes all important window messages
				  related to this perticulare project
	Note		: This file was created using the CWindowImpl ATL Object Wizard
	Send comments 
	or Bugs to	: prafulla_t@users.sourceforge.net
*/


#pragma once


#include "StdAfx.h"
#include <vector>

#include <commctrl.h>
#include <atlctrls.h>

#include "RRPConfigurationManager.h"
#include "RRPDebugInfoLogger.h"
#include "RRPMenuTooltip.h"
#include "RRPNewsButton.h"
#include "RRPRssFetcher.h"
#include "Resource.h"
class RRPConfigurationManager;

#define RRP_RSSFETCH WM_USER + 10
#define RRP_FETCHCOMPLETE WM_USER + 11
#define RRP_REFRESH WM_USER + 12
#define RRP_REMOVE WM_USER + 13
#define RRP_TOOLBAR_REG WM_USER + 14
#define RRP_TOOLBAR_UNREG WM_USER + 15
#define RRP_FETCHER_PROCESS_BUSY WM_USER + 16
#define RRP_FETCHER_PROCESS_FREE WM_USER + 17
#define RRP_CLEAN WM_USER + 18



/////////////////////////////////////////////////////////////////////////////
// RRPToolbar
class RRPToolbar : public CWindowImpl<RRPToolbar, CToolBarCtrl> {
public:
	DECLARE_WND_SUPERCLASS("RRPToolbar Class", TOOLBARCLASSNAME)
	BEGIN_MSG_MAP(RRPToolbar)
		COMMAND_ID_HANDLER(ID_NEWS_FOOTER,OnNewsFooterClick)
		COMMAND_RANGE_HANDLER(ID_NEWS_ITEM_START,ID_NEWS_ITEM_START+100,OnMenuClick);
		OCM_COMMAND_ID_HANDLER(ID_CONFIG,OnConfig)
		OCM_NOTIFY_CODE_HANDLER(TBN_DROPDOWN, OnToolbarDropDown)
		MESSAGE_HANDLER(RRP_FETCHCOMPLETE,OnFetchComplete)
		MESSAGE_HANDLER(RRP_FETCHER_PROCESS_BUSY,OnProcessBusy)
		MESSAGE_HANDLER(RRP_FETCHER_PROCESS_FREE,OnProcessFree)
		MESSAGE_HANDLER(WM_DRAWITEM,OnDrawItem)                   
		MESSAGE_HANDLER(WM_MENUSELECT,OnMenuSelect)
		MESSAGE_HANDLER(WM_MEASUREITEM,OnMeasureItem)
		MESSAGE_HANDLER(WM_INITMENUPOPUP,OnMenuPopup)
		MESSAGE_HANDLER(WM_TIMER,OnTimer)
	END_MSG_MAP()

// Handler prototypes:
//  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);
	RRPToolbar(void);
	virtual ~RRPToolbar(void);

	HWND createToolbar(HWND parentWindowHadle,RECT area);
	LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	void changeButtonCaption(int nID,char * str,DWORD dwMask = TBIF_TEXT);
	void createButton();
	void addButton(int buttonIndex);
	void removeButton(unsigned int buttonIndex);

	LRESULT OnButtonClick(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnConfig(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnToolbarDropDown(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)	;
	LRESULT OnDrawItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT OnMeasureItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT	OnNewsFooterClick(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT	OnMenuClick(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
	LRESULT	OnMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	LRESULT	OnMenuSelect(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
	void setBusyFlag(bool flag) {
		fetcherProcessBusy = flag;
	}
	
	BOOL isRssFetcherProcessBusy() {
		return fetcherProcessBusy;
	}

	//Busy signal received from the process
	LRESULT OnProcessBusy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
		fetcherProcessBusy = true;
		return 0;
	}
	//Free signal received from the process
	LRESULT OnProcessFree(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
		fetcherProcessBusy = false;
		fetcher->informRSSFetcherProcess(true);
		return 0;
	}
	LRESULT OnFetchComplete(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
		fetcherProcessBusy = false;
		fetcher->informRSSFetcherProcess();
		return 0;
	}
	LRESULT	OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
		int n = newsButtonVector.size();
		for(int i=0;i<n;i++) {
			if(newsButtonVector[i]) 
				newsButtonVector[i]->removeRssFile(true);
		}
		return 0;
	}

	RRPRssFetcher *getRssFetcher() {
		return fetcher;
	};

	RRPConfigurationManager* getConfigManger() {
		return configManager;
	};


	void setBrowser(IWebBrowser2 *p) {
		webBrowser = p;
	};

	FILETIME& getStartTIme() {
		return startTime;
	};

	HWND& getPopupMenuHandle() {
		return popupMenuHandle;
	};

private :
	std::vector<RRPNewsButton *> newsButtonVector;
	RRPDebugInfoLogger *debug;
	HWND toolbarHandle;
	HWND popupMenuHandle;
	BOOL fetcherProcessBusy;
	

	RRPConfigurationManager *configManager;
	RRPMenuTooltip *menuTooltip;
	RRPRssFetcher *fetcher;
	IWebBrowser2 *webBrowser;
	
	static int referenceCount;
	FILETIME startTime;
	

	POINT cursorPosition;

};

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
India India
Quote : "Life is all about solving problems and enjoying their solutions !! "

Comments and Discussions