ヘッダーファイルとMFC用のライブラリをここからダウンロードしてください。これは tlckc で使用しているものです。 tlckc は SDK で作っていますが、MFC でも使えるようにしてあります。以下の約束の元での使用を許可します。
<< 使用上の約束 >>
うるさいことは言いませんが、 1.バグを見つけた場合は必ず私に報告すること。 2.もっとよいものができた場合には私にも使わせてくれること。
<< 使い方 >>
リリース用のライブラリとヘッダーファイルをプロジェクトのあるフォルダに、デバッグ用はその下のDebugフォルダに入れてください。
MFC で使用する場合はプリプロセッサの定義に TLMFC を加えます。
新しいスタイルを使用する場合にはプリプロセッサの定義に _WINNT=0X500 を加えます。
UNICODEで使用する場合にはプリプロセッサの定義に _UNICODE を加えます。
次に示します例は CEditView でテストしていたときのコードです。
#include "tlmofn.h"
void CTestView::OnFileOpenMulti()
{
GetFileName(TRUE, TRUE);
}
void CTestView::OnFileOpenSingle()
{
GetFileName(TRUE);
}
void CTestView::OnFileSaveSingle()
{
GetFileName(FALSE);
}
void CTestView::GetFileName(BOOL bfOpen, BOOL bfMulti)
{
LPTSTR ptr;
CString sBuf;
CString sInitDir;
CEdit& edit = GetEditCtrl();
SetWindowText(_T(""));
try{
CTlMultiOfn tlofn(this, _T("All (*.*)\0*.*\0Header (*.h)\0*.h\0"), NULL, NULL, 2);
if(bfOpen){
tlofn.GetOpenFileName(bfMulti);
sBuf = CString(_T("<< File Open Dialog >>\r\n\r\n"));
}else{
tlofn.GetSaveFileName();
sBuf = CString(_T("<< File Save Dialog >>\r\n\r\n"));
}
edit.ReplaceSel(sBuf);
// Version
sBuf.Format(_T("Library version = %d\r\n"), tlofn.GetVersion());
edit.ReplaceSel(sBuf);
// Buffer size
sBuf.Format(_T("Current buffer size in byte = %d\r\n"), tlofn.GetBufferSize() * sizeof(TCHAR));
edit.ReplaceSel(sBuf);
// Number of files
sBuf.Format(_T("Number of files = %d\r\n"), tlofn.GetFileCount());
edit.ReplaceSel(sBuf);
// Directory
tlofn.GetDir(sInitDir);
sBuf.Format(_T("Path to the folder = %s\r\n\r\n"), sInitDir);
edit.ReplaceSel(sBuf);
// Filenames
ptr = tlofn.EnumTitle();
while(ptr){
sBuf.Format(_T("%s "), ptr);
edit.ReplaceSel(sBuf);
ptr = tlofn.EnumTitle(ptr);
}
}
catch(DWORD dwErrorCode){
sBuf.Format(_T("*** FAILURE 0X%06X ( SEE cderr.h ) ***\r\n"), dwErrorCode);
edit.ReplaceSel(sBuf);
return;
}
}