Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Getting messages from other controls.

Posted on 2002-07-04
12
Medium Priority
?
148 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

604 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