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

  • SEARCH
  • Home
  • 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

When I use this code to hide the windows border: this.FormBorderStyle = FormBorderStyle.None; I
When I use the form helper to make a time input,usaually I write code
My question is I use the code below for a registration form. It work
Normally you use Form.Visible to check if Window is visible at all. But sometimes
I'm trying to use form's CheckboxSelectMultiple widget but I I'd like to change the
I got a form in Django but when I use {{ form.as_p }} it
I have configured my application to use form based authentication and set up the
I am designing a secure login with JSP. I intend to use Form Authorization
I use simple_form in my app. How do i give the blank value in
I need to validate the Advanced search form , but it has data to

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.