Subclassing a ComboBox Paste Event
What I'm doing is subclassing a ComboBox and trying to disable pasting to it by blocking the WM_PASTE message. However, this doesn't work for some reason. So next I tried listing off all of the messages sent to the ComboBox to see what was being sent to it exactly. What I got confused me even more! Whenever I did a paste (by pressing either <SHIFT>+<INSERT> or <CTRL>+<V> ) these are the mesages that were intercepted:
- WM_COMMAND (&H111)
- wParam = 0400 03E9 (EN_UPDATE + identifier of control)
- lParam = 6D8 (the control handle)
- WM_CTLCOLOREDIT (&H133)
- wParam = 5EE (varies a control Device Context handle)
- lParam = 6D8 (the control handle)
- WM_COMMAND (&H11)
- wParam = 0300 03E9 (EN_CHANGE + identifier of control)
- lParam = 6D8 (the control handle)
OK, so that's all fine and dandy, but how the hell does the Edit portion of the ComboBox receive the/a paste message? I tried it repeatedly and I always got this combination of messages. The odd thing is that I can send (and intercept) a WM_PASTE message to the ComboBox and it works fine!
Can anybody explain to me what is going on?
Re: Subclassing a ComboBox Paste Event
Aaron Young, I need to block the copy and paste on my combobox and I tried this code of yours, but on the line between ''''
Public Sub SubClassComboEdit(ByRef oCombo As ComboBox)
Dim lHwnd As Long
If lPrevWndProc = 0 Then
''''''lHwnd = FindWindowEx(oCombo.hWnd, 0, "Edit", vbNullString)''''''
lPrevWndProc = SetWindowLong(lHwnd, GWL_WNDPROC, AddressOf CallBackProc)
End If
End Sub
It's coming an error 438.. How can I solve this problem? If u can see it for me, I uploaded it on it: http://rapidshare.com/files/418537411/teste_login.xls
Thanks a lot
PS: Some notes are in portuguese..
Re: Subclassing a ComboBox Paste Event
You do realise that this thread is over 10 years old don't you?
Error 438 means that the object does not support this property or method. In your case, a ComboBox in XL does not have a hwnd property.
Re: Subclassing a ComboBox Paste Event
hahahaha
No man.. I did'nt realised, because i'm a junior on VBA..
What can I do, you know?
I really need to block the paste and copy on the combobox, I tried many codes and variations till now, but I do not understand it as much it needs to work right :P