VB程序設(shè)計(jì)報(bào)告格式.doc_第1頁
VB程序設(shè)計(jì)報(bào)告格式.doc_第2頁
VB程序設(shè)計(jì)報(bào)告格式.doc_第3頁
VB程序設(shè)計(jì)報(bào)告格式.doc_第4頁
VB程序設(shè)計(jì)報(bào)告格式.doc_第5頁
已閱讀5頁,還剩3頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

Visual Basic程序設(shè)計(jì)題目:看圖工具學(xué)生姓名: 學(xué)生班級(jí): 1102 指導(dǎo)教師: 提交日期:1. 看圖工具介紹(四號(hào)字,宋體,加粗) 實(shí)現(xiàn)簡單的看圖2. 程序界面圖1 看圖工具主界面3. 程序設(shè)計(jì)3.1 變量說明 定義一個(gè)記錄文件名及其路徑的變量 Dim strFilePath As String 用于設(shè)于PictureBox控件背景顏色變量 Dim bkcolor As Color 定義用于處理圖片拖動(dòng)的變量 PictureBox控件相對(duì)于其容器左上角的距離 Private m_Leftx As Integer Private m_Lefty As Integer 鼠標(biāo)當(dāng)前的位置 Dim m_MousePosX As Integer Dim m_MousePosY As Integer 圖像移動(dòng)的距離 Dim m_DriftX As IntegerDim m_DriftY As Integer3.2 過程說明l 使文件列表框的內(nèi)容跟著目錄列表框的選擇而變化 l DirListBox1_SelectedIndexChanged()l 賦初值,記下PictureBox1控件相對(duì)其容器左上角的距離l Form1_Load()l 使目錄列表框的內(nèi)容跟著驅(qū)動(dòng)器列表框的選擇而變化l DriveListBox1_SelectedIndexChanged()l 使目錄列表框的內(nèi)容跟著驅(qū)動(dòng)器列表框的選擇變化而變化l DriveListBox1_TextChanged()l 使文件列表框的內(nèi)容跟著目錄列表框的選擇而變化l DirListBox1_SelectedIndexChanged()l 單擊文件列表框的某項(xiàng)內(nèi)容時(shí)記下該文件的路徑及其名稱l FileListBox1_Click()雙擊文件列表框某個(gè)圖片,使之在圖片框中顯示 FileListBox1_DoubleClick()4. 源碼說明 使目錄列表框的內(nèi)容跟著驅(qū)動(dòng)器列表框的選擇而變化 Private Sub DriveListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DriveListBox1.SelectedIndexChanged DirListBox1.Path = DriveListBox1.Drive End Sub 使目錄列表框的內(nèi)容跟著驅(qū)動(dòng)器列表框的選擇變化而變化 Private Sub DriveListBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DriveListBox1.TextChanged DirListBox1.Path = DriveListBox1.Drive End Sub 使文件列表框的內(nèi)容跟著目錄列表框的選擇而變化 Private Sub DirListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DirListBox1.SelectedIndexChanged FileListBox1.Path = DirListBox1.Path End Sub 使文件列表框的內(nèi)容跟著目錄列表框的選擇變化而變化 Private Sub DirListBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DirListBox1.TextChanged FileListBox1.Path = DirListBox1.Path End Sub 單擊文件列表框的某項(xiàng)內(nèi)容時(shí)記下該文件的路徑及其名稱 Private Sub FileListBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FileListBox1.Click strFilePath = DirListBox1.Path & & FileListBox1.FileName End Sub 雙擊文件列表框某個(gè)圖片,使之在圖片框中顯示 Private Sub FileListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles FileListBox1.DoubleClick Try PictureBox1.Image = Image.FromFile(strFilePath) 在狀態(tài)欄中顯示此圖片文件的路徑及文件名 filename.Text = strFilePath Catch ex As Exception End TryEnd Sub Private Sub 原圖顯示ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 原圖顯示ToolStripMenuItem.Click PictureBox1.SizeMode = PictureBoxSizeMode.Normal End Sub Private Sub 自動(dòng)縮放圖片ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 自動(dòng)縮放圖片ToolStripMenuItem.Click PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage End Sub Private Sub 圖片居中ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 圖片居中ToolStripMenuItem.Click PictureBox1.SizeMode = PictureBoxSizeMode.CenterImage End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 賦初值,記下PictureBox1控件相對(duì)其容器左上角的距離 定義處理鼠標(biāo)按下的事件 當(dāng)鼠標(biāo)按下時(shí),將鼠標(biāo)變成手形,并且記錄下當(dāng)前鼠標(biāo)的位置 Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown Try Me.Cursor = System.Windows.Forms.Cursors.Hand m_MousePosX = e.X m_MousePosY = e.Y Catch ex As Exception End Try End Sub 定義處理鼠標(biāo)釋放的事件 處理鼠標(biāo)按鍵釋放的事件,根據(jù)鼠標(biāo)按下時(shí)保存的鼠標(biāo)位置,和當(dāng)前鼠標(biāo)的位置,計(jì)算鼠標(biāo)移動(dòng)偏移量,借此調(diào)用移動(dòng)圖片的函數(shù),移動(dòng)圖片 Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp Try 計(jì)算出鼠標(biāo)的偏移量 m_DriftX = m_MousePosX - e.X m_DriftY = m_MousePosY - e.Y 計(jì)算出新的PictureBox1控件相對(duì)其容器左上角的距離 m_Leftx = m_Leftx - m_DriftX m_Lefty = m_Lefty - m_DriftY picturemove(sender, e) 當(dāng)鼠標(biāo)釋放時(shí),將鼠標(biāo)還原為箭頭形狀 Me.Cursor = System.Windows.Forms.Cursors.Arrow Catch ex As Exception End Try End Sub 根據(jù)偏移量計(jì)算出圖片位置,重畫圖片 Private Sub picturemove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Try Dim myBit As New System.Drawing.Bitmap(PictureBox1.Image) Dim myPicGrh As System.Drawing.Graphics = Me.PictureBox1.CreateGraphics 清除整個(gè)繪圖畫面,并已指定的背景顏色填充 myPicGrh.Clear(Me.PictureBox1.BackColor) 在指定的位置使用圖像的原始物理大小繪制指定的圖像 myPicGrh.DrawImageUnscaled(myBit, m_Leftx, m_Lefty) myBit.Dispose() myPicGrh.Dispose() Catch ex As Exception End Try End Sub Private Sub 自動(dòng)縮放圖片框ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 自動(dòng)縮放圖片框ToolStripMenuItem.Click PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize End Sub 當(dāng)窗體大小發(fā)生變化時(shí)保證窗體上的界面元素不亂 Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize 使文件列表框的高度等于窗體高度一般,且會(huì)靠著底部顯示(由于Dock屬性設(shè)置為Bottom) FileListBox1.Height = Me.Height / 2 使目錄列表框的高度等于窗體高度一般再減去驅(qū)動(dòng)器列表框的高度,即讓它們緊挨著排列 DirListBox1.Height = Me.Height / 2 - DriveListBox1.Height 使 Panel2控件寬度等于窗體寬度減去 Panel1寬度,為了界面美觀再減去了 Panel2.Width = Me.Width - 199 PictureBox1.Width = Panel2.Width PictureBox1.Height = Panel2.Height End Sub Private Sub 退出ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 退出ToolStripMenuItem.Click Me.Close() End Sub Private Sub 背景色ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As Syst

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論