Files
Work/test/FILEHELP.HPP
2024-08-07 09:16:27 -04:00

68 lines
1.5 KiB
C++
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef _FILEHELP_HPP
#define _FILEHELP_HPP
#include <string.h>
#include <common/windows.hpp>
//#include <mdiwin/windowsx.hpp>
#include <common/owner.hpp>
#include <common/dwindow.hpp>
class SelectFile : public DWindow
{
public:
enum Mode{Read,Write};
SelectFile(HWND hParent,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};
int DlgProc(UINT message,WPARAM wParam,LPARAM lParam);
void Initialize();
void SelChange();
void DoubleClick();
void SetExtended();
int CheckFileNameSpec();
LPSTR lstrrchr(LPSTR,char);
LPSTR lstrchr(LPSTR,char);
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;
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