Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
passing parameter in sql procedure 9 68
vb6 connector to SQL Server 2 41
Protecting vb6 & .Net code Obfuscation 18 181
Set email body to html using vbscript 6 70
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

685 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