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

RSS Reader Plug-in for Internet Explorer

, 16 Jul 2007
This is a toolbar for the Internet Explorer which shows information from RSS taken from the Internet.
rssreader_exe.zip
rssreader_src.zip
RssReader_src
RRPRssFetcher
RRPRssFetcher
res
RRPRssFetcher.ico
toolbar.bmp
RRPRssFetcher.vcproj.TEKAWADE.Prafulla V Tekawade.user
RSSReaderplugin
Debug
res
RssReaderPlugin.dll.manifest
RRPComInterfaceImplementor.rgs
RssReaderPlugin.aps
RssReaderPlugin.def
RssReaderPlugin.dsp
RssReaderPlugin.dsw
RssReaderPlugin.opt
RssReaderPlugin.plg
RssReaderPlugin.tlb
RssReaderPlugin.vcproj.TEKAWADE.Prafulla V Tekawade.user
RssReaderPluginps.def
RssReaderPluginps.mk
Setup.iss
/*
	Project		: RSS Reader plugin for Internet Explorer	
	File name	: RRPToolbar.cpp
	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
*/

#include "StdAfx.h"
#include "RRPToolbar.h"
#include "RRPConfigurationDialog.h"


int RRPToolbar::referenceCount = 0;


RRPToolbar::RRPToolbar(void) {
	debug = RRPDebugInfoLogger::getInstance();
	debug->setDebug(false);
	fetcherProcessBusy = false;
	::GetSystemTimeAsFileTime(&startTime);


	configManager = new RRPConfigurationManager();
	configManager->setToolbar(this);
	
	fetcher = new RRPRssFetcher(this);
	fetcher->registerToolbar();
	
	referenceCount++;
}

//Nothing as yet!!
RRPToolbar::~RRPToolbar(void) {
	if(configManager->deleteOnClose()) {
		int n = newsButtonVector.size();
		for(int i=0;i<n;i++) {
			if(newsButtonVector[i]) 
				newsButtonVector[i]->removeRssFile(true);
		}
		fetcher->sendCleanMessage();
	}
	fetcher->unregisterToolbar();
	if(fetcher)
		delete fetcher;
	if(configManager)
		delete configManager;
	if(menuTooltip)
		delete menuTooltip;
	int n = newsButtonVector.size();
	for(int i = 0 ;i<n;i++) 
		if(newsButtonVector[i])
			delete newsButtonVector[i];
	RRPDebugInfoLogger::removeInstance();
}

HWND RRPToolbar::createToolbar(HWND parentWindowHandle,RECT area) {
	const DWORD styleCode = 
		/*Window styles:*/ WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | WS_TABSTOP |
		/*Toolbar styles:*/ TBSTYLE_TOOLTIPS | TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | TBSTYLE_LIST | TBSTYLE_CUSTOMERASE |
							TBSTYLE_WRAPABLE |
		/*Common Control styles:*/ CCS_TOP | CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE;
	/*
		CCS_NOPARENTALIGN :: This flag help put the toolbar at the proper position,
		without this flag tpp;bar is placed at the top ,on menubar,
		basically it tries to align with parent window(reflection window).
		Setting this flag prevents it from doing so..
	*/
	toolbarHandle = Create(parentWindowHandle,area,TEXT("Toolbar Window"),styleCode);
	menuTooltip = new RRPMenuTooltip();
	menuTooltip->Create(toolbarHandle,_T("DFD"),NULL,TTS_NOPREFIX | TTS_BALLOON,_T("Brief Description"));
	createButton();
	
	int n = configManager->getSize();
	for(int i = 0;i<n;i++)
		addButton(i);
	
	SetTimer(1,900000);
	return toolbarHandle;
}
void RRPToolbar::addButton(int buttonIndex) {
	RRPNewsButton *newsButton;
	
	NewsButtonInfo *buttonInfo = configManager->getItem(buttonIndex);
	if(buttonInfo == NULL)
		buttonInfo = configManager->getItem(buttonIndex);
	if(buttonInfo == NULL)
		return;
	newsButton = new RRPNewsButton();
	newsButton->setToolbar(this);
	newsButton->setBrowser(webBrowser);
	newsButton->setRssFetcher(fetcher);
	newsButton->createButton(buttonInfo->title,101 + buttonIndex,buttonInfo->title,BTNS_WHOLEDROPDOWN);
	newsButton->setMenuTooltip(menuTooltip);
	newsButtonVector.push_back(newsButton);
}
void RRPToolbar::removeButton(unsigned int buttonIndex) {
	unsigned int n = newsButtonVector.size();
	if(buttonIndex < n) {
		RRPNewsButton *newsButton = newsButtonVector[buttonIndex];
		newsButton->removeRssFile();
		DeleteButton(CommandToIndex(newsButton->getCommandID()));
		configManager->removeNews(buttonIndex);
		std::vector<RRPNewsButton *>::iterator it = newsButtonVector.begin();
		int i = 0;
		while(i != buttonIndex) {
			if(i > newsButtonVector.size())
				break;
			it++;
			i++;
		}
		newsButtonVector.erase(it);
	}
	else
		MessageBox("No Button to remove!!","Error",MB_ICONERROR);
}

void RRPToolbar::createButton() {
	int iIndex = AddStrings("Rss Reader...");
	::SendMessage(toolbarHandle, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0L);
	InsertButton(1,ID_CONFIG,TBSTYLE_BUTTON  | BTNS_AUTOSIZE ,TBSTATE_ENABLED ,0,-1,0);
	//changeButtonCaption(ID_CONFIG,"Rss Reader...");
	//Actually changeButtonCaption was modified for different purpose hence
	//copied the code of method here
	TBBUTTONINFO tbi;	
	ZeroMemory(&tbi,sizeof(tbi));
	tbi.cbSize = sizeof(TBBUTTONINFO);
	tbi.dwMask = TBIF_TEXT;
	tbi.pszText = _T("Rss Reader...");
    SetButtonInfo(ID_CONFIG, &tbi);
}


