텍스트 에디터..?
를 만들면서 공부를 하고 있습니다.
BCB 6 에서 기본 지원하는 샘플 프로그램중
RichEdit를 참조해서 하고 있는 와중에
세이브, 로드를 위해.
밑의 코드를 가져다 붙였습니다.
void __fastcall TForm1::Button6Click(TObject *Sender)
{
if( !strcmp(FFileName.c_str(), Reconst_SUntitled.c_str()) ){
SaveAsClick(Sender);
}else
{
memo->Lines->SaveToFile(FFileName);
memo->Modified = False;
}
/*if (OpenDialog->Execute())
{
memo->Lines->LoadFromFile(OpenDialog->FileName);
memo->SetFocus();
memo->Modified = False;
memo->ReadOnly = OpenDialog->Options.Contains(ofReadOnly);
} */
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7Click(TObject *Sender)
{
CheckFileSave();
if (OpenDialog->Execute())
{
memo->Lines->LoadFromFile(OpenDialog->FileName);
SetFileName(OpenDialog->FileName);
memo->SetFocus();
memo->Modified = False;
memo->ReadOnly = OpenDialog->Options.Contains(ofReadOnly);
}
/*if (OpenDialog->Execute())
{
memo->Lines->LoadFromFile(OpenDialog->FileName);
memo->SetFocus();
memo->Modified = False;
memo->ReadOnly = OpenDialog->Options.Contains(ofReadOnly);
} */
}
//---------------------------------------------------------------------------
void __fastcall TForm1::CheckFileSave(void)
{
if(memo->Modified)
{
switch(MessageBox(Handle, Reconst_SSaveChanges.c_str(),
Reconst_SConfirmation.c_str(),MB_YESNOCANCEL | MB_ICONQUESTION))
{
case ID_YES:
SaveClick(this);
break;
case ID_CANCEL:
Abort();
};
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SetFileName(const AnsiString FileName)
{
LPSTR lpBuf = new char[MAX_PATH];
sprintf(lpBuf, Reconst_SPercent_s.c_str(), ExtractFileName(FileName).c_str(),
Application->Title.c_str() );
Caption = lpBuf;
FFileName = FileName;
delete lpBuf;
}
//---------------------------------------------------------------------------
그랬더니 이런 에러가 나는군요;
[Linker Error] Unresolved external 'Reconst::_SUntitled' referenced from D:\YTS\TXT EDITOR\UNIT1.OBJ
[Linker Error] Unresolved external 'Reconst::_SConfirmation' referenced from D:\YTS\TXT EDITOR\UNIT1.OBJ
[Linker Error] Unresolved external 'Reconst::_SSaveChanges' referenced from D:\YTS\TXT EDITOR\UNIT1.OBJ
[Linker Error] Unresolved external 'Reconst::_SPercent_s' referenced from D:\YTS\TXT EDITOR\UNIT1.OBJ
왜 그러는지 혹시 알 수 있을런지요?
....으헝 ㅠㅠㅠ
허접하게나마 제가 만든... 소스도 같이 올려봅니다...(근데 주석이 없군요.... 죄송합니다;)
|