ユーザーがこれを行っていない場合にファイルの拡張子を設定し、ファイル名と拡張子コンボボックス文字列を連結したいのですが、簡単な方法はありますか、それとも「フック」が必要ですか?
OPENFILENAME ofn; // common dialog box structure
TCHAR szFile[260]; // buffer for file name
HANDLE hFile; // file handle
// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
// Set lpstrFile[0] to '\0' so that GetOpenFileName does not
// use the contents of szFile to initialize itself.
ofn.lpstrFile[0] = 0;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = _T("Текстові файли(*.txt)\0*.txt\0Word(*.doc)\0*.doc\0");
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_EXPLORER;
if(GetSaveFileName(&ofn) == TRUE)
{
hFile = CreateFile( szFile,
GENERIC_WRITE,
0,
(LPSECURITY_ATTRIBUTES)NULL,
CREATE_NEW,
FILE_ATTRIBUTE_NORMAL,
(HANDLE)NULL);
int editLen = Edit_GetTextLength(edit);
TCHAR* buffer = new TCHAR[editLen+1];
DWORD wroteLen = 0;
Edit_GetText(edit,buffer,editLen+1);
//Set extension if need
///////////////////////
if(!WriteFile(hFile,buffer,editLen*sizeof(TCHAR),&wroteLen,NULL))
MessageBox(hwnd,_T("File wasn`t saved.."),_T("Error"),MB_ICONERROR);
CloseHandle(hFile);
delete[]buffer;
返信ありがとうございます!)))