Simple Question About SendMessage

microcephalic

Member
Joined
Nov 6, 2004
Messages
16
I am trying to figure out how to obtain the values needed to successfully execute a SendMessage Im using to try to close a dialog box.

My question is how do I figure out the value of my window (the hwnd value), the message I want to send (the wMsg value), and the remaing parameter values (wParam and lParam)?


Code:
  Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Integer, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Long) As Integer
 
You could always try the FindWindow API
Code:
Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, _
  ByVal Msg As Integer, ByVal wParam As UIntPtr, _
  ByVal lParam As IntPtr) As IntPtr

Declare Auto Function FindWindow Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

use like
Dim hWnd as IntPtr = FindWindow("", "<window caption here>")

and use the returned value as the first parameter to SendMessage. As to what you pass for the other 3 parameters depends on what you are trying to do. For a list of windows Messages you may want to Look on MSDN
 
Thanks, I found the name of the window now and checked out MSDN. It looks like I could use WM_COMMAND to help me "press" the save button on my dialog box. Would WM_COMMAND be the right choice to do something like this?

Thanks so much for your help!
 
Last edited by a moderator:

Similar threads

J
Replies
0
Views
116
josh_bauer2020
J
S
Replies
0
Views
221
sgrm123
S
Back
Top