Click here to Skip to main content
15,892,199 members
Articles / Desktop Programming / MFC

Visual Studio Bookmark Saver Add-In

Rate me:
Please Sign up or sign in to vote.
4.69/5 (8 votes)
6 Feb 2000 91.4K   1.5K   36  
Visual Studio add-in which saves and restores bookmarks after closing and re-opening a file.
// OptionsDialog.cpp : implementation file
//
// Copyright (C) 1998, 1999, 2000   Jignesh Patel
// All rights reserved. May not be sold for profit.

#include "stdafx.h"
#include "resource.h"
#include "OptionsDialog.h"
#include "BookMarkSheet.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// COptionsDialog property page

IMPLEMENT_DYNCREATE(COptionsDialog, CPropertyPage)

COptionsDialog::COptionsDialog() : CPropertyPage(COptionsDialog::IDD)
{
	//{{AFX_DATA_INIT(COptionsDialog)
	m_bEnableAddIn			= FALSE;
	m_bSaveOnClose			= FALSE;
	m_bSaveOnSave			= FALSE;
	//}}AFX_DATA_INIT
	m_bEmptyList			= false;
}

COptionsDialog::~COptionsDialog()
{
}

void COptionsDialog::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(COptionsDialog)
	DDX_Control(pDX, IDC_SAVEONSAVE, m_ctrlSaveOnSave);
	DDX_Control(pDX, IDC_SAVEONCLOSE, m_ctrlSaveOnClose);
	DDX_Control(pDX, IDC_ENABLE, m_ctrlEnable);
	DDX_Check(pDX, IDC_ENABLE, m_bEnableAddIn);
	DDX_Check(pDX, IDC_SAVEONCLOSE, m_bSaveOnClose);
	DDX_Check(pDX, IDC_SAVEONSAVE, m_bSaveOnSave);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(COptionsDialog, CPropertyPage)
	//{{AFX_MSG_MAP(COptionsDialog)
	ON_BN_CLICKED(IDC_DELETEBOOKMARKFILE, OnDeleteBookMarkFile)
	ON_BN_CLICKED(IDC_ENABLE, OnEnable)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// COptionsDialog message handlers


void COptionsDialog::OnDeleteBookMarkFile() 
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	if(IDYES == AfxMessageBox("Are you sure you want to delete all bookmark locations to be restored?", MB_YESNO))
	{
		DeleteFile(m_strFileName);
		m_bEmptyList = true;
		//	Inform the other page not to show anything!
		CBookMarkSheet * pWnd = (CBookMarkSheet*)GetParent();
		if(pWnd)
			pWnd->ClearTree();
	}
}	// end void COptionsDialog::OnDeleteBookMarkFile() 

bool COptionsDialog::WriteSettingsToRegistry()
{
	return false;
}	// end bool COptionsDialog::WriteSettingsToRegistry()

void COptionsDialog::OnEnable() 
{
	UpdateData(TRUE);
	if(!m_bEnableAddIn)
	{
		//	Disable the other check boxes.
		m_ctrlSaveOnSave.EnableWindow(FALSE);
		m_ctrlSaveOnClose.EnableWindow(FALSE);
	}
	else
	{
		m_ctrlSaveOnSave.EnableWindow(TRUE);
		m_ctrlSaveOnClose.EnableWindow(TRUE);
	}
}	// end void COptionsDialog::OnEnable() 


BOOL COptionsDialog::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	if(!m_bEnableAddIn)
	{
		//	Disable the other check boxes.
		m_ctrlSaveOnSave.EnableWindow(FALSE);
		m_ctrlSaveOnClose.EnableWindow(FALSE);
	}
	else
	{
		m_ctrlSaveOnSave.EnableWindow(TRUE);
		m_ctrlSaveOnClose.EnableWindow(TRUE);
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions