77 lines
1.9 KiB
C++
77 lines
1.9 KiB
C++
#ifndef _FILEHELP_HPP
|
||
#define _FILEHELP_HPP
|
||
#include <string.h>
|
||
#include <common/windows.hpp>
|
||
#include <common/windowsx.hpp>
|
||
#include <common/crsctrl.hpp>
|
||
#include <common/window.hpp>
|
||
#include <common/dwindow.hpp>
|
||
#include <common/owner.hpp>
|
||
|
||
class SelectFile : public DWindow, private CursorControl
|
||
{
|
||
public:
|
||
enum Mode{Read,Write};
|
||
SelectFile(Window &parentWindow,Mode readWrite=Read);
|
||
~SelectFile();
|
||
void SetAttribute(WORD attribute);
|
||
void SetExtension(const char * extension);
|
||
void SetFileSpec(const char * fileSpec);
|
||
int GetFileName(char *buffer,WORD length);
|
||
private:
|
||
enum {MaxTextLength=96};
|
||
enum {DefaultAttribute=0x4010};
|
||
enum {btnRed=192,btnGreen=192,btnBlue=192};
|
||
CallbackData::ReturnType commandHandler(CallbackData &someCallbackData);
|
||
CallbackData::ReturnType initDialogHandler(CallbackData &someCallbackData);
|
||
CallbackData::ReturnType drawItemHandler(CallbackData &someCallbackData);
|
||
void Initialize();
|
||
void SelChange();
|
||
void DoubleClick();
|
||
void SetExtended();
|
||
int CheckFileNameSpec();
|
||
LPSTR lstrrchr(LPSTR,char);
|
||
LPSTR lstrchr(LPSTR,char);
|
||
|
||
Callback<SelectFile> mCommandHandler;
|
||
Callback<SelectFile> mInitDialogHandler;
|
||
Callback<SelectFile> mDrawItemHandler;
|
||
char mszDefExt[MaxTextLength];
|
||
char mszFileName[MaxTextLength];
|
||
char mszFileSpec[MaxTextLength];
|
||
char mszDirectory[MaxTextLength];
|
||
char mcLastChar;
|
||
short mnEditLen;
|
||
int mLastDrive;
|
||
WORD mwFileAttribute;
|
||
OFSTRUCT mPof;
|
||
HFILE mfd;
|
||
HWND mhParent;
|
||
HINSTANCE mhInstance;
|
||
Mode mMode;
|
||
HBRUSH mhGrayBrush;
|
||
OwnerDraw mOwnerDraw;
|
||
};
|
||
|
||
inline
|
||
void SelectFile::SetAttribute(WORD nAttribute)
|
||
{
|
||
mwFileAttribute=nAttribute;
|
||
}
|
||
|
||
inline
|
||
void SelectFile::SetExtension(const char *szExtension)
|
||
{
|
||
::strncpy(mszDefExt,szExtension,sizeof(mszDefExt)-1);
|
||
mszDefExt[sizeof(mszDefExt)-1]='\0';
|
||
}
|
||
|
||
inline
|
||
void SelectFile::SetFileSpec(const char *szFileSpec)
|
||
{
|
||
::strncpy(mszFileSpec,szFileSpec,sizeof(mszFileSpec)-1);
|
||
mszFileSpec[sizeof(mszFileSpec)-1]='\0';
|
||
}
|
||
#endif
|
||
|
||
|