各位求救!

zhaochengqing 2004-10-22 09:38:41
我现在有一个这样的问题,我要把Text控件的Text设置为不可写只可读,我想用LOCKED属性,可是这样的话还是可以用“粘贴”还是可以改变文本框的内容,大家帮我想想办法,谢谢!
...全文
62 点赞 收藏 5
写回复
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
adong1980 2004-10-22
在Form_Load里面加
prvWinProc = GetWindowLong(Text1.hwnd, GWL_WNDPROC)
'设定Combo1的window Procedure到wndproc
ret = SetWindowLong(Text1.hwnd, GWL_WNDPROC, AddressOf DoNothing)

Form……Unload里加
ret = SetWindowLong(Text1.hwnd, GWL_WNDPROC, prvWinProc)

共用模块里加

Public prvWinProc As Long
Public ret As Long

Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public 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
Public Const WM_PASTE = &H302
Public Const GWL_WNDPROC = (-4)

Public Function DoNothing(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

If Msg = WM_PASTE Then
'Debug.Print Form1.hwnd & "ssf" & hwnd
Msg = 0
End If
DoNothing = CallWindowProc(prvWinProc, hwnd, Msg, wParam, lParam)
End Function
回复
duanjunjun 2004-10-22
你看这行嘛!
先得到哪个文本框的值,在第的Change事件里,加入 文本.值=先前得到的值
回复
zhaochengqing 2004-10-22
我是这样用的,可是这样的话那字就成了灰色的啦,不显眼听啦
还有没有别的方法啊?
回复
fxyfx 2004-10-22
Enable=False
回复
flyingZFX 2004-10-22
Enabled=False

就可以了,
回复
发动态
发帖子

1180

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
社区公告
暂无公告