annotate src/win32/Associate.cpp @ 2:3549bbe597ed

adding makefile.am
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:47 -0600
parents f9f4f1b99eed
children
rev   line source
rlm@1 1 // Associate.cpp : implementation file
rlm@1 2 //
rlm@1 3
rlm@1 4 #include "stdafx.h"
rlm@1 5 #include "resource.h"
rlm@1 6 #include "Associate.h"
rlm@1 7 #include "Reg.h"
rlm@1 8
rlm@1 9 /////////////////////////////////////////////////////////////////////////////
rlm@1 10 // Associate dialog
rlm@1 11
rlm@1 12 Associate::Associate(CWnd*pParent /*=NULL*/)
rlm@1 13 : CDialog(Associate::IDD, pParent)
rlm@1 14 {
rlm@1 15 //{{AFX_DATA_INIT(Associate)
rlm@1 16 m_agb = FALSE;
rlm@1 17 m_bin = FALSE;
rlm@1 18 m_cgb = FALSE;
rlm@1 19 m_gb = FALSE;
rlm@1 20 m_gba = FALSE;
rlm@1 21 m_gbc = FALSE;
rlm@1 22 m_sgb = FALSE;
rlm@1 23 //}}AFX_DATA_INIT
rlm@1 24 }
rlm@1 25
rlm@1 26 void Associate::DoDataExchange(CDataExchange*pDX)
rlm@1 27 {
rlm@1 28 CDialog::DoDataExchange(pDX);
rlm@1 29 //{{AFX_DATA_MAP(Associate)
rlm@1 30 DDX_Check(pDX, IDC_AGB, m_agb);
rlm@1 31 DDX_Check(pDX, IDC_BIN, m_bin);
rlm@1 32 DDX_Check(pDX, IDC_CGB, m_cgb);
rlm@1 33 DDX_Check(pDX, IDC_GB, m_gb);
rlm@1 34 DDX_Check(pDX, IDC_GBA, m_gba);
rlm@1 35 DDX_Check(pDX, IDC_GBC, m_gbc);
rlm@1 36 DDX_Check(pDX, IDC_SGB, m_sgb);
rlm@1 37 //}}AFX_DATA_MAP
rlm@1 38 }
rlm@1 39
rlm@1 40 BEGIN_MESSAGE_MAP(Associate, CDialog)
rlm@1 41 //{{AFX_MSG_MAP(Associate)
rlm@1 42 ON_BN_CLICKED(ID_CANCEL, OnCancel)
rlm@1 43 ON_BN_CLICKED(ID_OK, OnOk)
rlm@1 44 //}}AFX_MSG_MAP
rlm@1 45 END_MESSAGE_MAP()
rlm@1 46
rlm@1 47 /////////////////////////////////////////////////////////////////////////////
rlm@1 48 // Associate message handlers
rlm@1 49
rlm@1 50 BOOL Associate::OnInitDialog()
rlm@1 51 {
rlm@1 52 CDialog::OnInitDialog();
rlm@1 53
rlm@1 54 CenterWindow();
rlm@1 55
rlm@1 56 return TRUE; // return TRUE unless you set the focus to a control
rlm@1 57 // EXCEPTION: OCX Property Pages should return FALSE
rlm@1 58 }
rlm@1 59
rlm@1 60 void Associate::OnCancel()
rlm@1 61 {
rlm@1 62 EndDialog(FALSE);
rlm@1 63 }
rlm@1 64
rlm@1 65 void Associate::OnOk()
rlm@1 66 {
rlm@1 67 UpdateData();
rlm@1 68
rlm@1 69 int mask = 0;
rlm@1 70 if (m_gb)
rlm@1 71 mask |= 1;
rlm@1 72 if (m_sgb)
rlm@1 73 mask |= 2;
rlm@1 74 if (m_cgb)
rlm@1 75 mask |= 4;
rlm@1 76 if (m_gbc)
rlm@1 77 mask |= 8;
rlm@1 78 if (m_gba)
rlm@1 79 mask |= 16;
rlm@1 80 if (m_agb)
rlm@1 81 mask |= 32;
rlm@1 82 if (m_bin)
rlm@1 83 mask |= 64;
rlm@1 84 if (mask)
rlm@1 85 {
rlm@1 86 char applicationPath[2048];
rlm@1 87 CString commandPath;
rlm@1 88 LPCTSTR types[] = { ".gb", ".sgb", ".cgb", ".gbc", ".gba", ".agb", ".bin" };
rlm@1 89 GetModuleFileName(NULL, applicationPath, 2048);
rlm@1 90 commandPath.Format("\"%s\" \"%%1\"", applicationPath);
rlm@1 91 regAssociateType("VisualBoyAdvance.Binary",
rlm@1 92 "Binary",
rlm@1 93 commandPath);
rlm@1 94
rlm@1 95 for (int i = 0; i < 7; i++)
rlm@1 96 {
rlm@1 97 if (mask & (1<<i))
rlm@1 98 {
rlm@1 99 regCreateFileType(types[i], "VisualBoyAdvance.Binary");
rlm@1 100 }
rlm@1 101 }
rlm@1 102 }
rlm@1 103 EndDialog(TRUE);
rlm@1 104 }
rlm@1 105