给位大哥,小弟在这问问题把分都问完了,但我还有5分,我还想问个很简单的问题?(5分)

  • 主题发起人 主题发起人 zkking
  • 开始时间 开始时间
Z

zkking

Unregistered / Unconfirmed
GUEST, unregistred user!
很简单,做了个mdi,child为文本编辑,如果我想在mainform中实现对child中的richtext的操作
或是对child中的控件的操作怎么办?例如,在mainform中点击save按钮,想对child的激活窗口的
文本文件保存,我这么用的:
{ TMDIChild = class(TForm)
var
MDIChild:TMDIChild;}--为:child的声明;
在mainform中:
mdichild.richtext1.lines.savetofile(savedialog1.filename);
语言检查没错,但是总是在保存时提示出错,请问各位大哥怎么解决


 
整个问题我想不是很难吧,还是各位大哥觉得太简单不想答,能不能给个信,小弟先谢谢了?[8D][8D]
 
出错信息是什么?
 
是不是要计数的啊?
 
源程序:(mainform)
unit MAIN;
interface
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, Menus,
StdCtrls, Dialogs, Buttons, Messages, ExtCtrls, ComCtrls, StdActns,
ActnList, ToolWin, ImgList,shellapi, KsHooks, KsForms, KsSkinForms,
KsSkinEngine, KsControls, KsMenus, KsSkinMenus, KsItems, KsSkinItems,
KsToolBars, KsSkinToolBars, XPBarMenu, KsSpeedButtons, KsSkinSpeedButtons,
KsControlBars, KsSkinControlBars;
type
TMainForm = class(TForm)
OpenDialog: TOpenDialog;
StatusBar: TStatusBar;
ImageList1: TImageList;
SeSkinEngine1: TSeSkinEngine;
SeSkinForm1: TSeSkinForm;
SeSkinMenuBar1: TSeSkinMenuBar;
file1: TSeSkinItem;
edit1: TSeSkinItem;
research1: TSeSkinItem;
complie1: TSeSkinItem;
windows1: TSeSkinItem;
about: TSeSkinItem;
filenewitem: TSeSkinItem;
fileopenitem: TSeSkinItem;
filesaveitem: TSeSkinItem;
filesaveasitem: TSeSkinItem;
fileprintitem: TSeSkinItem;
filecloseitem: TSeSkinItem;
editcutitem: TSeSkinItem;
editcopyitem: TSeSkinItem;
editpasteitem: TSeSkinItem;
WindowCascadeItem: TSeSkinItem;
windowtileitem: TSeSkinItem;
CustomItem1: TSeSkinItem;
CustomItem2: TSeSkinItem;
editallitem: TSeSkinItem;
WindowTileItem2: TSeSkinItem;
CustomItem3: TSeSkinItem;
SeSkinToolBar1: TSeSkinToolBar;
btsysitem: TSeSkinSpeedButton;
btnewitem: TSeSkinSpeedButton;
btopenitem: TSeSkinSpeedButton;
btsaveitem: TSeSkinSpeedButton;
btcutitem: TSeSkinSpeedButton;
btpasteitem: TSeSkinSpeedButton;
btcopyitem: TSeSkinSpeedButton;
SeSkinSpeedButton8: TSeSkinSpeedButton;
SeSkinSpeedButton9: TSeSkinSpeedButton;
SeSkinSpeedButton10: TSeSkinSpeedButton;
SeSkinSpeedButton11: TSeSkinSpeedButton;
SeSkinSpeedButton12: TSeSkinSpeedButton;
SeSkinSpeedButton13: TSeSkinSpeedButton;
ActionList1: TActionList;
EditCut1: TEditCut;
EditCopy1: TEditCopy;
EditPaste1: TEditPaste;
EditSelectAll1: TEditSelectAll;
EditUndo1: TEditUndo;
menuundoiten: TSeSkinItem;
SeSkinSpeedButton1: TSeSkinSpeedButton;
SeSkinPopupMenu1: TSeSkinPopupMenu;
popcopyitem: TSeSkinItem;
poppasteitem: TSeSkinItem;
popcutitem: TSeSkinItem;
popnewitem: TSeSkinItem;
poplookitem: TSeSkinItem;
popcompliitem: TSeSkinItem;
popruncurseitem: TSeSkinItem;
n3: TSeSkinItem;
CustomItem12: TSeSkinItem;
popsaveitem: TSeSkinItem;
popsetitem: TSeSkinItem;
CustomItem15: TSeSkinItem;
FileSaveAs1: TFileSaveAs;
SaveDialog1: TSaveDialog;
procedure FileNew1Execute(Sender: TObject);
procedure FileOpen1Execute(Sender: TObject);
procedure HelpAbout1Execute(Sender: TObject);
procedure FileExit1Execute(Sender: TObject);
procedure WindowCascade1Execute(Sender: TObject);
procedure WindowTileItem2Click(Sender: TObject);
procedure WindowCascadeItemClick(Sender: TObject);
procedure windowtileitemClick(Sender: TObject);
procedure btnewitemClick(Sender: TObject);
procedure FileSaveAs1Accept(Sender: TObject);
procedure btsaveitemClick(Sender: TObject);

private
{ Private declarations }
procedure CreateMDIChild(const Name: string);
public
{ Public declarations }
end;

var
MainForm: TMainForm;
implementation
{$R *.dfm}
uses CHILDWIN, about;
procedure TMainForm.CreateMDIChild(const Name: string);
var
Child: TMDIChild;
begin
{ create a new MDI child window }
Child := TMDIChild.Create(self);
Child.Caption := Name;
{Child.FlatMemo1.Height:=Child.Height-20;
Child.FlatMemo1.Width:=Child.Width -4;
}

if FileExists(Name) then
Child.RICHEDIT1.Lines.LoadFromFile(Name);
end;

procedure TMainForm.FileNew1Execute(Sender: TObject);
begin
CreateMDIChild('NONAME' + IntToStr(MDIChildCount + 1));
end;

procedure TMainForm.FileOpen1Execute(Sender: TObject);
begin
if OpenDialog.Execute then
CreateMDIChild(OpenDialog.FileName);
end;

procedure TMainForm.HelpAbout1Execute(Sender: TObject);
begin
AboutBox.ShowModal;
end;

procedure TMainForm.FileExit1Execute(Sender: TObject);
begin

Close;
end;


procedure TMainForm.WindowCascade1Execute(Sender: TObject);
begin
cascade;
end;

procedure TMainForm.WindowTileItem2Click(Sender: TObject);
begin
tilemode:=tbvertical;
tile;
end;

procedure TMainForm.WindowCascadeItemClick(Sender: TObject);
begin
cascade;
end;

procedure TMainForm.windowtileitemClick(Sender: TObject);
begin
tilemode:=tbhorizontal;
tile;
end;

procedure TMainForm.btnewitemClick(Sender: TObject);
begin
FileNew1Execute(sender);
end;


procedure TMainForm.FileSaveAs1Accept(Sender: TObject);
var
child:Tmdichild;
begin
child.RichEdit1.Lines .SaveToFile(filesaveas1.Dialog.FileName );
end;

procedure TMainForm.btsaveitemClick(Sender: TObject);

begin
inherited;
if savedialog1.Execute then
mdichild.RichEdit1.Lines.SaveToFile(savedialog1.FileName);
end;

end.
提示为:
project mdiapp.exe raised exception class EAccessViolation with message'Access
violation' at address 004a1513 in module 'mdiapp.exe'.read of address ffffffff
mdiapp.exe为文件编译后的名字.

 
各位大哥帮帮忙吧,小弟要急死了!
 
我知道了
 
后退
顶部