Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Q: SendMessageTimeout

Status
Not open for further replies.

Kostarsus

Programmer
Nov 30, 2000
86
0
0
DE
Hi,

Today I'd read an API-Statement in the MSDN, where I have some problems to implement this statement in VB. The statement is like all statements in C++.

Here is the API-Statement:

SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,
(LPARAM) "Environment", SMTO_ABORTIFHUNG,
5000, &dwReturnValue);

Well, I've solved the problem of WM_SETTINGCHANGE. It is a problem because this windowmessage isn't in the WinApi32.txt textfile. So I use the message WM_WININICHANGE because it is of the same value. (I'd checked it in the header files of VC++)

Now my problem is the part (LPARAM) "Environment".
VB requires a long-value. You can't cast in VB like in VC++.
Now, any idea which value the 4th parameter should have?
I tried 0 but than the statement throws an error (dwReturnValue was 0)

In reguards and hope for help
Kostarsus



 
in a module add the following code

Public Const HWND_BROADCAST As Long = &HFFFF&
Public Const WM_SETTINGCHANGE As Long = &H1A
Public Const SPI_SETNONCLIENTMETRICS As Long = &H2A
Public Const SMTO_ABORTIFHUNG As Long = &H2

Public Declare Function SendMessageTimeout Lib "user32" _
Alias "SendMessageTimeoutA" _
(ByVal hwnd As Long, ByVal msg As Long, _
ByVal wParam As Long, ByVal lParam As Long, _
ByVal fuFlags As Long, ByVal uTimeout As Long, _
lpdwResult As Long) As Long



and call the function like below(here module1 is module name
Call module1.SendMessageTimeout(HWND_BROADCAST, _
WM_SETTINGCHANGE, _
SPI_SETNONCLIENTMETRICS, _
0&, SMTO_ABORTIFHUNG,
10000&, success)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top