扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:Adding 来源:YESKY 2007年11月16日
关键字:
#using using namespace System; #using "System.dll" #using "System.Windows.Forms.dll" #using "System.Drawing.dll" using namespace System::ComponentModel; using namespace System::Windows::Forms; using namespace System::Drawing; // 这是子窗口 __gc class ChildWnd: public Form { private: TextBox* m_pTextBox; public: ChildWnd() { InitChildWnd(); // 调用自定义的表单初始化代码 } void Dispose() // 表单释放,类似于析构函数 { // 所有的删除代码添加在这里 Form::Dispose(); // 默认的释放操作 } void InitChildWnd() { Text = S"文档窗口——未命名"; m_pTextBox = new TextBox(); m_pTextBox->Dock = DockStyle::Fill; m_pTextBox->Multiline = true; m_pTextBox->BackColor = Color::White; m_pTextBox->BorderStyle = BorderStyle::Fixed3D; Controls->Add(m_pTextBox); } }; // 这是主框架窗口 __gc class MainFrame: public Form { private: MainMenu * m_pMenu; MenuItem * m_pFileMenu; MenuItem * m_pFileMenuNew; MenuItem * m_pFileMenuOpen; MenuItem * m_pFileMenuExit; MenuItem * m_pWndMenu; MenuItem * m_pWndMenuIcons; MenuItem * m_pWndMenuCascade; MenuItem * m_pWndMenuTileHori; MenuItem * m_pWndMenuTileVert; MenuItem * m_pWndMenuList; public: MainFrame() { InitMainFrame(); // 调用自定义的表单初始化代码 CreateChildWnd(); } void Dispose() // 表单释放,类似于析构函数 { // 所有的删除代码添加在这里 Form::Dispose(); // 默认的释放操作 } void InitMainFrame() { Text = S"Win表单多文档应用程序"; IsMdiContainer = true; m_pFileMenuNew = new MenuItem( S"新建(&N)", new EventHandler(this, &MainFrame::OnFileNew)); m_pFileMenuOpen = new MenuItem( S"打开(&O)", new EventHandler(this, &MainFrame::OnFileOpen)); m_pFileMenuExit = new MenuItem( S"退出(&X)", new EventHandler(this, &MainFrame::OnFileExit)); MenuItem* rItems[] = new MenuItem *[3]; rItems[0] = m_pFileMenuNew; rItems[1] = m_pFileMenuOpen; rItems[2] = m_pFileMenuExit; m_pFileMenu = new MenuItem( S"文件(&F)", rItems); m_pWndMenu = new MenuItem( S"窗口(&X)"); m_pWndMenu->MdiList = true; m_pWndMenuIcons = new MenuItem( S"图标排列"); m_pWndMenuIcons->Click += new EventHandler(this, &MainFrame::OnWndMenu); m_pWndMenu->MenuItems->Add(m_pWndMenuIcons); m_pWndMenuCascade = new MenuItem( S"窗口层叠"); m_pWndMenuCascade->Click += new EventHandler(this, &MainFrame::OnWndMenu); m_pWndMenu->MenuItems->Add(m_pWndMenuCascade); m_pWndMenuTileHori = new MenuItem( S"上下平铺"); m_pWndMenuTileHori->Click += new EventHandler(this, &MainFrame::OnWndMenu); m_pWndMenu->MenuItems->Add(m_pWndMenuTileHori); m_pWndMenuTileVert = new MenuItem( S"左右平铺"); m_pWndMenuTileVert->Click += new EventHandler(this, &MainFrame::OnWndMenu); m_pWndMenu->MenuItems->Add(m_pWndMenuTileVert); m_pMenu = new MainMenu(); m_pMenu->MenuItems->Add(m_pFileMenu); m_pMenu->MenuItems->Add(m_pWndMenu); Menu = m_pMenu; } void OnFileNew(Object *sender, EventArgs *e) { CreateChildWnd(); } void OnFileOpen(Object *sender, EventArgs *e) { OpenFileDialog *dlg = new OpenFileDialog(); dlg->Filter = S"所有文件|*.*"; dlg->ShowDialog(); } void OnFileExit(Object *sender, EventArgs *e) { Close(); } void OnWndMenu(Object *sender, EventArgs *e) { if(sender->Equals(m_pWndMenuIcons)) { LayoutMdi(MdiLayout::ArrangeIcons); } else if(sender->Equals(m_pWndMenuCascade)) { LayoutMdi(MdiLayout::Cascade); } else if(sender->Equals(m_pWndMenuTileHori)) { LayoutMdi(MdiLayout::TileHorizontal); } else if(sender->Equals(m_pWndMenuTileVert)) { LayoutMdi(MdiLayout::TileVertical); } } void CreateChildWnd(void) { ChildWnd *pWnd = new ChildWnd(); pWnd->MdiParent = this; pWnd->Show(); } }; #ifdef _UNICODE int wmain(void) #else int main(void) #endif { Application::Run(new MainFrame()); // 启用应用程序,运行该类 return 0; } |
图一 |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者