Keep Window Looking Active

柔情痞子 提交于 2019-12-03 20:47:10

You don't say what language you are working in or whether this is managed or unmanaged code.

For C++ unmanaged code, you just handle the WM_NCACTIVATE message and force it to always seem active, like this:

case WM_NCACTIVATE:
   {
   // wParam tells us whether we are active or inactive, but we are going to ignore
   // that and always pass active down to DefWindowProc so it will draw us active.
   DefWindowProc(hwnd, uMsg, TRUE, lParam);
   //return FALSE; // returning false here prevents actual deactivation
   return TRUE; // return true allows deactivation (even though we draw as active)
   }
   break;

edit: the solution in delphi code (moved from comment to make it more readable)

procedure TForm1.WndProc(var Message: TMessage); 
begin inherited; 
  if (Message.Msg = WM_NCACTIVATE) then 
  begin 
    DefWindowProc(handle, Message.Msg, 1, Message.LParam ); 
    Message.Result := 1; 
  end; 
end;
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!