diff src/win32/Associate.cpp @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/Associate.cpp	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,105 @@
     1.4 +// Associate.cpp : implementation file
     1.5 +//
     1.6 +
     1.7 +#include "stdafx.h"
     1.8 +#include "resource.h"
     1.9 +#include "Associate.h"
    1.10 +#include "Reg.h"
    1.11 +
    1.12 +/////////////////////////////////////////////////////////////////////////////
    1.13 +// Associate dialog
    1.14 +
    1.15 +Associate::Associate(CWnd*pParent /*=NULL*/)
    1.16 +	: CDialog(Associate::IDD, pParent)
    1.17 +{
    1.18 +	//{{AFX_DATA_INIT(Associate)
    1.19 +	m_agb = FALSE;
    1.20 +	m_bin = FALSE;
    1.21 +	m_cgb = FALSE;
    1.22 +	m_gb  = FALSE;
    1.23 +	m_gba = FALSE;
    1.24 +	m_gbc = FALSE;
    1.25 +	m_sgb = FALSE;
    1.26 +	//}}AFX_DATA_INIT
    1.27 +}
    1.28 +
    1.29 +void Associate::DoDataExchange(CDataExchange*pDX)
    1.30 +{
    1.31 +	CDialog::DoDataExchange(pDX);
    1.32 +	//{{AFX_DATA_MAP(Associate)
    1.33 +	DDX_Check(pDX, IDC_AGB, m_agb);
    1.34 +	DDX_Check(pDX, IDC_BIN, m_bin);
    1.35 +	DDX_Check(pDX, IDC_CGB, m_cgb);
    1.36 +	DDX_Check(pDX, IDC_GB, m_gb);
    1.37 +	DDX_Check(pDX, IDC_GBA, m_gba);
    1.38 +	DDX_Check(pDX, IDC_GBC, m_gbc);
    1.39 +	DDX_Check(pDX, IDC_SGB, m_sgb);
    1.40 +	//}}AFX_DATA_MAP
    1.41 +}
    1.42 +
    1.43 +BEGIN_MESSAGE_MAP(Associate, CDialog)
    1.44 +//{{AFX_MSG_MAP(Associate)
    1.45 +ON_BN_CLICKED(ID_CANCEL, OnCancel)
    1.46 +ON_BN_CLICKED(ID_OK, OnOk)
    1.47 +//}}AFX_MSG_MAP
    1.48 +END_MESSAGE_MAP()
    1.49 +
    1.50 +/////////////////////////////////////////////////////////////////////////////
    1.51 +// Associate message handlers
    1.52 +
    1.53 +BOOL Associate::OnInitDialog()
    1.54 +{
    1.55 +	CDialog::OnInitDialog();
    1.56 +
    1.57 +	CenterWindow();
    1.58 +
    1.59 +	return TRUE; // return TRUE unless you set the focus to a control
    1.60 +	             // EXCEPTION: OCX Property Pages should return FALSE
    1.61 +}
    1.62 +
    1.63 +void Associate::OnCancel()
    1.64 +{
    1.65 +	EndDialog(FALSE);
    1.66 +}
    1.67 +
    1.68 +void Associate::OnOk()
    1.69 +{
    1.70 +	UpdateData();
    1.71 +
    1.72 +	int mask = 0;
    1.73 +	if (m_gb)
    1.74 +		mask |= 1;
    1.75 +	if (m_sgb)
    1.76 +		mask |= 2;
    1.77 +	if (m_cgb)
    1.78 +		mask |= 4;
    1.79 +	if (m_gbc)
    1.80 +		mask |= 8;
    1.81 +	if (m_gba)
    1.82 +		mask |= 16;
    1.83 +	if (m_agb)
    1.84 +		mask |= 32;
    1.85 +	if (m_bin)
    1.86 +		mask |= 64;
    1.87 +	if (mask)
    1.88 +	{
    1.89 +		char    applicationPath[2048];
    1.90 +		CString commandPath;
    1.91 +		LPCTSTR types[] = { ".gb", ".sgb", ".cgb", ".gbc", ".gba", ".agb", ".bin" };
    1.92 +		GetModuleFileName(NULL, applicationPath, 2048);
    1.93 +		commandPath.Format("\"%s\" \"%%1\"", applicationPath);
    1.94 +		regAssociateType("VisualBoyAdvance.Binary",
    1.95 +		                 "Binary",
    1.96 +		                 commandPath);
    1.97 +
    1.98 +		for (int i = 0; i < 7; i++)
    1.99 +		{
   1.100 +			if (mask & (1<<i))
   1.101 +			{
   1.102 +				regCreateFileType(types[i], "VisualBoyAdvance.Binary");
   1.103 +			}
   1.104 +		}
   1.105 +	}
   1.106 +	EndDialog(TRUE);
   1.107 +}
   1.108 +