




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
開通黃鉆寒假總結(jié)(2)鼠標(biāo)鍵盤系統(tǒng)的基本操作usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;namespace鼠標(biāo)
{
publicpartialclassForm1:Form
{
MessageFiltermf=newMessageFilter();
publicForm1()
{
InitializeComponent();
}
privatevoidForm1_MouseDown(objectsender,MouseEventArgse)
{//獲取鼠標(biāo)點擊時位置XY坐標(biāo)
this.label1.Text=e.X.ToString();
this.label2.Text=e.Y.ToString();
}
privatevoidtextBox1_MouseDown(objectsender,MouseEventArgse)
{//獲取鼠標(biāo)操作操作
stringstr=textBox1.Text;
if(e.Button==MouseButtons.Right)
{
textBox1.Text+="鼠標(biāo)右擊點下";
}
if(e.Button==MouseButtons.Left)
{
textBox1.Text+="鼠標(biāo)左擊點下";
}
if(e.Button==MouseButtons.Middle)
{
textBox1.Text+="鼠標(biāo)中間點下";
}
if(e.Button==MouseButtons.None)
{
textBox1.Text+="未按鼠標(biāo)";
}
}
privatevoidForm1_Load(objectsender,EventArgse)
{
//添加消息篩選器以便在向目標(biāo)傳送Windows消息時監(jiān)視這些消息
Application.AddMessageFilter(mf);
}
//從窗體中移除一個消息篩選器
privatevoidFrm_Main_FormClosing(objectsender,FormClosingEventArgse)
{
//從應(yīng)用程序的消息泵移除一個消息篩選器
Application.RemoveMessageFilter(mf);
}
//方法一,重寫WndProc虛方法,與方法二不可同時存在
protectedoverridevoidWndProc(refMessagem)
{
switch(m.Msg)//判斷系統(tǒng)消息的ID號
{
case513:
MessageBox.Show("單擊了鼠標(biāo)左鍵!","系統(tǒng)信息");
m.Result=(IntPtr)0;//為了響應(yīng)消息處理而向Windows返回的值
break;
case516:
MessageBox.Show("單擊了鼠標(biāo)右鍵!","系統(tǒng)信息");
m.Result=(IntPtr)0;//為了響應(yīng)消息處理而向Windows返回的值
break;
default:
base.WndProc(refm);
break;
}
}
}
//方法二,實現(xiàn)IMessageFilter接口,從而獲得Windows消息,與方法一不可同時存在
publicclassMessageFilter:IMessageFilter
{
publicboolPreFilterMessage(refMessagemessage)
{
switch(message.Msg)//判斷系統(tǒng)消息的ID號
{
this.Cursor=newCursor(Cursor.Current.Handle);//創(chuàng)建cursor對象
Cursor.Position=newPoint(Cursor.Position.X,Cursor.Position.Y);//設(shè)置鼠標(biāo)位置
Cursor.Clip=newRectangle(this.Location,this.Size);//設(shè)置鼠標(biāo)的活動區(qū)域
}
privatevoidbutton2_Click(objectsender,EventArgse)
{
Screen[]screens=Screen.AllScreens;//獲取顯示的數(shù)組
this.Cursor=newCursor(Cursor.Current.Handle);//創(chuàng)建Cursor對象
Cursor.Clip=screens[0].Bounds;//接觸對鼠標(biāo)活動區(qū)域的限制
}
publicboolG_OnMouseDown=false;//標(biāo)識,用來控制畫圖
publicPointlastPoint=Point.Empty;//定義繪圖開始點
publicPenpen;//聲明畫筆
publicGraphicsgraphics;//聲明繪圖對象
privatevoidForm2_MouseMove(objectsender,MouseEventArgse)
{
if(lastPoint.Equals(Point.Empty))//判斷繪圖開始點是否為空
{
lastPoint=newPoint(e.X,e.Y);//記錄鼠標(biāo)當(dāng)前位置
}
if(G_OnMouseDown)//開始繪圖
{
PointcruuPoint=newPoint(e.X,e.Y);//獲取鼠標(biāo)當(dāng)前位置
graphics.DrawLine(pen,cruuPoint,lastPoint);//繪圖
}
lastPoint=newPoint(e.X,e.Y);//記錄鼠標(biāo)當(dāng)前位置
}
privatevoidForm2_MouseUp(objectsender,MouseEventArgse)
{
G_OnMouseDown=false;//開始繪圖標(biāo)識設(shè)置為false
}
privatevoidForm2_MouseDown(objectsender,MouseEventArgse)
{
G_OnMouseDown=true;//開始繪圖標(biāo)識設(shè)置為true````
}
}
}
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;namespace鍵盤
{
publicpartialclassForm1:Form
{
publicForm1()
{
InitializeComponent();
}
privatevoidtextBox1_KeyDown(objectsender,KeyEventArgse)
{
/*if((e.Control==true)&&(e.KeyCode==Keys.A))
{
MessageBox.Show("你按下了ctrl+A","系統(tǒng)",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning);
}*/
}
privatevoidForm1_Load(objectsender,EventArgse)
{
Form1f=newForm1();
f.KeyPreview=true;
}
///<summary>
///移動窗體
///</summary>
///<paramname="sender"></param>
///<paramname="e"></param>
privatevoidForm1_KeyDown(objectsender,KeyEventArgse)
{
Pointpoint=this.Location;
switch(e.KeyData)//判斷按鍵類型
{
caseKeys.Up:
point.Y-=2;
break;
case
Keys.Down:
point.Y+=2;
break;
caseKeys.Right:
point.X+=2;
break;
caseKeys.Left:
point.X-=2;
break;
caseKeys.Escape:
this.Close();
break;
default:break;
}
this.Location=point;
}
/*
privatevoidForm1_KeyDown(objectsender,KeyEventArgse)
{
if(e.Alt&&e.KeyCode==Keys.F4)//鍵值115
{
e.Handled=true;//不執(zhí)行操作
}
if(e.KeyCode==Keys.F1)
{
MessageBox.Show("王延領(lǐng)按下了f1","提示");
}
}
privatevoidForm1_KeyUp(objectsender,KeyEventArgse)
{
if(e.KeyData==Keys.Escape)//按下esc時
{
if(MessageBox.Show("是否關(guān)閉程序","提示信息",MessageBoxButtons.YesNo)==DialogResult.Yes)
{
Application.Exit();
}
}
}
privatevoidrichTextBox1_KeyDown(objectsender,KeyEventArgse)
{
if(e.Control&&e.KeyCode==Keys.V)
{
e.Handled=true;//屏蔽CRTRL+V
}
if(e.Control&&e.KeyCode==Keys.X||e.KeyCode==Keys.C)
{
e.Handled=true;
}
}
privatevoidtextBox1_KeyPress(objectsender,KeyPressEventArgse)
{//釋放后發(fā)生事件
if(e.KeyChar==13)
{
e.Handled=true;//關(guān)閉敲回車鍵嘀的聲音
}
}
///<summary>
///輸入法的打開與關(guān)閉
///</summary>
///<paramname="sender"></param>
///<paramname="e"></param>
privatevoidbutton1_Click(objectsender,EventArgse)
{
this.textBox1.ImeMode=ImeMode.Off;//關(guān)閉輸入法
}
privatevoidbutton2_Click(objectsender,EventArgse)
{
this.textBox1.ImeMode=ImeMode.On;
}
privatevoidForm1_Load(objectsender,EventArgse)
{
Form1f=newForm1();
f.KeyPreview=true;//接受案件控件
}
/*
[System.Runtime.InteropServices.DllImport("user32",EntryPoint="GetKeyState")]//重寫Api
publicstaticexternintGetKeyState(intintkey);
privatevoidbutton1_Click(objectsender,EventArgse)
{
stringstr="判斷numlockhrcapslock鍵是否鎖定:\n";
intintnumlock=GetKeyState(144);//判斷numlock鍵
if(intnumlock==0)
{
str+="numlock未鎖定\n";
}
else{
str+="numlock已鎖定\n";
}
intintcapslock=GetKeyState(20);
if(intcapslock==0)
{
str+="caplock未鎖定\n";
}
else
{
str+="caplock已鎖定\n";
}
MessageBox.Show(str,"判斷");
}
privatevoidtextBox1_KeyDown_1(objectsender,KeyEventArgse)
{
if(e.KeyValue==13)//如果鍵值為13(回車鍵)
{
SendKeys.Send("{TAB}");//發(fā)送TAB命令
}
}
privatevoidtextBox2_KeyDown(objectsender,KeyEventArgse)
{
if(e.KeyValue==13)
{
SendKeys.Send("{TAB}");
}
}*/
}
}
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;namespace系統(tǒng)
{
publicpartialclassForm1:Form
{
publicForm1()
{
InitializeComponent();
}
privatevoidForm1_Load(objectsender,EventArgse)
{
label1.Text="當(dāng)前時間是:"+DateTime.Now.ToString();//獲取現(xiàn)在時間
label2.Text="當(dāng)前系統(tǒng)目錄"+Environment.SystemDirectory;
label3.Text="計算機名稱:"+Environment.MachineName;
label4.Text="當(dāng)前運行目錄:"+Environment.CurrentDirectory;
label5.Text="系統(tǒng)版本號:"+Environment.OSVersion.VersionString;
textBox1.Text=(Environment.TickCount/1000).ToString()+"秒";//獲取啟動后經(jīng)過的時間
}
privatevoidtimer1_Tick(objectsender,EventArgse)
{
textBox1.Text=(Environment.TickCount/1000).ToString()+"秒";
}
}
}
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Collections;
namespace獲取系統(tǒng)環(huán)境變量
{
publicpartialclassForm1:Form
{
publicForm1()
{
InitializeComponent();
}
privatevoidForm1_Load(objectsender,EventArgse)
{
listView1.View=View.Details;//設(shè)置控件顯示方式
listView1.GridLines=true;//是否顯示網(wǎng)格
listView1.Columns.Add("環(huán)境變量",150,HorizontalAlignment.Left);//添加列標(biāo)頭
listView1.Columns.Add("變量值",150,HorizontalAlignment.Left);//添加列標(biāo)頭
ListViewItemmyItem;//創(chuàng)建ListViewItem對象
//獲取系統(tǒng)環(huán)境變量及對應(yīng)的變量值,并顯示在ListView控件中
foreach(DictionaryEntryDEntryinEnvironment.GetEnvironmentVariables())
{
myItem=newListViewItem(DEntry.Key.ToString(),0);//創(chuàng)建ListViewItem對象
myItem.SubItems.Add(DEntry.Value.ToString());//添加子項集合
listView1.Items.Add(myItem);//將子項集合添加到控件中
}
}
}
}
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;namespace獲取所有邏輯分區(qū)
{
publicpartialclassForm1:Form
{
publicForm1()
{
InitializeComponent();
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
listFolders(comboBox1);
}
publicvoidlistFolders(ComboBoxtscb)//獲取本地磁盤目錄
{
string[]logicdrives=System.IO.Directory.GetLogicalDrives();//獲取本地邏輯分區(qū)的數(shù)組
for(inti=0;i<logicdrives.Length;i++)//遍歷數(shù)組
{
tscb.Items.Add(logicdrives[i]);//將數(shù)組中的項目添加到ComboBox控件中
tscb.SelectedIndex=0;//設(shè)置第一項被選中
}
}
privatevoidcomboBox1_SelectedIndexChanged(objectsender,EventArgse)
{
try
{
System.IO.DriveInfo[]drive=System.IO.DriveInfo.GetDrives();//獲取所有磁盤驅(qū)動
for(inti=0;i<drive.Length;i++)//遍歷數(shù)組
{
if(comboBox1.SelectedItem.ToString()==drive[i].Name)//判斷遍歷到的想是否與下拉框中的項相同
{
label1.Text="總空間"+drive[i].TotalSize/1024/1024/1024+"G";
label2.Text="剩余空間"+drive[i].TotalFreeSpace/1024/1024/1024+"G";
label3.Text="已用空間"+(drive[i].TotalSize-drive[i].TotalFreeSpace)/1024/1024/1024+"G";
}
if(comboBox1.SelectedItem.ToString()==drive[i].Name)
{
if(drive[i].IsReady)
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 生日蛋糕訂購合同范本
- 2025年西安肉夾饃店鋪轉(zhuǎn)讓合同
- 2025工程合同管理策略
- 電池制造與高速公路電子收費考核試卷
- 家庭影院座椅布局建議考核試卷
- 種子批發(fā)商綠色營銷與環(huán)保意識考核試卷
- 統(tǒng)編版語文六年級下冊《語文園地二》精美課件
- 什么的心聲初一語文作文
- 難忘的一節(jié)語文課初一作文范文
- 模具行業(yè)創(chuàng)新驅(qū)動與商業(yè)模式研究考核試卷
- (四調(diào))武漢市2025屆高中畢業(yè)生四月調(diào)研考試 數(shù)學(xué)試卷(含答案詳解)
- 2024年中國礦產(chǎn)資源集團大數(shù)據(jù)有限公司招聘筆試真題
- 2025年河南機電職業(yè)學(xué)院單招職業(yè)技能測試題庫及參考答案
- 超越廣告-南京林業(yè)大學(xué)中國大學(xué)mooc課后章節(jié)答案期末考試題庫2023年
- 2022屆上海市16區(qū)高三語文一模分類匯編三:文學(xué)文本閱讀 試卷(原卷版+解析版)
- DB37T 3717-2019 電動汽車充電站驗收規(guī)范
- TK305水噴砂方案
- 先進加工技術(shù)--水切割技術(shù)PPT
- 危廢處置方案完全示范版
- 沁園春·疊嶂西馳.中職課件電子教案
- 《第十三章:牙頜面畸形》PPT課件
評論
0/150
提交評論