Click here to Skip to main content
15,891,529 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.5K   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	: RRPConfigurationDialog.cpp
	Date		: 
	Purpose		: It contains the code for the settings dialog box which is used to change 
				  the settings of the rss reader
	Note		: 
	Send comments 
	or Bugs to	: prafulla_t@users.sourceforge.net
*/
#include "stdafx.h"
#include "RRPConfigurationDialog.h"
#include <string>



LRESULT RRPConfigurationDialog::OnCbnSelchangeNewsCombo(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	int currentSelection = newsCombo.GetCurSel();
	if(addNewsButtonIndex != currentSelection) {
		char *aText = comboEntries[currentSelection];
		NewsButtonInfo *newsButton = NULL;
		UINT n = configManager->getSize();
		for(UINT i = 0;i<n;i++) { 
			newsButton = configManager->getItem(i);
			if(newsButton)
				if(strcmp(newsButton->title,aText) == 0)
					break;
		}
		if(newsButton) {
			SetDlgItemText(IDC_TITLE,newsButton->title);
			SetDlgItemText(IDC_LINK,newsButton->link);
			return 0;
		}
	}
	SetDlgItemText(IDC_TITLE,"Enter title!");
	SetDlgItemText(IDC_LINK,"Enter link!");
	CEdit edit = GetDlgItem(IDC_TITLE);
	edit.SetFocus();
	return 0;
}

LRESULT RRPConfigurationDialog::OnEnSetfocusTitle(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	return 0;
}

LRESULT RRPConfigurationDialog::OnRemove(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) {
	unsigned int currentSelection = newsCombo.GetCurSel();
	if(currentSelection == addNewsButtonIndex)
		return 0;
	char *aText = comboEntries[currentSelection];
	NewsButtonInfo *newsButton = NULL;
	UINT n = configManager->getSize();
	UINT i = 0;
	for(i = 0;i<n;i++) { 
		newsButton = configManager->getItem(i);
		if(newsButton)
			if(strcmp(newsButton->title,aText) == 0)
				break;
	}
	if(newsButton) {
		//i specifies the index of the button,to be deleted
		configManager->getToolbar()->removeButton(i);
		newsCombo.ResetContent();
		fillComboBox();
		newsCombo.AddString("Add news button!!");
		newsCombo.SetCurSel(0);
		BOOL handled = true;
		OnCbnSelchangeNewsCombo(0,0,0,handled);
	}
	return 0;
}

LRESULT RRPConfigurationDialog::OnSave(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) {
	char *title = new char[100];
	char *link = new char[100];
	int tFlag = 0,lFlag = 0;
	GetDlgItemText(IDC_TITLE,title,100);
	GetDlgItemText(IDC_LINK,link,100);
	int currentSelection = newsCombo.GetCurSel();
	NewsButtonInfo *newsButton = configManager->getItem(currentSelection);
	int validFlag = 0;
	if(strcmp(title,"Enter title!") == 0)
		tFlag = 1;
	if(strcmp(link,"Enter link!") == 0)
		lFlag = 1;
	if(strcmp(title,"") == 0)
		tFlag = 1;
	if(strcmp(link,"") == 0)
		lFlag = 1;
	if(checkHyperLink(link) == 0) 
		validFlag = 1;
	if(tFlag && lFlag) 
		MessageBox("Enter title and link of RSS for the new Button!","Error",MB_ICONERROR);
	else if(tFlag)
			MessageBox("Enter title for the new Button!","Error",MB_ICONERROR);
		else if(lFlag && !validFlag)
				MessageBox("Enter link of RSS for the new Button!","Error",MB_ICONERROR);
	if(validFlag)
		MessageBox("Enter valid link of RSS for the new Button!","Error",MB_ICONERROR);
	if(currentSelection == addNewsButtonIndex) {
/*
	int validFlag = 0;
	if(strcmp(title,"Enter title!") == 0)
		tFlag = 1;
	if(strcmp(link,"Enter link!") == 0)
		lFlag = 1;
	if(strcmp(title,"") == 0)
		tFlag = 1;
	if(strcmp(link,"") == 0)
		lFlag = 1;
	if(checkHyperLink(link) == 0) 
		validFlag = 1;
	if(tFlag && lFlag) 
		MessageBox("Enter title and link of RSS for the new Button!","Error",MB_ICONERROR);
	else if(tFlag)
			MessageBox("Enter title for the new Button!","Error",MB_ICONERROR);
		else if(lFlag && !validFlag)
				MessageBox("Enter link of RSS for the new Button!","Error",MB_ICONERROR);
	if(validFlag)
		MessageBox("Enter valid link of RSS for the new Button!","Error",MB_ICONERROR);*/
		if(tFlag == 0 && lFlag == 0 && validFlag == 0)
			configManager->addNews(title,link);
	}
	else {
		configManager->modifyNews(currentSelection,title,link);
	}
	//Reset everything
	newsCombo.ResetContent();
	fillComboBox();
	newsCombo.AddString("Add news button!!");
	newsCombo.SetCurSel(0);
	BOOL handled = true;
	OnCbnSelchangeNewsCombo(0,0,0,handled);
	delete title,link;
	return 0;
}

//False if link is invalid
BOOL RRPConfigurationDialog::checkHyperLink(char *link) {
	if(strstr(link,"http://") == link)
		return 1;
	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)


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

Comments and Discussions