Hooking into Windows message loop in WPF window adds white border on the inside

后端 未结 2 1980
花落未央
花落未央 2020-12-09 17:21

I am trying to create a WPF window with WindowStyle=\"None\" (for custom buttons and no title) that cannot be resized. Setting ResizeMode to

2条回答
  •  心在旅途
    2020-12-09 17:55

    You can try from anywhere in a WPF App

                    ComponentDispatcher.ThreadFilterMessage += new ThreadMessageEventHandler(ComponentDispatcherThreadFilterMessage);
    

    and:

        // ******************************************************************
        private static void ComponentDispatcherThreadFilterMessage(ref MSG msg, ref bool handled)
        {
            if (!handled)
            {
                if (msg.message == WmHotKey)
                {
                    HotKey hotKey;
    
                    if (_dictHotKeyToCalBackProc.TryGetValue((int)msg.wParam, out hotKey))
                    {
                        if (hotKey.Action != null)
                        {
                            hotKey.Action.Invoke(hotKey);
                        }
                        handled = true;
                    }
                }
            }
        }
    

    Hope it helps... :-)

提交回复
热议问题