Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Multiple-SDI Application

Multiple-SDI Application

Scheduled Pinned Locked Moved C#
graphicshelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    h s n
    wrote on last edited by
    #1

    I want my application to behave like MSWord 2003. i.e. Multiple-SDI Application. I am facing problem with the code that first window always close all other windows. Please identify changes. //TopLevelForm.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; namespace MultipleSDI { public partial class TopLevelForm : Form { string fileName; static int formCount = 0; public TopLevelForm() { InitializeComponent(); MultiSDIApplication.Application.AddTopLevelForm(this); MultiSDIApplication.Application.AddWindowMenu(this.windowToolStripMenuItem); ++formCount; this.Text += ": " + formCount.ToString(); } public static TopLevelForm CreateTopLevelWindow(string fileName) { // Detect whether file is already open if (!string.IsNullOrEmpty(fileName)) { foreach (TopLevelForm openForm in Application.OpenForms) { if (string.Compare(openForm.FileName, fileName, true) == 0) { // Bring form to top openForm.Activate(); return openForm; } } } // Create new top-level form and open file TopLevelForm form = new TopLevelForm(); form.OpenFile(fileName); form.Show(); // Bring form to top form.Activate(); return form; } private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (this.openFileDialog.ShowDialog() == DialogResult.OK) { TopLevelForm.CreateTopLevelWindow(this.openFileDialog.FileName); } } void OpenFile(string fileName) { this.fileName = fileName; if (!string.IsNullOrEmpty(fileName)) { using (StreamReader reader = new StreamReader(fileName)) { textBox.Text = reader.ReadToEnd(); } } else this.fileName = "untitled" + formCount.ToString(); t

    L 1 Reply Last reply
    0
    • H h s n

      I want my application to behave like MSWord 2003. i.e. Multiple-SDI Application. I am facing problem with the code that first window always close all other windows. Please identify changes. //TopLevelForm.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; namespace MultipleSDI { public partial class TopLevelForm : Form { string fileName; static int formCount = 0; public TopLevelForm() { InitializeComponent(); MultiSDIApplication.Application.AddTopLevelForm(this); MultiSDIApplication.Application.AddWindowMenu(this.windowToolStripMenuItem); ++formCount; this.Text += ": " + formCount.ToString(); } public static TopLevelForm CreateTopLevelWindow(string fileName) { // Detect whether file is already open if (!string.IsNullOrEmpty(fileName)) { foreach (TopLevelForm openForm in Application.OpenForms) { if (string.Compare(openForm.FileName, fileName, true) == 0) { // Bring form to top openForm.Activate(); return openForm; } } } // Create new top-level form and open file TopLevelForm form = new TopLevelForm(); form.OpenFile(fileName); form.Show(); // Bring form to top form.Activate(); return form; } private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (this.openFileDialog.ShowDialog() == DialogResult.OK) { TopLevelForm.CreateTopLevelWindow(this.openFileDialog.FileName); } } void OpenFile(string fileName) { this.fileName = fileName; if (!string.IsNullOrEmpty(fileName)) { using (StreamReader reader = new StreamReader(fileName)) { textBox.Text = reader.ReadToEnd(); } } else this.fileName = "untitled" + formCount.ToString(); t

      L Offline
      L Offline
      Luis Alonso Ramos
      wrote on last edited by
      #2

      First of all, putting large amounts of code in a post is not a good idea, since few people will take the time to check it out. And if you don't explain what's going on, it is hard to understand at first glance. But here is an idea: maybe your message loop is running on your first window, so when it is closed the message loop returns and the app is closed. I would create an invisible window, run the message loop on it, and when the last window is closed, kill that window. You can also use that hidden window to get a list of all windows (for the Window menu, for example). I hope this helps.

      Luis Alonso Ramos Intelectix Chihuahua, Mexico

      Not much here: My CP Blog!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups