Solved

Getting messages from other controls.

Posted on 2002-07-04
12
138 Views
Last Modified: 2010-05-02
I want to create a control which has some other controls name and their some events name. when that event occur on that control, our control automatically calls its own particular function.
Thanks.  
0
Comment
Question by:AhmadKhan
  • 4
  • 4
  • 2
  • +2
12 Comments
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7131075
kindly elaborate!!

-priya
0
 

Author Comment

by:AhmadKhan
ID: 7131447
An ActiveX Control such as Mess1 placed on a Form, where
two more controls Text1 and Command1 placed:
when we write this code.
Mess1.controlName="Text1"
Mess1.controlEvent="change"
And when the change event of Text1 occurs a function of Mess1 say show() will be invoked.

Is it possible that any ActiveX control gets the messages of another control.
0
 
LVL 15

Expert Comment

by:ameba
ID: 7132390
Yes, that's possible.

For ActiveX controls which are not VB intrinsic controls, it's easy - using VBControlExtender object.

Dim WithEvents x As VBControlExtender

Private Sub x_ObjectEvent(Info As EventInfo)
    If Info.Name = yourEventname Then
        Beep ' do something
    End If
End Sub


For intrinsic VB controls (TextBox, PicturBox,...) there isn't such late bound mechanism to catch events.  You'll have to create helper classes for each type of such control.
Helper class will have a variable declared "WithEvents" and a bunch of delegation code for each type of event you want to handle.

There is a limitation - that won't work if control is in control array.  So, you'll have to check that and notify user that events are not supported.
0
 
LVL 6

Expert Comment

by:pierrecampe
ID: 7133002
ping
0
 

Author Comment

by:AhmadKhan
ID: 7133240
Thanks ameba
but can I use any Windows API function such as GetMessage()
b/c I want to capture any event of any control.
You can see "Spy" which comes with Visual Studio. I like this software.
0
 
LVL 15

Expert Comment

by:ameba
ID: 7133636
That is different - windows messages are not the same thing as events.
The technique to do that is Subclassing, and I do not like it - too hardcore and there is a problem with debugging such application.

Basically, you subclass your form:
Private Sub Form_Load()
     oldWndProc = SetWindowLong(Me.Hwnd, GWL_WNDPROC, AddressOf MyWndProc)
End Sub

and then catch all messages in a module, in MyWndProc() function.
http://coolvb.cooltech.org/subclass.shtml
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:AhmadKhan
ID: 7137230
Ya that is a good solution and I've find it on MSDN.
under this topic "Passing Function Pointers to DLL Procedures and Type Libraries"
it's a hook concept. but how can I hook multiple windows handles. plz first see the above topic on MSDN where u'll see this line Me.hook to hook form window.
Now I'm trying to solve this problem using this technique.
I'm very thankful to u.

0
 
LVL 15

Expert Comment

by:ameba
ID: 7137423
Sorry, I stopped answering EE questions because of some issues...  Do NOT accept my comment as answer.
0
 

Author Comment

by:AhmadKhan
ID: 7137518
Ok
0
 
LVL 6

Expert Comment

by:pierrecampe
ID: 7137620
ameba
Please do not leave us because some j...k thinks he does not have to follow ee guidelines
you have always been a great help to me in the past
and i only hope i can count on your help in the future
Thanks
Pierre
0
 
LVL 15

Expert Comment

by:ameba
ID: 8981459
AhmadKhan,
No comment has been added lately (380 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: PAQ and Refund

-- Please DO NOT accept this comment as an answer ! --

Moderator will finalize this question in 7 days.

Thanks,
ameba
acting as EE Cleanup Volunteer


--
Sorry for not returning here, I hope you found some component which does what you want.
Regards,
ameba
0
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9056087
Question is PAQ'd and points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now