Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 55531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:23:31+00:00 2026-05-10T17:23:31+00:00

I have a C# WinForms borderless window, for which I override WndProc and handle

  • 0

I have a C# WinForms borderless window, for which I override WndProc and handle the WM_NCHITTEST message. For an area of that form, my hit test function returns HTSYSMENU. Double-clicking that area successfully closes the form, but right-clicking it does not show the window’s system menu, nor does it show up when right-clicking the window’s name in the taskbar.

This form uses these styles:

this.SetStyle( ControlStyles.AllPaintingInWmPaint, true ); this.SetStyle( ControlStyles.UserPaint, true ); this.SetStyle( ControlStyles.OptimizedDoubleBuffer, true ); this.SetStyle( ControlStyles.ResizeRedraw, true ); 

And has these non-default property values:

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.KeyPreview = true; this.MaximizeBox = false; this.MinimizeBox = false; 

I’ve tried handling WM_NCRBUTTONDOWN and WM_NCRBUTTONUP, and send the WM_GETSYSMENU message, but it didn’t work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:23:32+00:00Added an answer on May 10, 2026 at 5:23 pm

    A borderless window, if I am not mistaken, is flagged such that it offers no system menu, and that it does not appear in the taskbar.

    The fact that any given window does not have a border and does not appear in the taskbar is the result of the style flags set on the window. These particular Style flags can be set using the GetWindowLong and SetWindowLong API calls. However you have to be careful as certain styles just don’t work together.

    I have written a number of custom controls over the years and I am constantly coaxing windows to become something they weren’t originally intended to be.
    For example I have written my own dropdown control where I needed a window to behave as a popup and not to activate.
    The following code will do that. Note that the code appears in the OnHandleCreated event handler. This is because the flags need to be changed just after the handle is setup which indicates that Windows has already set what it thinks the flags should be.

    using System.Runtime.InteropServices;  protected override void OnHandleCreated(EventArgs e) {     uint dwWindowProperty;      User32.SetParent(this.Handle, IntPtr.Zero);      dwWindowProperty = User32.GetWindowLong( this.Handle, User32.GWL.EXSTYLE );     dwWindowProperty = dwWindowProperty | (uint)User32.WSEX.TOOLWINDOW | (uint)User32.WSEX.NOACTIVATE;     User32.SetWindowLong( this.Handle, User32.GWL.EXSTYLE, dwWindowProperty );      dwWindowProperty = User32.GetWindowLong( this.Handle, User32.GWL.STYLE );     dwWindowProperty = ( dwWindowProperty & ~(uint)User32.WS.CHILD ) | (uint)User32.WS.POPUP;      User32.SetWindowLong( this.Handle, User32.GWL.STYLE, dwWindowProperty );     base.OnHandleCreated (e); }   //this is a fragment of my User32 library wrapper needed for the previous code segment. class User32  {     [DllImport('user32.dll', SetLastError = true)]    static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);      [DllImport('user32.dll', CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall )]     public  static extern int SetWindowLong( IntPtr hWnd, User32.GWL gwlIndex, uint dwNewLong);       [DllImport('user32.dll', CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall )]     public static extern uint GetWindowLong( IntPtr hWnd, User32.GWL gwlIndex );      [FlagsAttribute]      public enum WS: uint {          POPUP = 0x80000000,         CHILD = 0x40000000,     }      public enum GWL {         STYLE   = -16,         EXSTYLE = -20     }      [FlagsAttribute]     public enum WSEX: uint {         TOP        = 0x0,         TOPMOST    = 0x8,         TOOLWINDOW = 0x80,         NOACTIVATE = 0x08000000,     } } 

    Unfortunately the SysMenu style cannot be set without using the Caption style, so I can’t say if this is a problem in your implementation.

    You can check out the original style list and the extend style list at these two links:
    Window Styles
    CreateWindowEx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 92k
  • Answers 92k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer That Wikipedia article is pretty opaque. The Microsoft project page… May 11, 2026 at 6:29 pm
  • Editorial Team
    Editorial Team added an answer According to the docs there's a NetShareEnum and a WNetEnumResource… May 11, 2026 at 6:29 pm
  • Editorial Team
    Editorial Team added an answer You should have a separate one really. Reusing connections is… May 11, 2026 at 6:29 pm

Related Questions

I have a C# winforms app that runs a macro in another program. The
Let's assume I have a C# Winforms project, MainGUI. It references another project in
I am working in a C# winforms project and I have a user control
I'm working on a C# winforms application (VS.NET 2008, .NET 3.5 sp 1). I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.