真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net窗口實(shí)例的簡(jiǎn)單介紹

VB.NET 拖動(dòng)無邊框窗體編程實(shí)例

Imports System Drawing Imports System Windows Forms ****************************************** Private oOriginalRegion As Region = Nothing 用于窗體移動(dòng) Private bFormDragging As Boolean = False Private oPointClicked As Point ****************************************** Private Sub Form _MouseDown(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles MyBase MouseDown Me bFormDragging = True Me oPointClicked = New Point(e X e Y) End Sub ****************************************** Private Sub Form _MouseUp(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles MyBase MouseUp Me bFormDragging = False End Sub ****************************************** Private Sub Form _MouseMove(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles MyBase MouseMove If Me bFormDragging Then Dim oMoveToPoint As Point 以當(dāng)前鼠標(biāo)位置為基礎(chǔ) 找出目標(biāo)位置 oMoveToPoint = Me PointToScreen(New Point(e X e Y)) 根據(jù)開始位置作出調(diào)整 oMoveToPoint Offset(Me oPointClicked X * _ (Me oPointClicked Y + _ SystemInformation CaptionHeight + _ SystemInformation BorderSize Height) * ) 移動(dòng)窗體 Me Location = oMoveToPoint End If

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對(duì)這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡(jiǎn)單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:主機(jī)域名、虛擬主機(jī)、營(yíng)銷軟件、網(wǎng)站建設(shè)、亞東網(wǎng)站維護(hù)、網(wǎng)站推廣。

lishixinzhi/Article/program/ASP/201311/21755

如何給VB.NET窗體添加子窗體?

直接添加一個(gè)MID父窗體或在已有窗體的屬性中找到IsMDIContainer屬性,然后設(shè)置為True,然后創(chuàng)建第二個(gè)窗體 ,需要加載子窗體的時(shí)候:

Dim NewMDIChild As New Form2

NewMDIChild.MdiParent = Me

NewMDIChild.Show()

Public?Shared?Sub?CheckMDIChildForm(ByVal?MDIForm?As?Windows.Forms.Form,?ByVal?MDIChildForm?As?Windows.Forms.Form,?ByVal?MDIChildFormName?As?String)

If?MDIForm.MdiChildren.Length??1?Then

'如果沒有任何一個(gè)MDI子窗體,則創(chuàng)該MDI子窗體的窗體實(shí)例

Dim?MDIChildFrm?As?Windows.Forms.Form?=?MDIChildForm?'?定義MDI子窗體

MDIChildFrm.MdiParent?=?MDIForm?'指定父窗體

MDIChildFrm.Show()?'打開窗體

Exit?Sub

Else

Dim?x?As?Integer

Dim?frmyn?As?Boolean

For?x?=?0?To?(MDIForm.MdiChildren.Length)?-?1

Dim?tempChild?As?Windows.Forms.Form?=?CType(MDIForm.MdiChildren(x),?Windows.Forms.Form)

If?tempChild.Name?=?MDIChildFormName?Then

'檢測(cè)到有該MDI子窗體,設(shè)為激活?并退出循環(huán)

frmyn?=?True

tempChild.BringToFront()

Exit?For

Else

frmyn?=?False

End?If

Next

If?Not?frmyn?Then

'在打開的窗體中沒檢測(cè)到則新建

Dim?MDIChildFrm?As?Windows.Forms.Form?=?MDIChildForm?'?定義MDI子窗體

MDIChildFrm.MdiParent?=?MDIForm?'指定父窗體

MDIChildFrm.Show()?'打開窗體

End?If

End?If

End?Sub

vb.net實(shí)例化窗口后如何區(qū)分打開的窗口

If App.PrevInstance = True Then

End

End If

如果程序正在運(yùn)行,結(jié)束程序。

在模塊中加入每個(gè)窗口的標(biāo)題變量。

然后用if then 來判斷是否有相同窗口。

如果你事先不知道有哪些窗口的話,那你就用枚舉 FindWindow來查找子窗口句柄。再用SendMessage 獲得窗口標(biāo)題再進(jìn)行判斷。

求vb.net句柄實(shí)例,實(shí)現(xiàn)操作其他程序窗口。如我給的例子

Imports?System.Text

Imports?System.Runtime.InteropServices

Public?Class?Form1

'?相關(guān)API函數(shù)聲明,注釋掉的這里沒用到,但是也比較常用吧,這些函數(shù)的功能都能搜到。

Private?Declare?Function?FindWindow?Lib?"user32"?Alias?"FindWindowA"?(ByVal?lpClassName?As?String,?ByVal?lpWindowName?As?String)?As?IntPtr

Private?Declare?Function?FindWindowEx?Lib?"user32"?Alias?"FindWindowExA"?(ByVal?hWnd1?As?IntPtr,?ByVal?hWnd2?As?IntPtr,?ByVal?lpsz1?As?String,?ByVal?lpsz2?As?String)?As?IntPtr

Private?Delegate?Function?EnumChildProc(ByVal?hWnd?As?IntPtr,?ByVal?lParam?As?Integer)?As?Boolean

Private?Declare?Function?EnumChildWindows?Lib?"user32.dll"?(ByVal?hWndParent?As?IntPtr,?ByVal?lpEnumFunc?As?EnumChildProc,?ByVal?lParam?As?Integer)?As?Boolean

Private?Declare?Auto?Function?SendMessage?Lib?"User32.dll"?(ByVal?hWnd?As?IntPtr,?ByVal?Msg?As?Integer,?ByVal?wParam?As?Integer,?ByVal?lParam?As?String)?As?Integer

'Private?Declare?Function?CheckDlgButton?Lib?"user32"?Alias?"CheckDLGButtonA"?(ByVal?hDlg?As?IntPtr,?ByVal?nIDButton?As?IntPtr,?ByVal?wCheck?As?Integer)?As?Integer

Private?Declare?Function?GetClassName?Lib?"user32"?Alias?"GetClassNameA"?(ByVal?hWnd?As?IntPtr,?ByVal?lpClassName?As?StringBuilder,?ByVal?nMaxCount?As?Integer)?As?Integer

'Private?Declare?Function?GetWindowThreadProcessId?Lib?"user32"?Alias?"GetWindowThreadProcessId"?(ByVal?hwnd?As?IntPtr,?ByVal?lpdwProcessId?As?Long)?As?Integer

Private?Declare?Auto?Function?GetWindowTextLength?Lib?"user32"?Alias?"GetWindowTextLength"?(ByVal?hwnd?As?IntPtr)?As?Integer

Private?Declare?Function?GetWindowText?Lib?"user32"?Alias?"GetWindowTextA"?(ByVal?hwnd?As?IntPtr,?ByVal?lpString?As?StringBuilder,?ByVal?cch?As?Integer)?As?Integer

'?相關(guān)消息定義,也有沒用到的

Const?WM_SETTEXT?=?HC

Const?WM_GETTEXT?=?HD

'Const?WM_SETFOCUS?=?H7

'Const?WM_KILLFOCUS?=?H8

'Const?WM_CLOSE?=?H10

'Const?WM_SYSCOMMAND?=?H112

'Const?SC_CLOSE?=?HF060

'Const?SC_MINIMIZE?=?HF020

Const?BM_GETCHECK?=?HF0

Const?BM_SETCHECK?=?HF1

Const?BM_GETSTATE?=?HF2

Const?BM_SETSTATE?=?HF3

Const?BM_SETSTYLE?=?HF4

Const?BM_CLICK?=?HF5

'Const?BM_GETIMAGE?=?HF6

'Const?BM_SETIMAGE?=?HF7

Const?BST_UNCHECKED?=?O0

Const?BST_CHECKED?=?O1

Const?BST_INDETERMINATE?=?O2

'?儲(chǔ)存窗口句柄

Dim?WindowHandle?As?IntPtr

'?儲(chǔ)存兩個(gè)(或者多個(gè))編輯框句柄

Dim?EditHandle?As?New?List(Of?IntPtr)

Dim?EditWindowsText?As?List(Of?String)

'?儲(chǔ)存復(fù)選框句柄

Dim?CheckHandle?As?IntPtr?=?0

Private?Sub?Form1_Load(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?MyBase.Load

Button1_Click(sender,?e)

End?Sub

'?EnumChildWindows?回調(diào)函數(shù),該函數(shù)名作為API函數(shù)EnumChildWindows?的一個(gè)參數(shù)

'?該函數(shù)實(shí)現(xiàn)了枚舉各個(gè)子窗口,找出編輯框?qū)傩缘墓δ?/p>

Public?Function?EnumChildProcC(ByVal?hwnd?As?IntPtr,?ByVal?lParam?As?Integer)?As?Boolean

Dim?dwWindowClass?As?StringBuilder?=?New?StringBuilder(100)

'?獲得某一個(gè)句柄的類名

GetClassName(hwnd,?dwWindowClass,?100)

If?dwWindowClass.ToString.Contains("EDIT")?Or?dwWindowClass.ToString.Contains("Edit")?Then?????'?類名包含EDIT的為編輯框

EditHandle.Add(hwnd)????????????????????????'?存儲(chǔ)該句柄

End?If

'?返回?True?一直枚舉完

Return?True

End?Function

Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click

WindowHandle?=?FindWindow(vbNullString,?"登陸")

If?WindowHandle.ToInt32?=?0?Then

MsgBox("未捕獲到窗口"?+?"登陸")

Return

End?If

'?枚舉所有主窗口的子窗口(控件),枚舉時(shí)自動(dòng)調(diào)用回調(diào)函數(shù),完成編輯框句柄的獲取

EnumChildWindows(WindowHandle,?AddressOf?EnumChildProcC,?0)

'?尋找復(fù)選框

CheckHandle?=?FindWindowEx(WindowHandle,?IntPtr.Zero,?vbNullString,?"記住密碼")

Dim?str?As?New?StringBuilder

Dim?j?As?Integer?=?0

'?對(duì)編輯框文本賦值

For?j?=?0?To?EditHandle.Count?-?1

SendMessage(EditHandle(j),?WM_SETTEXT,?0,?"Text")

'GetWindowText(EditHandle(j),?str,?20)

'EditWindowsText.Add(Str.ToString)

'Str.Clear()

Next

If?EditHandle.Count?=?0?Then

MsgBox("未找到輸入框!")

End?If????????

If?CheckHandle.ToInt32??0?Then

'CheckDlgButton(WindowHandle,?id,?1)

'?對(duì)復(fù)選框進(jìn)行鼠標(biāo)單擊操作

SendMessage(CheckHandle,?BM_CLICK,?0,?0)

'SendMessage(CheckHandle,?BM_SETCHECK,?True,?0)

End?If

End?Sub

End?Class


網(wǎng)站名稱:vb.net窗口實(shí)例的簡(jiǎn)單介紹
瀏覽地址:http://weahome.cn/article/doisios.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部