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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:31:21+00:00 2026-05-18T22:31:21+00:00

I use a form with border NONE. I need to override WndProc for resize

  • 0

I use a form with border NONE. I need to override WndProc for resize and move form. However, using this code, my app crashes!

 static const int WM_NCHITTEST = 0x0084;
 static const int HTCLIENT = 1;
 static const int HTCAPTION = 2;

 protected: virtual void Form1::WndProc(System::Windows::Forms::Message %m) override 
 {        
     switch (m.Msg)
     {
         case WM_NCHITTEST:
             if (m.Result == IntPtr(HTCLIENT))
             {
                 m.Result = IntPtr(HTCAPTION);
             }
             break;
     }
     Form1::WndProc(m);
 }       


virtual System::Windows::Forms::CreateParams^ get() override
{

    System::Windows::Forms::CreateParams^ cp = __super::CreateParams;
    cp->Style |= 0x40000; 
    return cp;
}

How can I fix my code not to crash but still allow my form to be moved and resized?

  • 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-05-18T22:31:21+00:00Added an answer on May 18, 2026 at 10:31 pm

    You have to call the base class’s WndProc method first, in order for m.Result to be set to the correct value. The code you posted doesn’t call it until the end.

    Additionally, you’re trying to call the base class with Form1::WndProc, which actually calls the current class’s implementation of the WndProc method. That’s why your application is “crashing” every time you try to run it with a StackOverflowException—your code within the WndProc method is calling itself recursively. Directly calling the superclass’s implementation (like you did in the CreateParams property) with the __super keyword works just fine.

    So, you need to re-write that method like this:

    virtual void Form1::WndProc(System::Windows::Forms::Message %m) override 
    {
        __super::WndProc(m);
    
        switch (m.Msg)
        {
        case WM_NCHITTEST:
            if (m.Result == IntPtr(HTCLIENT))
            {
                m.Result = IntPtr(HTCAPTION);
            }
            break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to use form fields that does not correspond to database
I have a search form on each of my pages. If I use form
In rails, is it recommended to use form helpers? Internally, everything boils down to
I use a form to run a few codes on a database in Access.
When I attempt to use the iterator form of parsing for a Spirit grammar
I have seen people say that it is bad form to use catch with
When I use the default model binding to bind form parameters to a complex
I want to use the jQuery accordion tool for a form i'm building so
the company I work for want to use a hosted payment form to charge
I have a website where we use Javascript to submit the login form. On

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.