//-----------------------------------------
// BCCForm Ver 2.41
// An Easy Resource Editor for BCC
// Copyright (c) February 2002 by ysama
//-----------------------------------------
#include "ResRenamer.h"
ps. 写真データを扱うAlbumのツールに入れようか、とも考えたのですが、Albumの*.albファイルのファイルパス名のデータをツールのRenamerが書き換えると、今度はAlbumがalbファイルで読めなくなります。Renamerは任意のフォールダー内の任意のファイルの名前を変えるので様々なフォールダーにある写真(イメージ)データをまとめたalbファイルとは全く関連性がなく、Renamerのファイル名変更結果をログで残して、albファイルと照合して該当があればalbファイルを変更するような別のツールが必要になりますが、一応ログファイルをの子pすべきか否か、考え中です。(まぁ、人間の仕事と一緒で、手順としては写真データを整理して、それからアルバムに貼る手順を行えば、問題はないのですが、ユーザーは必ずしもそのように行動しませんし、それが予見できるのでプログラマーはその予見可能なユーザー行動に対処しなければならないのが現代の設計義務なんでしょうね。)
前回「悩み」を書きましたが、悩んでいても仕方がないし、このブログは本来BCCForm and BCCSkelton(Unicode版ECCSkeltonも含む)のサポートを行う場所なので、C#で作ってもよいのですが、B(E)CCSkeltonでのプログラムはやはり作らないと不味かろう、というのが結論です。
using System;
using System.Windows.Forms;
using System.Drawing;
using System.IO;
using System.Linq; // EnumerateFiles を使用するのに必要
using System.Text; // Encoding.GetEncoding を使用するのに必要
public partial class AppForm : Form
{
TextBox txtBox;
Button clrBtn, rdBtn, wrtBtn, extBtn;
[STAThread] //ファイルを開く(保存)ダイアログを使うのでこれは必須
public static void Main()
{
AppForm ap = new AppForm();
Application.Run(ap);
}
public AppForm()
{
this.Size = new Size(640, 480); this.MinimumSize = new Size(320, 190); //翌日修正箇所
this.Text = "TextBox Test";
this.Load += AppForm_Load;
}
ps. 昔々の大昔に勉強したC言語のMS-DOSワイルドカード等に対応する文字列比較関数のサンプルを載せます。今風で言えばintを使っていますが、"bool"を返す関数になっていますね。参考になるかしら?
int strcmp2(char* str1, char* str2) {
while(*str1) { /* ptr is not NULL */
switch(*str1) {
case '?': /* ? does match with any characters and nothing to do here */
break;
case '[': { /* "[(-)]" matches with a group of characters */
int found; /* A flag for a case where they match */
for(found = 0, str1++; *str1 && *str1 != ']'; str1++) { /* Until EOS or ']' */
if(*str1 == *str2)
found = 1;
else if(str1[1] == '-' && *str1 <= *str2 && *str2 <= str1[2]) { /* No space or tab allowed */
found = 1;
str1 += 2; /* Skipping "-?" */
}
}
if(!found)
return 0;
else break;
}
case '*': /* '*' matches with any characters */
for(str1++; *str2; str2++) /* Skipping '*' amd compare with the rest of str2 till EOS of str2*/
if(match2(str1, str2)) return 1;
return match2(str1, str2); /* Even if both are EOS, return 1 */
case '\\':
str1++; /* Skipping '\' which protect reserved characters, e.g. "\*" */
default:
if(*str1 != *str2) /* If they don't match or str is NULL, then end loop */
return 0;
}
str1++;
str2++;
}
// return (*str1 == *str2); /* Only both are NULL, return TRUE otherwise FALSE */
return !(*str1 || *str2); /* Ditto */
}