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