By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,239 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,239 IT Pros & Developers. It's quick & easy.

Receive SendMessage in VB 6.0

P: n/a
MCC
I need to send messages to a VB 6.0 exe with SendMessage (from a C++ app).
Anybody have sample code for a VB 6.0 message handler to receive SendMessage
or PostMessage commands?

Thanks.
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
<< I need to send messages to a VB 6.0 exe with SendMessage (from a C++
app).
Anybody have sample code for a VB 6.0 message handler to receive SendMessage
or PostMessage commands? >>

The safest trick is to send a seldom-used message for which VB defines a
form-level event handler. That way you can trap the message by just
handling the event. For example, you could send a WM_RBUTTONDOWN, showing
the <Ctrl> and <Alt> keys are pressed. In the form's MouseDown event
handler, look for this combo and execute your code if found.

You can subclass the form in VB6, allowing you to see the windows' messages
before VB does. Just call SetWindowLong with nIndex set to GWL_WNDPROC.
Pass the address of your new window procedure using the AddressOf keyword.

But be warned -- VB 6 programs that subclass forms (or any other window) are
inherently unstable. If they exit, while debugging or released, without
restoring the original Window procedure, Windows may crash afterwards.
Sending messages that trigger supported form events gets around that
problem.

Hope that helps.

Karen Kenworthy
http://www.karenware.com/
Nov 21 '05 #2

P: n/a
"MCC" <MC*@discussions.microsoft.com> schrieb:
I need to send messages to a VB 6.0 exe with SendMessage (from a C++ app).
Anybody have sample code for a VB 6.0 message handler to receive
SendMessage
or PostMessage commands?


<URL:http://www.thescarms.com/vbasic/PassString.asp>

Note that this is a VB.NET newsgroup. VB6-related questions should be
posted to appropriate groups in the "microsoft.public.vb.*" hierarchy.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.