Solved

Getting messages from other controls.

Posted on 2002-07-04
12
143 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 

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 Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

809 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