void RRPToolbar::changeButtonCaption(int buttonIndex,char *str,DWORD dwMask) {
	int n = newsButtonVector.size();
	if(buttonIndex < n) {
		newsButtonVector[buttonIndex]->changeButtonCaption(str);
	}


/*
	TBBUTTONINFO tbi;	
	//Zeroing memory before it is used is very important,
	//failing to do so might give very irritating bugs
	ZeroMemory(&tbi,sizeof(tbi));
	tbi.cbSize = sizeof(TBBUTTONINFO);
	tbi.dwMask = TBIF_TEXT;
	tbi.pszText = _T(str);
    SetButtonInfo(nID, &tbi);*/
}	   


LRESULT RRPToolbar::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
	debug->log("OnCreate got called");
	return 0;
}

LRESULT RRPToolbar::OnButtonClick(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) {
	bHandled = true;
	debug->log("OnButtonClick got called");
	return 0;
}

LRESULT RRPToolbar::OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
	bHandled = true;
	return 0;
}

LRESULT RRPToolbar::OnToolbarDropDown(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)	 {
	NMTOOLBAR* ptb = reinterpret_cast<NMTOOLBAR *>(pnmh);
	int n = newsButtonVector.size();
	for(int i = 0 ;i<n;i++) 
		newsButtonVector[i]->setButtonClicked(false);
	for(int i = 0 ;i<n;i++) 
		if(ptb->iItem == newsButtonVector[i]->getCommandID()) {
			newsButtonVector[i]->refreshNews();
			newsButtonVector[i]->OnButtonDropDown(idCtrl,pnmh,bHandled);
		}
	return 0;
}

LRESULT RRPToolbar::OnDrawItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
	DRAWITEMSTRUCT* lpDIS = reinterpret_cast<DRAWITEMSTRUCT*>(lParam);
	MenuItem *menuItem = (MenuItem *)lpDIS->itemData;
	int  n = newsButtonVector.size();
	for(int i = 0 ;i<n;i++) 
		if(menuItem->commandID == newsButtonVector[i]->getCommandID()) {
			newsButtonVector[i]->OnDrawItem(uMsg,(WPARAM)menuItem->name,lParam,bHandled);
			break;
		}
	return 0;
}

LRESULT RRPToolbar::OnMeasureItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
	MEASUREITEMSTRUCT* pmis = reinterpret_cast<MEASUREITEMSTRUCT*>(lParam);
	MenuItem *menuItem = (MenuItem *)pmis->itemData;
	int  n = newsButtonVector.size();
	for(int i = 0 ;i<n;i++) 
		if(menuItem->commandID == newsButtonVector[i]->getCommandID()) {
			newsButtonVector[i]->OnMeasureItem(uMsg, (WPARAM)menuItem->name ,lParam,bHandled);
			break;
		}
	return 0;
}

LRESULT	RRPToolbar::OnNewsFooterClick(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) {
	int n = newsButtonVector.size();
	for(int i = 0; i<n ;i++) {
		if(newsButtonVector[i]->isButtonClicked()) {
			if(cursorPosition.x < 100)
				newsButtonVector[i]->OnPrevHotSpotClicked();
			if(cursorPosition.x > 200)
				newsButtonVector[i]->OnNextHotSpotClicked();
				
		}
	}
	return 0;
}

LRESULT	RRPToolbar::OnMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
	popupMenuHandle = ::FindWindow(_T("#32768"),NULL);
	return 0;
}

LRESULT	RRPToolbar::OnMenuSelect(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
	if(::IsWindow(popupMenuHandle)) {
		::GetCursorPos(&cursorPosition);
		::MapWindowPoints(NULL,popupMenuHandle,&cursorPosition,1);
	}
	int n = 0;
	RECT desktopRect;
	::GetWindowRect(::GetDesktopWindow(),&desktopRect);
	RECT rt;
	::GetWindowRect(popupMenuHandle,&rt);
	POINT pt;
/*	if(rt.right < desktopRect.right*0.50)
		pt.x = rt.right;
	else
		pt.x = rt.left;*/
	pt.x = rt.right;
	pt.y = rt.top+cursorPosition.y;
	n = newsButtonVector.size();
	for(int i = 0; i < n ;i++) {
		if(newsButtonVector[i]->isButtonClicked()) {
			newsButtonVector[i]->setMenuHandle(popupMenuHandle);
			newsButtonVector[i]->OnMenuSelect(reinterpret_cast<WPARAM>(&pt),wParam, lParam, bHandled);
		}
	}
	return 0;
}
//Menu clicked by the user
LRESULT	RRPToolbar::OnMenuClick(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) {
	int n = newsButtonVector.size();
	for(int i = 0; i<n ;i++) {
		if(newsButtonVector[i]->isButtonClicked()) {
			newsButtonVector[i]->OnMenuClick(wNotifyCode,wID,hWndCtl,bHandled);
		}
	}
	return 0;
}

//Rss Reader clicked by the user
LRESULT RRPToolbar::OnConfig(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) {
	RRPConfigurationDialog configDialog(this);
	configDialog.DoModal();
	return 0;
}

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

PrafullaT

India India
Quote : "Life is all about solving problems and enjoying their solutions !! "

| Advertise | Privacy | Mobile
Web02 | 2.8.140718.1 | Last Updated 17 Jul 2007
Article Copyright 2007 by PrafullaT
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid