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 8864735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:19:18+00:00 2026-06-14T16:19:18+00:00

How to do that? I could not find any useful sample for C#. I

  • 0

How to do that? I could not find any useful sample for C#. I know I should use SetClassLong/SetClassLongPtr, but here is the definition I only found: http://www.pinvoke.net/default.aspx/user32/SetClassLongPtr.html.

Obviously, I should call GetClassLongPtr with GCL_STYLE to read the current style flags, add or exclude CS_DROPSHADOW, and then call SetClassLongPtr with the changed flag value. But looking at that PInvoke definition, it is not trivial, especially taking into account 32/64-bit systems.

Can anybody give a link or a good example of this? And please, do not provide samples with overwriting CreateParams as this does not work for our dynamic scenario. Maybe, there is another [managed] way to do that?

  • 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. Editorial Team
    Editorial Team
    2026-06-14T16:19:19+00:00Added an answer on June 14, 2026 at 4:19 pm

    Here is something I have managed to write:

        private void SetSizeableCore(bool value)
        {
            fSizeable = value;
            if (value)
            {
                FormBorderStyle = FormBorderStyle.SizableToolWindow;
                DockPadding.All = 0;
                System.Version ver = Environment.OSVersion.Version;
                // Always for WinXP family, but for higher systems only if the aero theme is not in effect
                bool needShadow = ((ver.Major == 5) && (ver.Minor > 0)) || ((ver.Major > 5) && !IsAeroThemeEnabled());
                SetShadowFlag(needShadow);
            }
            else
            {
                FormBorderStyle = FormBorderStyle.None;
                DockPadding.All = 1;
                SetShadowFlag(true);
            }
        }
    
        private void SetShadowFlag(bool hasShadow)
        {
            if (!IsDropShadowSupported())
                return;
            System.Runtime.InteropServices.HandleRef myHandleRef = new System.Runtime.InteropServices.HandleRef(this, this.Handle);
            int myStyle = iGNativeMethods.GetClassLongPtr(myHandleRef, iGNativeMethods.CS_DROPSHADOW).ToInt32();
            if (hasShadow)
                myStyle |= iGNativeMethods.CS_DROPSHADOW;
            else
                myStyle &= ~iGNativeMethods.CS_DROPSHADOW;
            iGNativeMethods.SetClassLong(myHandleRef, iGNativeMethods.GCL_STYLE, new IntPtr(myStyle));
        }
    
        private bool IsDropShadowSupported()
        {
            // Win2000 does not have this feature
            if (Environment.OSVersion.Version <= new Version(5, 0))
                return false;
            bool myResult = false;
            iGNativeMethods.SystemParametersInfo(iGNativeMethods.SPI_GETDROPSHADOW, 0, ref myResult, 0);
            return myResult;
        }
    
        private bool IsAeroThemeEnabled()
        {
            if (Environment.OSVersion.Version.Major > 5)
            {
                bool aeroEnabled;
                iGNativeMethods.DwmIsCompositionEnabled(out aeroEnabled);
                return aeroEnabled;
            }
            return false; 
        }
    

    Correct me if I’m wrong.

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

Sidebar

Related Questions

I've tried looking at similar problems, but could not easily find one that helped
I have searched a lot but I could not find any good solution to
I could not find the function that returns the name of the cell referenced.
I searched the Web and could not find anything that would show me a
i custom varnish 500 error page,but i found that it could not display chinese
I am doing some server stuff that could potentially fail (not likely) but something
It does not seem that SendGrid has a free account that one could use
In other words, can I do something with a volatile variable that could not
I have a strange problem that I could not solve. When I try to
I am not sure what I could be doing wrong that causes info level

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.