-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGetSystem.cpp
167 lines (147 loc) · 3.91 KB
/
GetSystem.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// GetSystem.cpp : 実装ファイル
//
#include "stdafx.h"
#include "MZDiskExplorer.h"
#include "GetSystem.h"
#include "path.h"
#include "afxdialogex.h"
// GetSystem ダイアログ
IMPLEMENT_DYNAMIC(GetSystem, CDialog)
GetSystem::GetSystem(CWnd* pParent /*=nullptr*/)
: CDialog(IDD_GETSYSTEM, pParent)
,FileName()
,MzDiskClass(NULL)
,SaveType(0)
{
}
GetSystem::~GetSystem()
{
}
void GetSystem::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_PATH, m_Path);
DDX_Control(pDX, IDC_FILETYPE, m_FileType);
}
BEGIN_MESSAGE_MAP(GetSystem, CDialog)
ON_BN_CLICKED(IDC_REF, &GetSystem::OnRef)
ON_CBN_SELCHANGE(IDC_FILETYPE, &GetSystem::OnCbnSelchangeFiletype)
END_MESSAGE_MAP()
// GetSystem メッセージ ハンドラー
void GetSystem::SetFile(char *filename)
{
strcpy_s( FileName, sizeof(FileName), filename );
}
BOOL GetSystem::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: ここに初期化を追加してください
m_FileType.AddString( "BIN" );
m_FileType.AddString( "MZT" );
m_FileType.SetCurSel( SaveType );
m_Path.SetSel( 0, -1, FALSE );
m_Path.Clear();
m_Path.ReplaceSel( FileName, FALSE );
return TRUE; // return TRUE unless you set the focus to a control
// 例外 : OCX プロパティ ページは必ず FALSE を返します。
}
void GetSystem::OnOK()
{
// TODO: ここに特定なコードを追加するか、もしくは基底クラスを呼び出してください。
cPath path;
char temp[ 261 ];
ZeroMemory( temp, sizeof( temp ) );
int size = m_Path.GetLine( 0, temp, 260 );
temp[size] = '\0';
path.SetPath( temp );
m_Path.SetSel( 0, -1, FALSE );
m_Path.Clear();
m_Path.ReplaceSel( path.GetPath(), FALSE );
ZeroMemory( FileName, sizeof( FileName ) );
size = m_Path.GetLine( 0, FileName, 260 );
FileName[size] = '\0';
int select;
int result;
select = m_FileType.GetCurSel();
if ( 0 == select )
{
result = MzDiskClass->GetSystem( FileName, Disk::FILEMODE_BIN );
}
else
{
result = MzDiskClass->GetSystem( FileName, Disk::FILEMODE_MZT );
}
if( 0 != result )
{
MessageBox( "ブートプログラムの取り出しに失敗しました. ", "エラー", MB_OK );
}
CDialog::OnOK();
}
void GetSystem::OnRef()
{
// TODO: ここにコントロール通知ハンドラー コードを追加します。
CString datapath;
char savepath[ 261 ];
int select;
char temp[ 261 ];
ZeroMemory( temp, sizeof( temp ) );
int size = m_Path.GetLine( 0, temp, 260 );
temp[size] = '\0';
select = m_FileType.GetCurSel();
if ( 0 == select )
{
CFileDialog SelFile( TRUE, "bin", temp, OFN_HIDEREADONLY, "BIN file|*.*||" );
if ( IDCANCEL == SelFile.DoModal() )
{
return;
}
datapath = SelFile.GetPathName();
}
else
{
cPath path;
path.SetPath( temp );
path.SetExtName( "mzt" );
CFileDialog SelFile( TRUE, "mzt", path.GetPath(), OFN_HIDEREADONLY, "MZT file|*.mzt|全てのファイル|*.*||" );
if ( IDCANCEL == SelFile.DoModal() )
{
return;
}
datapath = SelFile.GetPathName();
}
memset( savepath, 0, MAX_PATH );
strcpy_s( savepath, sizeof(savepath), datapath.GetBuffer( MAX_PATH ) );
m_Path.SetSel( 0, -1, FALSE );
m_Path.Clear();
m_Path.ReplaceSel( datapath, FALSE );
ZeroMemory( FileName, sizeof( FileName ) );
size = m_Path.GetLine( 0, FileName, 260 );
FileName[size] = '\0';
}
void GetSystem::OnCbnSelchangeFiletype()
{
// TODO: ここにコントロール通知ハンドラー コードを追加します。
cPath path;
char temp[ 261 ];
int select;
ZeroMemory( temp, sizeof( temp ) );
int size = m_Path.GetLine( 0, temp, 260 );
temp[size] = '\0';
path.SetPath( temp );
select = m_FileType.GetCurSel();
if ( 0 == select )
{
path.SetExtName( "" );
}
else
{
path.SetExtName( "mzt" );
}
m_Path.SetSel( 0, -1, FALSE );
m_Path.Clear();
m_Path.ReplaceSel( path.GetPath(), FALSE );
ZeroMemory( FileName, sizeof( FileName ) );
size = m_Path.GetLine( 0, FileName, 260 );
FileName[size] = '\0';
SaveType = select;
}