You need to be logged in to view a user's profile.
  1. Rebecca Tollfree
  2. PowerBuilder
  3. Wednesday, 13 March 2024 09:05 AM UTC

Hi all

I am using Windows10 and am struggling with sending a WM_SETTINGCHANGE message out.

According to the following article:

WM_SETTINGCHANGE message (Winuser.h) - Win32 apps | Microsoft Learn

I am supposed to use SendMessageTimeoutA

I can't seem to get my code to work without the application crashing.

Previously we have used SendMessageA , but since the desktop has upgraded to Win10 the application seems to hang when it gets to SendMessageA.

 

Does anyone have any example code of SendMessageTimeoutA for a WM_SETTINGCHANGE message. Specifically we are changing the international settings on the registry (dateformats, decimal places and so forth). This is a legacy application so I don't want to change the logic too drastically (# if it ain't broke) but I don't quite understand why the SendMessageA is no longer working. All I can think is that there has been a change to the user32.dll on microsoft so that WM_SETTINGCHANGE can no longer be broadcast using SendMessageA

 

Any advice would be gratefully received 

 

 

Rebecca Tollfree Accepted Answer Pending Moderation
  1. Wednesday, 13 March 2024 14:18 PM UTC
  2. PowerBuilder
  3. # 1

Hi John

 

This is a 32bit application. As to your question RE ANSI vs Unicode - this is a legacy application that I have inherited so I'm not sure of why it was done one way and not the other - presumably because it is quite old.

It was originally built on Powerbuilder 8, but we have now migrated onto Powerbuilder 2021 build 1509.

It was working before we migrated the desktops to Win 10 so I'm just not sure if something has changed on microsoft, or if there is a desktop setting that needs to be set somewhere :( I have to admit - I don't fully understand the microsoft help pages. I have checked my path variable and can see that the /system32/ folder is definitely included there

 

Code as per the below:

 

Local External function declaration:

FUNCTION LONG SendMessageA(LONG hWnd, UINT Msg, LONG wParam, STRING lParam) LIBRARY 'USER32.DLL' alias for "SendMessageA;Ansi"

 

 Function code :

//API Constant Declarations
CONSTANT LONG HWND_BROADCAST = 65535
CONSTANT UINT WM_SETTINGCHANGE = 26

//Registry Key
CONSTANT STRING REGKEY = 'HKEY_CURRENT_USER\Control Panel\International'

 //Return code variable

INTEGER li_rc
BOOLEAN lb_rc

 

//<some code here for updating international registry values>//


//We need to call API to let windows NT know that these changes have been made
//application hangs at sendmessageA
SendMessageA(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 'intl')
lb_rc = TRUE


RETURN lb_rc

Comment
  1. John Fauss
  2. Wednesday, 13 March 2024 17:44 PM UTC
In the intro to the Microsoft documentation for WM_SETTINGCHANGE:

https://learn.microsoft.com/en-us/windows/win32/winmsg/wm-settingchange

is this statement: This message cannot be sent directly to a window.

I don't know if this is a change from past Windows behavior or if Windows 7 and earlier allowed it while Windows 10 does not, but that statement seems pretty clear to me that you can't (or maybe more correrctly, can no longer) do what you are trying to do. The workaround described in the documentation is to use the SendMessageTimeoutA/W API function. The ANSI flavor of WinAPI functions should work OK, it just incurs unnecessary overhead for PB to perform translations between ANSI and Unicode when calling and returning from external functions.
  1. Helpful 1
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 13 March 2024 13:19 PM UTC
  2. PowerBuilder
  3. # 2

Hi, Rebecca -

Please post the external function declaration you are using for the SendMessageA API call, as well as the code that calls the external function. Is there a reason you are calling the ANSI implementation of this API instead of the Unicode one?

Also, what version/release/build of PB are you using, are you deploying as a 32-bit app or 64-bit?

Best regards, John

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.