資源簡介
如何用C#做一個懸浮窗口程序?
網上有許多的教材但沒有源碼下載,自己寫了一個于大家分享,內附教程.
用C#做一個像FlashGet的懸浮窗口,其實很簡單,不像以前需要調用很多系統API。大致的步驟如下。
首先是主窗體部分,懸浮窗口部分

代碼片段和文件信息
//by?lonleung?2008-12-10?00:15
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
namespace?WindowsFormsApplication20
{
????public?partial?class?frmMain?:?Form
????{
????????public?frmMain()
????????{
????????????InitializeComponent();
????????}
????????private?FormWindowState?fwsPrevious;
????????private?frmTopMost?myTopMost;
????????private?void?frmMain_Load(object?sender?System.EventArgs?e)
????????{
????????????//?Save?window?state
????????????fwsPrevious?=?this.WindowState;
????????????//?Create?top?most?window
????????????myTopMost?=?new?frmTopMost(this);
????????}
????????private?void?frmMain_SizeChanged(object?sender?EventArgs?e)
????????{
????????????if?(this.WindowState?==?FormWindowState.Minimized)
????????????{
????????????????//?Window?minimized
????????????????//?Show?top?most?window
????????????????myTopMost.Show();
????????????????this.ShowInTaskbar?=?false;
????????????}
????????????else?if?(this.WindowState?!=?fwsPrevious)
????????????{
????????????????//?Save?current?window?state
????????????????fwsPrevious?=?this.WindowState;
????????????}
????????}
????????///?
????????///?Restore?window?state
????????///?
????????public?void?RestoreWindow()
????????{
????????????this.WindowState?=?fwsPrevious;
????????????this.ShowInTaskbar?=?true;
????????}
????????private?void?TOPToolStripMenuItem_Click(object?sender?EventArgs?e)
????????{
????????????myTopMost.Show();
????????}
????????private?void?mostToolStripMenuItem_Click(object?sender?EventArgs?e)
????????{
????????????Application.Exit();
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????string?strName?=?“功能“?+?Convert.ToString(this.tabControl1.TabPages.Count?+?1);
????????????string?strTap?=?“tabPage“?+?Convert.ToString(this.tabControl1.TabPages.Count);
????????????this.tabControl1.TabPages.Add(strTap?strName);
????????}
????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????int?seleIndex?=?tabControl1.SelectedIndex;
????????????this.tabControl1.TabPages.RemoveAt(seleIndex);
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????12800??2008-12-11?08:57??模仿迅雷浮動窗\WindowsFormsApplication20\bin\Debug\WindowsFormsApplication20.exe
?????文件??????36352??2008-12-11?08:57??模仿迅雷浮動窗\WindowsFormsApplication20\bin\Debug\WindowsFormsApplication20.pdb
?????文件??????14328??2008-12-11?08:56??模仿迅雷浮動窗\WindowsFormsApplication20\bin\Debug\WindowsFormsApplication20.vshost.exe
?????文件????????490??2007-07-21?01:33??模仿迅雷浮動窗\WindowsFormsApplication20\bin\Debug\WindowsFormsApplication20.vshost.exe.manifest
?????文件???????2346??2008-12-11?08:57??模仿迅雷浮動窗\WindowsFormsApplication20\Form1.cs
?????文件???????5279??2008-12-11?00:39??模仿迅雷浮動窗\WindowsFormsApplication20\Form1.Designer.cs
?????文件???????6019??2008-12-11?00:39??模仿迅雷浮動窗\WindowsFormsApplication20\Form1.resx
?????文件???????3039??2008-12-11?08:57??模仿迅雷浮動窗\WindowsFormsApplication20\frmTopMost.cs
?????文件???????3808??2008-12-10?23:29??模仿迅雷浮動窗\WindowsFormsApplication20\frmTopMost.Designer.cs
?????文件???????6019??2008-12-10?23:29??模仿迅雷浮動窗\WindowsFormsApplication20\frmTopMost.resx
?????文件???????2744??2008-12-11?08:56??模仿迅雷浮動窗\WindowsFormsApplication20\obj\Debug\WindowsFormsApplication20.csproj.FileListAbsolute.txt
?????文件????????910??2008-12-11?00:39??模仿迅雷浮動窗\WindowsFormsApplication20\obj\Debug\WindowsFormsApplication20.csproj.GenerateResource.Cache
?????文件??????12800??2008-12-11?08:57??模仿迅雷浮動窗\WindowsFormsApplication20\obj\Debug\WindowsFormsApplication20.exe
?????文件????????180??2008-12-11?00:39??模仿迅雷浮動窗\WindowsFormsApplication20\obj\Debug\WindowsFormsApplication20.frmMain.resources
?????文件????????180??2008-12-10?23:29??模仿迅雷浮動窗\WindowsFormsApplication20\obj\Debug\WindowsFormsApplication20.frmTopMost.resources
?????文件??????36352??2008-12-11?08:57??模仿迅雷浮動窗\WindowsFormsApplication20\obj\Debug\WindowsFormsApplication20.pdb
?????文件????????180??2008-12-10?22:48??模仿迅雷浮動窗\WindowsFormsApplication20\obj\Debug\WindowsFormsApplication20.Properties.Resources.resources
?????文件????????488??2008-12-10?22:44??模仿迅雷浮動窗\WindowsFormsApplication20\Program.cs
?????文件???????1406??2008-12-10?22:43??模仿迅雷浮動窗\WindowsFormsApplication20\Properties\AssemblyInfo.cs
?????文件???????2900??2008-12-10?22:43??模仿迅雷浮動窗\WindowsFormsApplication20\Properties\Resources.Designer.cs
?????文件???????5612??2008-12-10?22:43??模仿迅雷浮動窗\WindowsFormsApplication20\Properties\Resources.resx
?????文件???????1110??2008-12-10?22:43??模仿迅雷浮動窗\WindowsFormsApplication20\Properties\Settings.Designer.cs
?????文件????????249??2008-12-10?22:43??模仿迅雷浮動窗\WindowsFormsApplication20\Properties\Settings.settings
?????文件???????3746??2008-12-10?22:48??模仿迅雷浮動窗\WindowsFormsApplication20\WindowsFormsApplication20.csproj
?????文件????????965??2008-12-10?22:43??模仿迅雷浮動窗\WindowsFormsApplication20.sln
????..A..H.?????25088??2008-12-11?08:57??模仿迅雷浮動窗\WindowsFormsApplication20.suo
?????目錄??????????0??2008-12-10?22:44??模仿迅雷浮動窗\WindowsFormsApplication20\obj\Debug\Refactor
?????目錄??????????0??2008-12-10?22:43??模仿迅雷浮動窗\WindowsFormsApplication20\obj\Debug\TempPE
?????目錄??????????0??2008-12-10?22:45??模仿迅雷浮動窗\WindowsFormsApplication20\bin\Debug
?????目錄??????????0??2008-12-11?00:41??模仿迅雷浮動窗\WindowsFormsApplication20\obj\Debug
............此處省略9個文件信息
評論
共有 條評論