?
Solved

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

Posted on 2008-10-21
3
Medium Priority
?
393 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
[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
  • 3
3 Comments
 
LVL 25

Expert Comment

by:SStory
ID: 22770296
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
ID: 22770392
This may also be a good refresher...

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

Accepted Solution

by:
SStory earned 1500 total points
ID: 22770512
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
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…
Suggested Courses

741 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