Click here to Skip to main content
11,634,827 members (67,237 online)
Click here to Skip to main content
Articles » Languages » C# » Applications » Downloads
Add your own
alternative version

Window Tabifier

, 29 Mar 2008 CPOL 202K 7.3K 282
A simple application for hosting several Windows in one parent window
windowtabifier_demo.zip
WindowTabifier_demo
About.dll
DragAndDropFileComponent.dll
TabStrip.dll
Window Tabifier.exe
windowtabifier_src.zip
Window Tabifier
Window Tabifier
bin
DLL's
About.dll
DragAndDropFileComponent.dll
TabStrip.dll
documents-32x32.png
folder-documents.ico
Properties
Settings.settings
Thumbs.db
Window Tabifier.csproj.user
Window.cd
Windows-Desktop-32x32.png
windowtabifier_srcvs2005.zip
WindowTabifier_srcVS2005
Window Tabifier
bin
DLLs
About.dll
DragAndDropFileComponent.dll
TabStrip.dll
documents-32x32.png
Properties
Settings.settings
Resources
folder-documents.ico
Thumbs.db
Thumbs.db
Window Tabifier.csproj.user
window.cd
Windows-Desktop-32x32.png
windowtabifier_srcvs2008.zip
WindowTabifier_srcVS2008
Window Tabifier
bin
DLLs
About.dll
DragAndDropFileComponent.dll
TabStrip.dll
documents-32x32.png
folder-documents.ico
Properties
Settings.settings
Thumbs.db
Window Tabifier.csproj.user
window.cd
Windows-Desktop-32x32.png
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using System.Security.Permissions;
using System.Security;

namespace WindowTabifier
{
    public partial class Main : Form
    {
        Properties.Settings set = Properties.Settings.Default;
        About.AboutBox box = new About.AboutBox("Window Tabifier");

        public Main()
        {
            InitializeComponent();

            rdbExeIcon.Checked = !rdbWindowIcon.Checked;

            box.programname = "Window Tabifier";
            box.StartPosition = FormStartPosition.CenterScreen;
            box.BackColor = Color.SandyBrown;
        }

        private bool isstartup()
        {
            bool result = false;
            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
            result = key.GetValue("Window Tabifier") != null;
            key.Close();
            return result;
        }

        [RegistryPermissionAttribute(SecurityAction.LinkDemand, Write = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run")]
        private void startup(bool add)
        {
            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
            if (add)
            {
                key.SetValue("Window Tabifier", "\"" + Application.ExecutablePath + "\"");
            }
            else
                key.DeleteValue("Window Tabifier", false);

            key.Close();
        }

        private void Exit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            if (!System.IO.File.Exists(Application.StartupPath + "\\Window Tabifier.exe.config"))
            {
                MessageBox.Show("Configuration file not found.", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                Application.Exit();
            }
            System.IO.Directory.SetCurrentDirectory(Application.StartupPath);
            winapi.statusbar = winapi.FindWindow("Shell_TrayWnd", "");

            set.Startup = isstartup();
            Tray.ShowBalloonTip(5);
            this.Hide();
        }

        private void Tab_Click(object sender, EventArgs e)
        {
            WindowList wnd = new WindowList();
            if (wnd.ShowDialog() == DialogResult.OK && wnd.SelectedWindows.Count>0)
            {
                Host hostform = new Host(wnd.SelectedWindows);
                hostform.Show();
                wnd.Dispose();
            }
        }

        private void tabAll_Click(object sender, EventArgs e)
        {
            Host hostwindow = null;
            if (Properties.Settings.Default.Ignore)
            {
                hostwindow = new Host(window.GetOpenWindows().FindAll(delegate(window wnd) { return wnd.Title.Length > 0 && wnd.GetExecutablePath() != Application.ExecutablePath; }));
            }
            else
            {
                hostwindow = new Host(window.GetOpenWindows().FindAll(delegate(window wnd) { return wnd.GetExecutablePath() != Application.ExecutablePath; }));
            }
            hostwindow.Show();
        }

        private void Tray_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (!this.Visible)
            {
                this.Show();
                this.WindowState = FormWindowState.Normal;
            }
        }

        private void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            startup(startupCheck.Checked);

            set.Save();

            if (e.CloseReason == CloseReason.UserClosing)
            {
                this.Hide();
                e.Cancel = true;
            }
        }

        private void About_Click(object sender, EventArgs e)
        {
            if (!box.Visible)
            {
                box.ShowDialog();
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Giorgi Dalakishvili
Software Developer
Georgia Georgia
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150728.1 | Last Updated 29 Mar 2008
Article Copyright 2008 by Giorgi Dalakishvili
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid