DESABILITA BOTÃO DIREITO

MILTONSILVA94 26/03/2016 12:21:18
#459929
Consigo simplificar a rotina abaixo? Pois tenho diversos campos [ô]text[ô] em vários form do meu projeto...

[ô]Rotina para bloqueio do botão direito do mouse
Private Sub RotinaBloqueioBotaoDireitoMouse()
OldWindowProc = SetWindowLong( _
txtNome.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtMatricula.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtNascimento.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtCpf.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtRg.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtEndereco.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtNumeroCasa.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtBairro.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtCidade.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtCep.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtBancoNumero.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtBancoNome.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtAgencia.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtContaCorrente.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtPisPasep.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtCtpsNumero.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtCtpsSerie.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtTituloEleitorNumero.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtTituloEleitorZona.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtTituloEleitorSecao.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtCnhNumero.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtNomeMae.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtNomePai.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtTelefoneResidencial.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtTelefoneCelular.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtDataAdmissao.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)

OldWindowProc = SetWindowLong( _
txtSalario.hwnd, GWL_WNDPROC, _
AddressOf NewWindowProc)
End Sub

Aguardo sugestões
MILTONSILVA94 28/03/2016 10:13:31
#459975

KURTGU 28/03/2016 10:49:28
#459980
Resposta escolhida
Aqui uma coisa que possa te ajudar, ele identifica todas as textbox de um formulario, e so voce ajustar...

www.jack.eti.br/limpando-todos-os-objetos-textbox-do-formulario-em-vb-funcoes-publicas/
MILTONSILVA94 28/03/2016 10:57:57
#459981
KURTGU meu problema é para desabilitar o botão direito do mouse nos campos text... Este link que me enviou é para limpar os campos text, kkkkkkkkkkkkkk
KURTGU 28/03/2016 11:06:00
#459986
Achei isto veja se funciona...

Declare Function SetWindowLong& Lib [Ô]user32[Ô] Alias [Ô]SetWindowLongA[Ô] (ByVal hwnd&, ByVal nIndex&, ByVal dwNewLong&)
Declare Function CallWindowProc& Lib [Ô]user32[Ô] Alias [Ô]CallWindowProcA[Ô] (ByVal lpPrevWndFunc&, ByVal hwnd&, ByVal uMsg&, ByVal wParam&, ByVal lParam&)
Const GWL_WNDPROC = (-4)
Dim lppwp& [ô](Long) Pointer to Previous Window Procedure
Function WindowProc&(ByVal hwnd&, ByVal uMsg&, ByVal wParam&, ByVal lParam&)
If uMsg = &H7B& Then uMsg = 0 [ô]Disable WM_CONTEXTMENU
WindowProc = CallWindowProc(lppwp, hwnd, uMsg, wParam, lParam)
End Function
Sub SetContextMenu(Txt As TextBox, bEnable As Boolean)
If bEnable Then
If lppwp Then SetWindowLong Txt.hwnd, GWL_WNDPROC, lppwp
Else
Dim Ret As Long
Ret = SetWindowLong(Txt.hwnd, GWL_WNDPROC, AddressOf WindowProc)
If lppwp = 0 Then lppwp = Ret
End If
End Sub

a

E sete os textboxes com:

SetContextMenu Text1, False

http://vbnet.mvps.org/index.html?code/subclass/contextmenu.htm

http://support.microsoft.com/kb/224302/pt

http://www.devx.com/vb2themax/Tip/18413


















MILTONSILVA94 28/03/2016 13:44:17
#460018
Showww KURTGU, agora sim muito obrigado
KURTGU 28/03/2016 14:08:38
#460021
Citação:

:
Showww KURTGU, agora sim muito obrigado



Que bom que Deu certo Abracos...E so encerrar o topico se sua duvida foi sanada fui...
Tópico encerrado , respostas não são mais permitidas