Solved

Getting messages from other controls.

Posted on 2002-07-04
12
142 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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