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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:01:03+00:00 2026-05-23T10:01:03+00:00

I have a WinForm and now I need to change the cursor when it’s

  • 0

I have a WinForm and now I need to change the cursor when it’s in the windows caption part. I have some code working, it has 2 problems:


  1. It also changes the cursor when on the edges (normal resize cursor should be shown).
    I found out the I need something like this WM_NCHITTEST & HTTOP, but how do I combine that?
  2. There’s some flicker when moving the mouse.

I also tried placing the code below the base.WndProc(ref m);.

This is the code I already have:

if ((m.Msg == Win32.WM.NCMOUSEMOVE
    || m.Msg == Win32.WM.NCLBUTTONDOWN || m.Msg == Win32.WM.NCLBUTTONUP
    || m.Msg == Win32.WM.NCRBUTTONDOWN || m.Msg == Win32.WM.NCRBUTTONUP)
)
{
    if (m.WParam.ToInt32() != Win32.HT.TOP && m.WParam.ToInt32() != Win32.HT.RIGHT && m.WParam.ToInt32() != Win32.HT.BOTTOM && m.WParam.ToInt32() != Win32.HT.LEFT)
    {
        Cursor = Cursors.Hand;
    }
}

EDIT:
I wasn’t logging the message correctly in Spy++. Found the solution to the window edges (see updated code).

Thnx, J

  • 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-23T10:01:04+00:00Added an answer on May 23, 2026 at 10:01 am

    It flickers because you use the wrong message. Any mouse move is followed by WM_SETCURSOR to allow the app to change the cursor. So the cursor changes back to the default. Intercept WM_SETCURSOR instead. The low word of LParam contains the hit test code.

        protected override void WndProc(ref Message m) {
            if (m.Msg == 0x20) {  // Trap WM_SETCUROR
                if ((m.LParam.ToInt32() & 0xffff) == 2) { // Trap HTCAPTION
                    Cursor.Current = Cursors.Hand;
                    m.Result = (IntPtr)1;  // Processed
                    return;
                }
            }
            base.WndProc(ref m);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on a project that has 2 interfaces - windows forms
I have a Winform with a BackgroundWorker. The BackgroundWorker, among other things, has to
I have a winform application that uses some referenced web services to get data.
I have a PictureBox (WinMobile 6 WinForm) on which I draw some images. There
In one of the financial Winform projects , the application code will have to
I have two datagridview inside a winform. I need to reload with a button
I have a fairly large CRUD WinForm app that has numerous objects. Person, Enrollment,
I have a problem trying to show some images on my winform. On one
I have a treeView displayed on a winform.Now when i click on an xmlnode
I have a winform application that controls some transmitters and sound cards. There is

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.