Total members 11890 |It is currently Sat Apr 20, 2024 1:22 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka






 Project Name:   Window Tabifier
 Programmer:   Giorgi Dalakishvili
 Type:   Application
 Technology:  C#
 IDE:   NONE
 Description:   This program allows to host several open Windows in one parent window so that you can easily access and navigate between them, as well as clean up space in the taskbar

Host.cs
csharp code
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;
using System.Diagnostics;
using System.Threading;
using FarsiLibrary.Win;

namespace WindowTabifier
{
public partial class Host : Form
{
private List<window> hostedwindows;

public Host(List<window> windows)
{
InitializeComponent();
hostedwindows = windows;
}

private void ProcessWindows(List<window> windows)
{
lock (tabs)
{
int startindex = tabs.Items.Count - 1;
for (int i = startindex; i < windows.Count; i++)
{
int count = tabs.Items.Add(new FATabStripItem(windows[i].Title, null));

windows[i].SetParent(tabs.Items[count].Handle);
windows[i].SetStyle(winapi.GWL_STYLE, (IntPtr)winapi.WS_VISIBLE);
windows[i].Move(tabs.Location, tabs.Items[0].Size, true);
}
}
}

private void Release(window wnd)
{
wnd.RestoreParent();
wnd.SetStyle(winapi.GWL_STYLE, (IntPtr)wnd.PreviousStyle);
wnd.RestoreLocation();
}


private void Host_Load(object sender, EventArgs e)
{
ProcessWindows(hostedwindows);
}

private void Host_FormClosing(object sender, FormClosingEventArgs e)
{
foreach (window wnd in hostedwindows)
{
Release(wnd);
}
}

private void Host_Resize(object sender, EventArgs e)
{
for (int i = 1; i < tabs.Items.Count; i++)
{
hostedwindows[i - 1].Move(tabs.Location, tabs.Items[0].Size, true);
}

if (this.WindowState==FormWindowState.Minimized && Properties.Settings.Default.Tray)
{
this.Hide();

hostTrayIcon.Icon = this.Icon;
hostTrayIcon.Visible = true;
hostTrayIcon.Text = this.Text;
hostTrayIcon.ShowBalloonTip(100);
}
}


private void tabs_TabStripItemClosing(TabStripItemClosingEventArgs e)
{
if (tabs.SelectedItem==tabs.Items[0])
{
e.Cancel = true;
return;
}

ActionForm act = new ActionForm();

if (act.ShowDialog() == DialogResult.OK)
{
int index=tabs.Items.IndexOf(e.Item)-1;

Release(hostedwindows[index]);

if (act.CloseWindow)
{
hostedwindows[index].Close();
}
hostedwindows.RemoveAt(index);
}
else
e.Cancel = true;
}

private void tabs_TabStripItemClosed(object sender, EventArgs e)
{
if (tabs.Items.Count == 1)
{
this.Close();
}
}

private void tabs_TabStripItemSelectionChanged(TabStripItemChangedEventArgs e)
{
if (e.ChangeType != FATabStripItemChangeTypes.Added)
{
this.Text = e.Item.Title;

int index = tabs.Items.IndexOf(e.Item);

if (e.ChangeType == FATabStripItemChangeTypes.Removed)
{
index -= 1;
}

Icon temp = null;

if (Properties.Settings.Default.WindowIcon)
{
temp = index > 0 ? hostedwindows[index - 1].WindowIcon : null;
}
else
{
temp = index > 0 ? hostedwindows[index - 1].ExecutableIcon : null;
}

if (index == 0 || temp == null)
{
this.Icon = Properties.Resources.ProgramIcon;
}
else
{
this.Icon = temp;
}
}
}

private void tabs_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyValue>48 && e.KeyValue<58 && tabs.Items.Count>=(e.KeyValue-48))
{
tabs.SelectedItem = tabs.Items[e.KeyValue - 49];
}
}

private void tabs_MouseMove(object sender, MouseEventArgs e)
{
FATabStripItem c = tabs.GetTabItemByPoint(e.Location);
if (c != null && Properties.Settings.Default.SelectonHover)
{
tabs.SelectedItem = tabs.Items[tabs.Items.IndexOf(c)];
}
}


private void dragAndDropFile_FileDropped(object sender, DragAndDropFileControlLibrary.FileDroppedEventArgs e)
{
ProcessFiles(e.Filenames);
}

private void OpenFileButton_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
ofd.Filter = "All Files|*.txt";

if (ofd.ShowDialog()==DialogResult.OK)
{
ProcessFiles(ofd.FileNames);
}
}


private void ProcessFiles(string[] files)
{
foreach (string filename in files)
{
if (!filename.EndsWith(".lnk"))
{
ParameterizedThreadStart thrparam = new ParameterizedThreadStart(ProcessFile);
Thread thr = new Thread(thrparam);
thr.Start(filename);
}
}

if (files.Length > 0)
{
tm.Enabled = true;
}
}

private void ProcessFile(object filename)
{
string path = filename as string;
if (File.Exists(path))
{
Process proc = Process.Start(path);

if (proc != null)
{
proc.WaitForInputIdle(5000);
if (proc.MainWindowHandle != IntPtr.Zero)
{
lock (hostedwindows)
{
hostedwindows.Add(new window(proc.MainWindowHandle));
}
}
proc.Dispose();
}
}
else
if (Directory.Exists(path))
{
int i = 0;
Process.Start(path);

IntPtr handle = IntPtr.Zero;
while (handle==IntPtr.Zero && i<5)
{
i++;
Thread.Sleep(1000);
handle = window.FindWindow("CabinetWClass", Path.GetFileName(path));
}

if (handle != IntPtr.Zero)
{
lock (hostedwindows)
{
hostedwindows.Add(new window(handle));
}
}
}
}


private void tm_Tick(object sender, EventArgs e)
{
ProcessWindows(hostedwindows);
tm.Enabled = false;
}

private void AddWindowButton_Click(object sender, EventArgs e)
{
WindowList wnd = new WindowList();
if (wnd.ShowDialog() == DialogResult.OK && wnd.SelectedWindows.Count > 0)
{
this.hostedwindows.AddRange(wnd.SelectedWindows);
wnd.Dispose();
ProcessWindows(hostedwindows);
}
}


private void hostTrayIcon_Click(object sender, EventArgs e)
{
this.Show();
this.WindowState = FormWindowState.Maximized;

hostTrayIcon.Visible = false;
hostTrayIcon.Icon = null;
}
}
}


Attachment:
WindowTabifier.jpg
WindowTabifier.jpg [ 42.82 KiB | Viewed 5131 times ]





Attachments:
WindowTabifier_srcVS2005.zip [127.86 KiB]
Downloaded 808 times
WindowTabifier_srcVS2008.zip [125.64 KiB]
Downloaded 870 times

_________________
Please recommend my post if you found it helpful. ,
java,j2ee,ccna ,ccnp certified .
Author:
Expert
User avatar Posts: 838
Have thanks: 2 time

updated.


_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : Window Tabifier
 Window 7 problem....     -  
 new window using javascript     -  
 Window Through C Language     -  
 Open in a new window help     -  
 BLACK WINDOW     -  
 GridLayout-window with buttons     -  
 difference between a Window and a Frame     -  
 Open a link in a new window?     -  
 How to start MFC window-programming     -  
 Set scope on main window     -  



Topic Tags

C# Projects
cron






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com