Solved

How do I process Windows events (WndProc) through a VB DLL?

Posted on 2008-10-21
3
387 Views
Last Modified: 2012-06-27
I am writing a DLL that will make calls to an external device, and need to process Windows Messages to identify results.  I can do this in an exe by overridding WndProc, but with a DLL there is no Windows Handle (hWnd) available.
0
Comment
Question by:DerekOHara
  • 3
3 Comments
 
LVL 25

Expert Comment

by:SStory
Comment Utility
I guess you'd need to create a window using
CreateWindowEx api call--the old way.
http://msdn.microsoft.com/en-us/library/ms632680(VS.85).aspx

You could use this to make a hidden or taskbar window that could receive messages
0
 
LVL 25

Expert Comment

by:SStory
Comment Utility
This may also be a good refresher...

http://www.toymaker.info/Games/html/winmain.html
0
 
LVL 25

Accepted Solution

by:
SStory earned 500 total points
Comment Utility
Here, this page actually talks about doing what I suggested.
http://msdn.microsoft.com/en-us/library/ms632599(VS.85).aspx#message_only
You specify HWND_MESSAGE as the constant.

If this if VB6 you will declare like this:
Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long

If (vb.net)
Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Integer, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hwndParent As Integer, ByVal hMenu As Integer, ByVal hInstance As Integer, ByRef lpParam As Object) As Integer

(see http://www.webtropy.com/articles/art9-1.asp?f=CreateWindowEx)


0

Featured Post

What Security Threats Are You Missing?

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…

771 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

10 Experts available now in Live!

Get 1:1 Help Now