windows – Delphi:如何响应WM_SettingChange / WM_WinIniChang
| 
        
           
 我需要知道我的应用程序何时收到 
  问题是TApplication中的消息泵在我有机会看到它之前将其发送到黑洞(默认处理程序): 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;过程CheckIniChange()不会抛出我可以处理的任何事件,Mouse.SettingChanged()也不会. 一旦代码路径达到Default,就会沿着DefWindowProc排放孔向下发送,永远不会再被看到(因为WndProc做的第一件事就是将Message.Result设置为零. 我希望为TApplicationEvents.OnMessage事件分配一个处理程序: procedure TdmGlobal.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
begin
   case Msg.message of
   WM_SETTINGCHANGE:
      begin
         // Code
      end;
   end;
end;但OnMessage事件仅针对通过消息泵发出的消息抛出.由于WM_SETTINGCHANGE消息是“处理”的,它永远不会看到 PeekMessage TranslateMessage DispatchMessage 系统. 我如何回应Windows广播WM_SETTINGCHANGE? 解决方法Edit2:对于旧版本,通常的消息拦截应该有效……[...]
  private
    procedure WMSettingChange(var Message: TWMSettingChange); message WM_SETTINGCHANGE;
[...]
procedure TForm1.WMSettingChange(var Message: TWMSettingChange);
begin
  showMessage('SettingChange message intercept');
end;编辑:哎呀!没看到它是为了D5.以下是D2007. 在您的应用程序中使用OnSettingChange: procedure TApplication.SettingChange(var Message: TWMSettingChange);
begin
  if Assigned(FOnSettingChange) then
    with Message do
      FOnSettingChange(Self,Flag,Section,Result);
end;您可以使用此代码进行测试.尝试并更改TaskBar的高度或停靠侧… procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnSettingChange := MySettingChange;
end;
procedure TForm1.MySettingChange(Sender: TObject; Flag: Integer;
  const Section: string; var Result: Integer);
begin
  showMessage('setting changed');
end;(编辑:南平站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! | 

