Adding an event handler in a sub

  • Thread starter Thread starter Just Me
  • Start date Start date
J

Just Me

I need to create a library sub that adds event handlers to a control.
Public Shared Sub AddEvent(ByVal qq As Control, By?? ControlMouseMove As ??)

So I need to pass the address of the handler or equivalent so that I can

AddHandler qq.MouseMove, AddressOf ControlMouseMove



Anyone know how to do that?





Thanks
 
You can do something like

Public Sub AddEvent(ByVal qq As Control, ByVal handler As EventHandler)
AddHandler qq.MouseMove, handler
End Sub

You would call it like this:

Dim eHandler As New EventHandler(AddressOf ControlMouseMove)
AddEvent(Button1, eHandler)

Craig VB.Net Team
 
Thanks. I tried it and it works great.

Craig, I know you know something about the RichTextBox so I'd appreciate it
if you'd take a minute to read my last post under Using Regular Expressions
with a RichTextBox, Aug 11.

Should I just forget it!

No one seems to know anything about it.

Even a hint as to where I can go to get more info would be greatly
appreciated.

I've been looking for some time now.

Thanks again for the reply below.
 
Thanks. I tried it and it works great.

Craig, I know you know something about the RichTextBox so I'd appreciate it
if you'd take a minute to read my last post under Using Regular Expressions
with a RichTextBox, 8/12/2004 8.54 AM

Should I just forget it!

No one seems to know anything about it.

Even a hint as to where I can go to get more info would be greatly
appreciated.

I've been looking for some time now.

Thanks again for the reply below.
 
I don't know a lot about the RichTextBox, but from what I can gather in the documentation, this isn't directly supported. Here's a url, however, that may help.

http://www.knowdotnet.com/articles/regexandrichtextbox.html

Craig VB.Net Team
--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).

--------------------
From: " Just Me" <[email protected]>
References: <[email protected]> <[email protected]>
Subject: Re: Adding an event handler in a sub
Date: Sat, 14 Aug 2004 09:19:09 -0400
Lines: 39
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <uXB#[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: h26.d169bd.dial.xtelegent.net 209.105.189.26
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:222957
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Thanks. I tried it and it works great.

Craig, I know you know something about the RichTextBox so I'd appreciate it
if you'd take a minute to read my last post under Using Regular Expressions
with a RichTextBox, 8/12/2004 8.54 AM

Should I just forget it!

No one seems to know anything about it.

Even a hint as to where I can go to get more info would be greatly
appreciated.

I've been looking for some time now.

Thanks again for the reply below.



Craig Vick said:
You can do something like

Public Sub AddEvent(ByVal qq As Control, ByVal handler As EventHandler)
AddHandler qq.MouseMove, handler
End Sub

You would call it like this:

Dim eHandler As New EventHandler(AddressOf ControlMouseMove)
AddEvent(Button1, eHandler)

Craig VB.Net Team

Thanks & Regards
Santhosh Somayajulu
Internet Information Services Team,
Microsoft
 
Thanks for the reply. I had seen that page but he works on the text property
rather that the box doing it.
I don't know what documentation you've seen but if you search for
tommatchpattern you find things like:

STDMETHODIMP FindTextEnd( BSTR bstr,
long Count,
long Flags,
long *pLength
);
Parameters
--snip--
Flags
Flags governing comparisons.
It can be zero (the default) or any combination of the following values.
tomMatchWord 2 Matches whole words.
tomMatchCase 4 Matches case.
tomMatchPattern 8 Matches regular expressions.

--snip--

Thanks again



Craig Vick said:
I don't know a lot about the RichTextBox, but from what I can gather in
the documentation, this isn't directly supported. Here's a url, however,
that may help.
http://www.knowdotnet.com/articles/regexandrichtextbox.html

Craig VB.Net Team
--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).

--------------------
From: " Just Me" <[email protected]>
References: <[email protected]>
 
As far as I can see, the .Net RichTextBox doesn't expose anything like this (it would be nice if it did). The API below maybe for another RichTextBox control
(though I looked at the VB6 control, and it didn't support this either).

Craig VB.Net Team
--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).

--------------------
From: " Just Me" <[email protected]>
References: <[email protected]> <[email protected]> <uXB#KFggEHA.3676
@TK2MSFTNGP12.phx.gbl> said:
Subject: Re: Adding an event handler in a sub
Date: Fri, 20 Aug 2004 22:14:22 -0400
Lines: 106
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <#[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
NNTP-Posting-Host: h121.d169bd.dial.xtelegent.net 209.105.189.121
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.languages.vb:224838
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Thanks for the reply. I had seen that page but he works on the text property
rather that the box doing it.
I don't know what documentation you've seen but if you search for
tommatchpattern you find things like:

STDMETHODIMP FindTextEnd( BSTR bstr,
long Count,
long Flags,
long *pLength
);
Parameters
--snip--
Flags
Flags governing comparisons.
It can be zero (the default) or any combination of the following values.
tomMatchWord 2 Matches whole words.
tomMatchCase 4 Matches case.
tomMatchPattern 8 Matches regular expressions.

--snip--

Thanks again




the documentation, this isn't directly supported. Here's a url, however,
that may help.

Thanks & Regards
Santhosh Somayajulu
Internet Information Services Team,
Microsoft
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top