C++ Builder中MDI应用程序的设计
作者 佚名技术
来源 程序设计
浏览
发布时间 2012-06-30
try { doc->Print(PathName); } catch(...){ Printer()->EndDoc(); throw; } } } void __fastcall TChildForm::Printersetup1Click(TObject *Sender) { PrinterSetupDialog1->Execute();//打开打印机设置对话框进行打印机设置} void __fastcall TChildForm::Cut1Click(TObject *Sender) {doc->CutToClipboard();//文档剪切到剪贴板} void __fastcall TChildForm::Copy1Click(TObject *Sender) { doc->CopyToClipboard();//文档拷贝到剪贴板} void __fastcall TChildForm::Paste1Click(TObject *Sender) { doc->PasteFromClipboard();//从剪贴板粘贴文档} void __fastcall TChildForm::Delete1Click(TObject *Sender) { doc->ClearSelection();//删除选中的文档} void __fastcall TChildForm::Selectall1Click(TObject *Sender) { doc->SelectAll();//文档全选} //文档向左、向右、居中等各种对齐方式响应函数 void __fastcall TChildForm::Left1Click(TObject *Sender) { Left1->Checked = false; Right1->Checked = false; Center1->Checked = false; if( dynamic_cast<TMenuItem *>(Sender) !=0) dynamic_cast <TMenuItem *>(Sender) ->Checked = true; { if (Left1->Checked ) doc->Paragraph->Alignment = taLeftJustify; else if (Right1->Checked) doc->Paragraph->Alignment= taRightJustify; else if (Center1->Checked) doc->Paragraph->Alignment = taCenter; } } //文档自动换行 void __fastcall TChildForm::Wordwrap1Click(TObject *Sender) { doc->WordWrap = !doc->WordWrap; //toggle word wrapping if (doc->WordWrap) doc->ScrollBars = ssVertical; else doc->ScrollBars = ssBoth; Wordwrap1->Checked = doc->WordWrap; // set menu item check } //设置选中文档的字体 void __fastcall TChildForm::Font1Click(TObject *Sender) {FontDialog1->Font= doc->Font; if (FontDialog1->Execute()) doc->SelAttributes->Assign(FontDialog1->Font); } //子窗口鼠标单击响应函数 void __fastcall TChildForm::FormClick(TObject *Sender) { bool HasSelection; Paste1->Enabled = Clipboard()->HasFormat(CF_TEXT); HasSelection = doc->SelLength > 0; Cut1->Enabled = HasSelection; Copy1->Enabled = HasSelection; Delete1->Enabled = HasSelection; } //子窗口关闭时事件响应 void __fastcall TChildForm::FormClose(TObject *Sender, TCloseAction &Action) {Action=caFree; } //子窗口关闭时询问事件响应 void __fastcall TChildForm::FormCloseQuery(TObject *Sender, bool &CanClose) { if (doc->Modified) { TMsgDlgButtons temp_set; temp_set<< mbYes<<mbNo <<mbCancel; String buffer = "Save changes to " + PathName; switch(MessageDlg(buffer, mtConfirmation,temp_set,0)) { case mrYes: Save1Click(this); break; case mrCancel: CanClose=false; break; } }} void __fastcall TChildForm::FormCreate(TObject *Sender) { PathName = DefaultFileName; } //---------MDIChild.h------------ class TChildForm : public TForm { private: // User declarations AnsiString PathName;//文档文件和路径名定义 public: // User declarations void __fastcall Open(const AnsiString AFileName);//文档打开函数声明 virtual __fastcall TChildForm(TComponent* Owner); }; 另外,你自己也可以根据上述开发思路来开发出各种各样的MDI程序,比如,你可以在文档中利用OLE加入图片,声音等多媒体因素, |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
上一篇: 用BCB3.0制作桌面动画下一篇: 读取其他应用程序中ListView中的内容
关于C++ Builder中MDI应用程序的设计的所有评论