Removing and restoring Window borders

Posted by Laurence on Stack Overflow See other posts from Stack Overflow or by Laurence
Published on 2012-04-26T16:38:00Z Indexed on 2014/08/22 22:21 UTC
Read the original article Hit count: 158

Filed under:
|
|
|

I want to remove the window borders of another process in C#; I used RemoveMenu to remove the borders. It almost works but I have 2 problems left:

  • I need to remove the borders twice, the first time the menu bar still exists.
  • I can’t restore the menu’s

This is what I already wrote:

public void RemoveBorders(IntPtr WindowHandle, bool Remove)
    {
        IntPtr MenuHandle = GetMenu(WindowHandle);

        if (Remove)
        {
            int count = GetMenuItemCount(MenuHandle);
            for (int i = 0; i < count; i++)
                RemoveMenu(MenuHandle, 0, (0x40 | 0x10));
        }
        else
        {
            SetMenu(WindowHandle,MenuHandle);
        }

        int WindowStyle = GetWindowLong(WindowHandle, -16);

        //Redraw
        DrawMenuBar(WindowHandle);
        SetWindowLong(WindowHandle, -16, (WindowStyle & ~0x00080000));
        SetWindowLong(WindowHandle, -16, (WindowStyle & ~0x00800000 | 0x00400000));
    }

Can someone show me what I did wrong? I already tried to save the MenuHandle and restore it later, but that doesn't work.

© Stack Overflow or respective owner

Related posts about c#

Related posts about Windows