国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
VB入門技巧N例(1)
1. 如何消除textbox中按下回車時(shí)的beep聲?
  1. Private Sub Text1_KeyPress(KeyAscii As Integer)
  2.   If KeyAscii = 13 Then
  3.      KeyAscii = 0
  4.   End If
  5. End Sub
復(fù)制代碼

2.Textbox獲得焦點(diǎn)時(shí)自動(dòng)選中。
  1. Private Sub Text1_GotFocus()
  2.   Text1.SelStart = 0
  3.   Text1.SelLength = Len(Text1.Text)
  4. End Sub
復(fù)制代碼


3.屏蔽textbox控件自身的右鍵菜單,并顯示自己的菜單。
方法一:
  1. Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y _
  2. As Single)
  3.    If Button = 2 Then
  4.      Text1.Enabled = False
  5.      Text1.Enabled = True
  6.      PopupMenu mymenu
  7.    End If
  8. End Sub
復(fù)制代碼


方法二:回調(diào)函數(shù)
  1. module:
  2. Option Explicit
  3. Public OldWindowProc As Long ' 保存默認(rèn)的窗口函數(shù)的地址
  4. Public Const WM_CONTEXTMENU = &H7B ' 當(dāng)右擊文本框時(shí),產(chǎn)生這條消息
  5. Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd _  
  6. As Long, ByVal nIndex As Long) As Long
  7. Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd _  As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  8. Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal _ lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  9. Public Function SubClass_WndMessage(ByVal hWnd As Long, ByVal Msg As Long, ByVal wp _
  10. As Long, ByVal lp As Long) As Long
  11. ' 如果消息不是WM_CONTEXTMENU,就調(diào)用默認(rèn)的窗口函數(shù)處理
  12. If Msg <> WM_CONTEXTMENU Then
  13.    SubClass_WndMessage = CallWindowProc(OldWindowProc, hWnd, Msg, wp, lp)
  14.    Exit Function
  15. End If
  16. SubClass_WndMessage = True
  17. End Function
  18. 窗體中:
  19. Private Const GWL_WNDPROC = (-4)
  20. Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y _  
  21. As Single)
  22. If Button = 1 Then Exit Sub
  23.    oldWindowProc = GetWindowLong(Text1.hWnd, GWL_WNDPROC) ' 取得窗口函數(shù)的地址
  24.       ' 用SubClass_WndMessage代替窗口函數(shù)處理消息
  25.    Call SetWindowLong(Text1.hWnd, GWL_WNDPROC, AddressOf SubClass_WndMessage)
  26. End Sub
  27. Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  28.   If Button = 1 Then Exit Sub
  29.     ' 恢復(fù)窗口的默認(rèn)函數(shù)
  30.     Call SetWindowLong(Text1.hWnd, GWL_WNDPROC, OldWindowProc)
  31.     PopupMenu mymenu
  32. End Sub
復(fù)制代碼

4. 設(shè)置TEXTBOX為只讀屬性
  1. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd _
  2. As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  3. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd _ As Long, ByVal nIndex As Long) As Long
  4. Private Const GWL_STYLE = (-16)
  5. Private Const EM_SETREADONLY = &HCF
  6. Private Sub Command1_Click()
  7.   Dim l As Long
  8.   If (GetWindowLong(Text1.hwnd, GWL_STYLE) And &H800) Then
  9.      Text1.Text = "This is a read/write text box."   '文本窗口是只讀窗口,設(shè)置為可讀寫窗口
  10.      l = SendMessage(Text1.hwnd, EM_SETREADONLY, False, vbNull)
  11.      Text1.BackColor = #ffffff   '將背景設(shè)置為白色
  12.      Command1.Caption = "Read&Write"
  13.    Else
  14.      Text1.Text = "This is a readonly text box."    '文本窗口是可讀寫窗口,設(shè)置為只讀窗口
  15.      l = SendMessage(Text1.hwnd, EM_SETREADONLY, True, vbNull)
  16.      Text1.BackColor = vbInactiveBorder   '將背景設(shè)置為灰色
  17.      Command1.Caption = "&ReadOnly"
  18.   End If
  19. End Sub
復(fù)制代碼






本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
使用messageboxtimeout api函數(shù)實(shí)現(xiàn)自動(dòng)關(guān)閉的msgbox
如何在VB中判斷Windows9x的運(yùn)行模式
API未公開函數(shù)解密
VBA常用代碼解析(第三十七講)
5行代碼 把cad窗體鑲?cè)氲阶砸训拇绑w
功能強(qiáng)大的SendMessage函數(shù) vb編程
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服