在delphi5中编译正常,但在delphi7中编译时,有如下提示!
我想是因为delphi5中不完善的函数等东西,在delphi7中纠正了,用别的函数代替!
具体实例如下:语句1:
application.MessageBox(pchar('输入数值不能为空!'+edit1.text),'提示',mb_ok+mb_iconinformation);
提示1:
[Warning] sun_ck_pdblr_mxxg.pas(169): Unsafe type 'PChar'语句2:
procedure TForm1.Button1Click(Sender: TObject);
var book1:TBookMark;
begin
book1:=query1.GetBook;
query1.Active:=false;
query1.Active:=true;
querysp.GotoBook(book1);
querysp.FreeBook(book1);
end;
提示2:
[Warning] sun_ck_pdblr.pas(223): Unsafe type 'TBook'
[Warning] sun_ck_pdblr.pas(265): Unsafe type 'book1: Pointer'
[Warning] sun_ck_pdblr.pas(268): Unsafe type 'book1: Pointer'
[Warning] sun_ck_pdblr.pas(269): Unsafe type 'book1: Pointer'谁知道解决方法?
我想是因为delphi5中不完善的函数等东西,在delphi7中纠正了,用别的函数代替!
具体实例如下:语句1:
application.MessageBox(pchar('输入数值不能为空!'+edit1.text),'提示',mb_ok+mb_iconinformation);
提示1:
[Warning] sun_ck_pdblr_mxxg.pas(169): Unsafe type 'PChar'语句2:
procedure TForm1.Button1Click(Sender: TObject);
var book1:TBookMark;
begin
book1:=query1.GetBook;
query1.Active:=false;
query1.Active:=true;
querysp.GotoBook(book1);
querysp.FreeBook(book1);
end;
提示2:
[Warning] sun_ck_pdblr.pas(223): Unsafe type 'TBook'
[Warning] sun_ck_pdblr.pas(265): Unsafe type 'book1: Pointer'
[Warning] sun_ck_pdblr.pas(268): Unsafe type 'book1: Pointer'
[Warning] sun_ck_pdblr.pas(269): Unsafe type 'book1: Pointer'谁知道解决方法?
MessageBox(pchar('输入数值不能为空!'+edit1.text),'提示',mb_ok+mb_iconinformation);语句2:
你没有指针吧!
你用的是delphi几?Sunniness(笨鸟) :
var book1:TBookMark;
是标准的书签,没有问题!
只是提示为不安全类型!
那还有什么函数可以实现书签的功能?
因为TbookMark本身是指针类型.
强烈建议不要这么做,除非对于所有的类型相当的熟悉(即使如此恐怕也会有疏漏)
而在Delphi5的编译器中不去检查你是否使用了指针类型,也就没有这个提示!可我就是看那些提示在编译时冒出来而感到难受,好像是在说我程序编的不对!!!
Project-->Options...-->Compiler Messages-->
Unsafe type
Unsafe code
Unsafe typecast
將這三項勾選去掉就行