forked from kuran-kuran/MZDiskExplorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetBoot.cpp
173 lines (156 loc) · 4.28 KB
/
GetBoot.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
168
169
170
171
172
173
// GetBoot.cpp : インプリメンテーション ファイル
//
#include "stdafx.h"
#include "MZDiskExplorer.h"
#include "GetBoot.h"
#include "path.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// cGetBoot ダイアログ
cGetBoot::cGetBoot(CWnd* pParent /*=NULL*/)
: CDialog(cGetBoot::IDD, pParent)
,FileName()
,MzDiskClass(NULL)
,SaveType(0)
{
//{{AFX_DATA_INIT(cGetBoot)
// メモ - ClassWizard はこの位置にマッピング用のマクロを追加または削除します。
//}}AFX_DATA_INIT
}
void cGetBoot::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(cGetBoot)
DDX_Control(pDX, IDC_PATH, m_Path);
DDX_Control(pDX, IDC_FILETYPE, m_FileType);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(cGetBoot, CDialog)
//{{AFX_MSG_MAP(cGetBoot)
ON_CBN_SELCHANGE(IDC_FILETYPE, OnSelchangeFiletype)
ON_BN_CLICKED(IDC_REF, OnRef)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// cGetBoot メッセージ ハンドラ
BOOL cGetBoot::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; // コントロールにフォーカスを設定しないとき、戻り値は TRUE となります
// 例外: OCX プロパティ ページの戻り値は FALSE となります
}
void cGetBoot::SetFile(char *filename)
{
strcpy_s( FileName, sizeof(FileName), filename );
}
void cGetBoot::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->GetBoot( FileName, Disk::FILEMODE_BIN );
}
else
{
result = MzDiskClass->GetBoot( FileName, Disk::FILEMODE_MZT );
}
if( 0 != result )
{
MessageBox( "ブートプログラムの取り出しに失敗しました. ", "エラー", MB_OK );
}
CDialog::OnOK();
}
void cGetBoot::OnSelchangeFiletype()
{
// 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;
}
void cGetBoot::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';
}