问题出在哪儿 [英] where is the problem

查看:65
本文介绍了问题出在哪儿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//--------------------------------------------- ------------------------------

#include< vcl.h>
#include< stdio.h>
#include< iostream.h>


#pragma hdrstop


#include"Unit7.h"
//------------------------------------------------ ---------------------------
#pragma package(smart_init)
#pragma资源"* .dfm"
TForm7 * Form7;
//------------------------------------------------ ---------------------------
__fastcall TForm7 :: TForm7(TComponent *所有者)
:TForm(所有者)
{
Form7->标题=无标题-注释";
}
//------------------------------------------------ ---------------------------
字符串ImeFajla;
文件* fp;
void __fastcall TForm7 :: Open1Click(TObject * Sender)
{
Memo1-> Clear();
OpenDialog1-> Execute();
文件* fp;
fp = fopen(OpenDialog1-> FileName.c_str(),"r");
ImeFajla = OpenDialog1-> FileName;
Form7->标题= ImeFajla +-注释";
char s [101];
char c;
int i = 0;
c = fgetc(fp);
while(c!= EOF)
{
while(c!=''\ n''&& c!= EOF)
{
s [i ++] = c;
c = fgetc(fp);
}
s [i] =''\ 0'';
i = 0;
Memo1-> Lines-> Add(s);
c = fgetc(fp);
}
fclose(fp);
}
//------------------------------------------------ ---------------------------
void __fastcall TForm7 :: SaveAs1Click(TObject * Sender)
{
SaveDialog1-> Execute();
文件* fp;
fp = fopen(SaveDialog1-> FileName.c_str(),"w");
ImeFajla = SaveDialog1-> FileName;
fprintf(fp,%s",Memo1-> Text.c_str());
Form7->标题= ImeFajla +-注释";
fclose(fp);
}
//------------------------------------------------ ---------------------------
void __fastcall TForm7 :: Save1Click(TObject * Sender)
{
文件* fp;
如果(ImeFajla!=")
{
fp = fopen(ImeFajla.c_str(),"w");
fputs(Memo1-> Text.c_str(),fp);
Form7->标题= ImeFajla +-注释";
}
其他
{
SaveDialog1-> Execute();
fp = fopen(SaveDialog1-> FileName.c_str(),"w");
ImeFajla = SaveDialog1-> FileName;
fprintf(fp,%s",Memo1-> Text.c_str());
Form7->标题= ImeFajla +-注释";

}

fclose(fp);
}
//------------------------------------------------ ---------------------------
void __fastcall TForm7 :: Exit1Click(TObject * Sender)
{
Form7-> Close();
}
//------------------------------------------------ ---------------------------
void __fastcall TForm7 :: New1Click(TObject * Sender)
{
Memo1-> Clear();
ImeFajla =";
Form7->标题=无标题-注释";
}
//------------------------------------------------ ---------------------------
void __fastcall TForm7 :: font1Click(TObject * Sender)
{
if(FontDialog1-> Execute())
Memo1-> Font = FontDialog1-> Font;
}
//------------------------------------------------ ---------------------------
void __fastcall TForm7 :: color1Click(TObject * Sender)
{
if(ColorDialog1-> Execute())
Memo1-> Color = ColorDialog1-> Color;
}
//------------------------------------------------ ----------------------






[BCC32错误] Unit7.cpp(28):E2451未定义符号"OpenDialog1"
[BCC32错误] Unit7.cpp(54):E2451未定义符号"SaveDialog1"
[BCC32错误] Unit7.cpp(74):E2451未定义符号"SaveDialog1"
[BCC32错误] Unit7.cpp(99):E2451未定义符号"FontDialog1"
[BCC32错误] Unit7.cpp(105):E2451未定义的符号"ColorDialog1"

//---------------------------------------------------------------------------

#include <vcl.h>
#include <stdio.h>
#include <iostream.h>


#pragma hdrstop


#include "Unit7.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm7 *Form7;
//---------------------------------------------------------------------------
__fastcall TForm7::TForm7(TComponent* Owner)
: TForm(Owner)
{
Form7->Caption = "untitled - Notes";
}
//---------------------------------------------------------------------------
String ImeFajla;
FILE *fp;
void __fastcall TForm7::Open1Click(TObject *Sender)
{
Memo1->Clear();
OpenDialog1->Execute();
FILE *fp;
fp = fopen(OpenDialog1->FileName.c_str(),"r");
ImeFajla = OpenDialog1->FileName;
Form7->Caption = ImeFajla+" - Notes";
char s[101];
char c;
int i = 0;
c = fgetc(fp);
while(c != EOF)
{
while(c != ''\n'' && c!= EOF)
{
s[i++] = c;
c = fgetc(fp);
}
s[i]=''\0'';
i = 0;
Memo1->Lines->Add(s);
c = fgetc(fp);
}
fclose(fp);
}
//---------------------------------------------------------------------------
void __fastcall TForm7::SaveAs1Click(TObject *Sender)
{
SaveDialog1->Execute();
FILE *fp;
fp = fopen(SaveDialog1->FileName.c_str(),"w");
ImeFajla = SaveDialog1->FileName;
fprintf(fp,"%s",Memo1->Text.c_str());
Form7->Caption = ImeFajla+" - Notes";
fclose(fp);
}
//---------------------------------------------------------------------------
void __fastcall TForm7::Save1Click(TObject *Sender)
{
FILE *fp;
if ( ImeFajla != "")
{
fp = fopen(ImeFajla.c_str(),"w");
fputs(Memo1->Text.c_str(),fp);
Form7->Caption = ImeFajla+" - Notes";
}
else
{
SaveDialog1->Execute();
fp = fopen(SaveDialog1->FileName.c_str(),"w");
ImeFajla = SaveDialog1->FileName;
fprintf(fp,"%s",Memo1->Text.c_str());
Form7->Caption = ImeFajla+" - Notes";

}

fclose(fp);
}
//---------------------------------------------------------------------------
void __fastcall TForm7::Exit1Click(TObject *Sender)
{
Form7->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm7::New1Click(TObject *Sender)
{
Memo1->Clear();
ImeFajla = "";
Form7->Caption = "untitled - Notes";
}
//---------------------------------------------------------------------------
void __fastcall TForm7::font1Click(TObject *Sender)
{
if(FontDialog1->Execute())
Memo1->Font = FontDialog1->Font;
}
//---------------------------------------------------------------------------
void __fastcall TForm7::color1Click(TObject *Sender)
{
if(ColorDialog1->Execute())
Memo1->Color = ColorDialog1->Color;
}
//----------------------------------------------------------------------






[BCC32 Error] Unit7.cpp(28): E2451 Undefined symbol ''OpenDialog1''
[BCC32 Error] Unit7.cpp(54): E2451 Undefined symbol ''SaveDialog1''
[BCC32 Error] Unit7.cpp(74): E2451 Undefined symbol ''SaveDialog1''
[BCC32 Error] Unit7.cpp(99): E2451 Undefined symbol ''FontDialog1''
[BCC32 Error] Unit7.cpp(105): E2451 Undefined symbol ''ColorDialog1''

推荐答案

问题是未定义您引用的对话框.

至少我是从错误告诉您它们未定义的情况下猜测的.
The problem is that the dialogs your referencing aren''t defined.

At least that''s my guess from the errors telling you that they''re undefined.


''OpenDialog1''是什么?在哪里定义?
并且,请给您的帖子起一个有意义的标题.
:)
What''s ''OpenDialog1''? Where is defined?
And, please, give a meaningful title to your post.
:)


您是否已在对话框中包含了所需的.h文件?

另一方面...您可以直接执行:

Have you included the needed .h files where the dialogs are?

On the other hand... you directly do:

[quote]
String ImeFajla;
FILE *fp;
void __fastcall TForm7::Open1Click(TObject *Sender)
{
Memo1->Clear();
OpenDialog1->Execute();
FILE *fp;
fp = ...
[quote]



并且您应该对对话框执行与FILE* fp相同的操作,我的意思是...

CMemoDialog*(或您的班级名称是什么)Memo1;
COpenDialog* OpenDialog1;

如果您正在执行此操作(不在发布的代码段中),则可能与全局"和本地"定义存在冲突.
例如,在我引用的代码部分中,函数外有一个File* fp,然后在函数内有另一个.函数内部的一个不必与另一个相同,因为您是在本地使用它的.但是String ImeFajla只是在开始时声明,然后在函数中使用,这就是您不会收到错误的原因.



and you should do the same with the dialogs as with the FILE* fp, I mean...

CMemoDialog* (or whatever the name of your class is) Memo1;
COpenDialog* OpenDialog1;

If you are doing it (it is not in the snippet you posted) probably you are having conflicts with "global" and "local" definitions.
For instance, in the part of your code that I quote, you have a File* fp out of the function, and then another one inside the function. The one inside the function doesn''t have to be the same as the other because you are using it locally. But the String ImeFajla is just declared at the beginning and then used in the functions, that''s the reason you don''t get an error for it.


这篇关于问题出在哪儿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