Click here to Skip to main content
15,895,777 members
Articles / Desktop Programming / MFC

Visual Studio Source Code Control Provider Switcher Add-in

Rate me:
Please Sign up or sign in to vote.
4.56/5 (2 votes)
29 May 20023 min read 76.6K   975   13  
This article shows how to create a VS Add-in that allow you to change the source code control provider
// AboutDlg.cpp : implementation file
//

#include "stdafx.h"
#include "SCCProvider.h"
#include "AboutDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog


CAboutDlg::CAboutDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CAboutDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAboutDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}


void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	DDX_Control(pDX, IDC_HYPERLINK, m_Hyperlink);
	DDX_Control(pDX, IDC_HYPERLINK_EMAIL, m_HyperlinkEmail);
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg message handlers

BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// Extra initialization
	m_Hyperlink.ModifyLinkStyle(0, CHyperLink::StyleUseHover);
	m_HyperlinkEmail.SetURL("mailto:babdulbaki@comcast.net");
	m_HyperlinkEmail.ModifyLinkStyle(0, CHyperLink::StyleDownClick);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CAboutDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CAboutDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

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
Systems Engineer
United States United States
Bassam Abdul-Baki has a Bachelor of Science (BS) degree and a Master of Science (MS) degree in Mathematics and another MS in Technology Management. He's an analyst by trade. He started out in Quality Assurance (QA) and analysis, then dabbled in Visual C++ and Visual C# programming for a while, and then came back to QA and analysis again. He's not sure where he'll be five years from now, but is looking into data analytics.

Bassam is into mathematics, technology, astronomy, archaeology, and genealogy.

Comments and Discussions