Delphi: How to respond to WM_SettingChange/WM_WinIniChange?
Posted
by Ian Boyd
on Stack Overflow
See other posts from Stack Overflow
or by Ian Boyd
Published on 2010-05-12T19:13:57Z
Indexed on
2010/05/12
19:34 UTC
Read the original article
Hit count: 779
i need to know when my application recieves a WM_SETTINGCHANGE message (formerly known as WM_WININICHANGE).
Problem is that the message pump in TApplication sends it down a black hole (default handler) before i can get a chance to see it:
procedure TApplication.WndProc(var Message: TMessage);
...
begin
Message.Result := 0;
for I := 0 to FWindowHooks.Count - 1 do
if TWindowHook(FWindowHooks[I]^)(Message) then Exit;
CheckIniChange(Message);
with Message do
case Msg of
WM_SETTINGCHANGE:
begin
Mouse.SettingChanged(wParam);
Default; <----------------------*poof* down the sink hole
end;
...
end;
...
end;
The procedure CheckIniChange() doesn't throw any event i can handle, neither does Mouse.SettingChanged().
And once the code path reaches Default, it is sent down the DefWindowProc drain hole, never to be seen again (since the first thing the WndProc does is set the Message.Result to zero.
i was hoping to assign a handler to a TApplicationEvents.OnMessage event:
procedure TdmGlobal.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
begin
case Msg.message of
WM_SETTINGCHANGE:
begin
// Code
end;
end;
end;
But the OnMessage event is only thrown for messages that come through the message pump. Since the WM_SETTINGCHANGE message is "handled", it never sees the
PeekMessage
TranslateMessage
DispatchMessage
system.
How can i respond to the windows broadcast WM_SETTINGCHANGE?
© Stack Overflow or respective owner