For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > August 2005 > How to raise events on a reference to a control?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to raise events on a reference to a control?
Wendell Buckner

2005-08-29, 6:55 pm

Here's a little a background of what I'm trying to do...

Private Function ICommonHookUI_Init(Optional ByVal InitForm As Object,
Optional ByVal InitReadOnly As Boolean) As Boolean

Do

If InitForm Is Nothing Then Exit Do

Set m_InitForm = InitForm

Dim FoundUI As Boolean
Dim UIIndex As Long
Dim c As Control
Dim m As Menu

Const LookForUIName = "mnuCustomOptions"

For Each c In m_InitForm.Controls

FoundUI = (TypeOf c Is Menu)

Do

If Not FoundUI Then Exit Do

FoundUI = UCase$(c.Name) = UCase$(LookForUIName)

If Not FoundUI Then Exit Do

Set m_mnuUpload = c

m_mnuUpload.Caption = "&Upload Signatures"
m_mnuUpload.Visible = True

Loop Until True

If FoundUI Then Exit For

Next

ICommonHookUI_Init = True

Loop Until True

End Function

Now is there anyway for me to raise the "click" event on this menu item I
have a reference for? Also, I can't seem to declare my menu reference using
the "withevents" keyword? Can someone thell me why? I get a type mismatch
13? One last thing can then CallByName function be used to call an event on
a control?
--
Wendell Buckner/SQN Banking Systems


Ken Halter

2005-08-29, 6:55 pm

"Wendell Buckner" <wendellbuckner@sbcglobal.net> wrote in message
news:Q%GQe.650$v83.118@newssvr33.news.prodigy.com...
> Here's a little a background of what I'm trying to do...
>
>
> Now is there anyway for me to raise the "click" event on this menu item I
> have a reference for? Also, I can't seem to declare my menu reference
> using
> the "withevents" keyword? Can someone thell me why? I get a type mismatch
> 13? One last thing can then CallByName function be used to call an event
> on
> a control?
> --
> Wendell Buckner/SQN Banking Systems


You can't raise an event yourself. It's up to the control to raise any
events it exposes. Some have a method that allows you to do this, most
don't. You can easily add a procedure and call it from the click event and
anywhere else you need it.

WithEvents object variables must be module scope. The object you're trying
to "attach" to the WithEvents variable must not be part of a control array.

--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Please keep all discussions in the groups..


Jeff Johnson [MVP: VB]

2005-08-29, 6:55 pm


"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message
news:uO0GY2LrFHA.2880@TK2MSFTNGP12.phx.gbl...

> WithEvents object variables must be module scope. The object you're trying
> to "attach" to the WithEvents variable must not be part of a control
> array.


I didn't know that. I knew you couldn't have an array of WithEvents objects,
but I'd never heard that the target object couldn't be part of a control
array. But then again I'd never even try to do that in the first place, so I
guess that's why I never considered it....


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com