Window Messages


SharpE Messages

There are many custom messages used and broadcasted by SharpE. Not all of them are used anymore and some are only implemented to ensure that older components are working correctly. All messages are defined in SharpApi.pas. The most important and current window messages and broadcasts of SharpE will be desribed below:

WM_SHARPEUPDATESETTINGS
System wide broadcast when a SharpE setting changed. The wparam of this message contains a constant (defined in SharpApi?) which specifies the type of the setting which changed.

WM_SHARPEUPDATEACTIONS
An application receives this broadcast when the actions.service has been started. When the application receives this message after it already has registered actions with the service then it has to register the actions again because most likely the service has been restarted. Applications which are not using the SharpE Action system do not have to process this message.

WM_SHARPEACTIONMESSAGE
An application receives this message if a SharpE actions which was registered by this application has been executed. The message.lparam property contains the ID (integer) of the action which was executed.

WM_SHARPTERMINATE
When a SharpE related application receives this message it should save all settings and shut itself down as soon as possible. This message can be send directly to a single window or it can be used as a global system wide broadcast.
Not all SharpE components are using this message yet, any future component should handle this message[[BR]] The reason for this message is to replace WM_QUIT messages for shutting down components (WM_QUIT messages can sometimes cause unexpected problems because of differences between Formclose/Formdestroy events).

WM_WEATHERUPDATE
Is a system wide broadcast message if the weather.service is updating the weather data. All components and modules using the weather data should update the data when receiving this message.


System Messages

There are several messages broadcasted by the OS itself which can be very important for shell applications.

WM_DISPLAYCHANGE
The screen resolution has changed. Applcations might have to adjust their size and screen position.
Be carefully when handling this messages, it's also broadcasted if a any application/game is switching into full screen mode.
MSDN Library link

WM_POWERBROADCAST
This message is broadcasted to an application to notify it about power management events. The message.wParam value contains the power management event which was executed. An application handling this message must return True if the power management request is granted. To deny the request return BROADCAST_QUERY_DENY.
MSDN Library link

WM_COMPACTING
The message is sent to all top-level windows when the system detects more than 12.5 percent of system time over a 30- to 60-second interval is being spent compacting memory. This indicates that system memory is low. When an application receives this message, it should free as much memory as possible, taking into account the current level of activity of the application and the total number of applications running on the system.
MSDN Library link

WM_SETTINGCHANGE
To know when the wallpaper changes.

procedure WM_SETTINGCHANGE(var Message:TMessage); message WM_SETTINGCHANGE;

procedure TForm1.WM_SETTINGCHANGE(var Message:TMessage);
begin
  if (message.WParam = SPI_SETDESKWALLPAPER) 
    or (message.Msg = SPI_SETDESKWALLPAPER)  then //wallpaper changed
end;