|
// MyClass.cpp: MyClass クラスのインプリメンテーション
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MyClass.h"
//////////////////////////////////////////////////////////////////////
// 構築/消滅
//////////////////////////////////////////////////////////////////////
MyClass::MyClass()
{
}
MyClass::~MyClass()
{
}
void MyClass::WMCreate()
{
// ドラッグドロップの実装
LView->DragAccept( true );
// 固定ピッチフォント
LView->SetFont( 2, 12, false );
// タイトル
LView->AddColumn( "アドレス" );
LView->AddColumn( "16進数表示" );
LView->AddColumn( "テキスト表示" );
// 表示最適化
LView->Fit();
// バッファサイズ設定
Buff.Resize( 16 * 40 );
// メインウインドウ最大化
this->Maximize();
}
void MyClass::ProcDrop()
{
if ( !LView->IsHandle( this->hTargetWindow ) ) {
return;
}
// ドロップされたファイルのパスの取得
this->TargetFile.Resize( MAX_PATH );
DragQueryFile(
this->hDrop,
0, // 選択された先頭ファイル
this->TargetFile.szLboxString,
MAX_PATH
);
// ファイルから640バイトの取得
FILE *fp;
fp = fopen( this->TargetFile.szLboxString, "rb" );
if ( fp == NULL ) {
MsgOk(
"%s \nのオープンに失敗しました",
this->TargetFile.szLboxString
);
return;
}
DWORD nByte;
nByte = fread(
this->Buff.szLboxString,
1,
// 最後のバイトが先導バイトの場合
// もう1バイト必要
16*40+1,
fp
);
fclose( fp );
if ( nByte > 16*40 ) {
nByte = 16*40;
}
DWORD i,code;
BOOL flg;
// リストビューのリセット
LView->Reset();
for( i = 0; i < 40; i++ ) {
LView->AddRow();
}
LboxString LData(""); // 16進用
LboxString LText(""); // テキスト用
flg = false; // 行の最終バイトが先導バイト
for( i = 0; i < nByte; i++ ) {
// ターゲットの1バイト
code = 0x000000ff & *(this->Buff.szLboxString + i);
// 16進表示を追加作成
LData.Printfcat(
"%02X ",
code
);
// テキスト表示を追加作成
if ( 0 <= code && code <= 0x0000001f ) {
LText.Printfcat(
"%s",
"."
);
}
else {
if ( flg ) {
flg = false;
LText.Printfcat(
"%s",
" "
);
}
else {
LText.Printfcat(
"%c",
code
);
}
}
// アドレス表示を作成
if ( i % 16 == 0 ) {
LView->SetCurrentRow( i / 16 );
LView->SetColumnPrintf( 0, "%08X", i / 16 );
}
// 行の最終バイトの処理
if ( i % 16 == 15 ) {
// 16進表示をカラムへセット
LView->SetColumnText( 1, &LData );
LData.SetChar( 0, 0 );
// 先導バイトの場合
if ( IsDBCSLeadByte( (BYTE)code ) ) {
// SHIFT JIS の厳密なチェック
if ( 0x000000f0 > code || code > 0x000000fc ) {
// 次の1バイトを取得
code =
0x000000ff &
*(this->Buff.szLboxString + i + 1);
LText.Printfcat(
"%c",
code
);
// 先導フラグをON
flg = true;
}
}
// テキスト表示をカラムへセット
LView->SetColumnText( 2, <ext );
LText.SetChar( 0, 0 );
}
}
// 最終処理
if ( (i-1) % 16 != 15 ) {
LView->SetColumnText( 1, &LData );
LView->SetColumnText( 2, <ext );
}
// 表示最適化
LView->Fit();
}
| |