Solved

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

Posted on 2008-10-21
3
392 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 500 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

707 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