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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:27:05+00:00 2026-06-02T09:27:05+00:00

static HWND btn; HCURSOR cursor = LoadCursor(0, IDC_CROSS); case WM_CREATE: btn = CreateWindow(TEXT(BUTTON), TEXT(Press

  • 0
static HWND btn;
HCURSOR cursor = LoadCursor(0, IDC_CROSS);

case WM_CREATE:
    btn = CreateWindow(TEXT("BUTTON"), TEXT("Press Me"),
                       WS_CHILD|WS_VISIBLE, 50, 50, 80, 30,
                       hwnd, (HMENU) 111, NULL, NULL);

Now, in WM_COMMAND, I try to use:

SendMessage(btn, WM_SETCURSOR, 0, (LPARAM) cursor);

Which isn’t working.

So how do I change the cursor of the mouse after it clicks the button? Also, how do I change the cursor of the mouse as it is hovering over the button (like it changes to a hand when hovering over links in web-browsers)?

  • 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-02T09:27:10+00:00Added an answer on June 2, 2026 at 9:27 am

    Use this code to change the cursor of a single control:

    SetClassLong(btn, GCL_HCURSOR, (LONG)cursor);
    

    Preferred method, for 64 bit compatibility, is:

    SetClassLongPtr(btn, GCL_HCURSOR, (LONG_PTR)cursor);
    

    Note that this won’t change the icon only for the specified btn window but for all windows with the same class, you have to first register a custom class name with RegisterClass() and then use it in the WNDCLASS.lpszClassName structure when creating btn.

    Again this will apply to all the Windows with that (custom) class. To change the cursor of a single specific window you need to subclass it, manage the WM_SETCURSOR message and if (for example) lParam is HTCLIENT (pointer entered the window client area) then call SetCursor() to set the cursor you want (don’t forget to return TRUE in this case). Of course this might be temporary (calling SetWindowLongPtr() with GWLP_WNDPROC).

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

Sidebar

Related Questions

I create like this htextbox=CreateWindow(Lstatic,L,WS_BORDER|ES_MULTILINE|WS_CHILD|WS_VISIBLE,50,0, 100,50,hWnd,(HMENU)ID_STATIC,hInst,NULL); But I can't write text there. What is
[DllImport(user32.dll)] public static extern int SetScrollPos(IntPtr hWnd, int nBar, int nPos, bool bRedraw); [DllImport(user32.dll,
public partial class Form1 : Form { [DllImport(coredll.dll)] static extern int SetWindowLong(IntPtr hWnd, int
public partial class Form1 : Form { [DllImport(coredll.dll)] static extern int SetWindowLong(IntPtr hWnd, int
The trouble I'm having is with using... [DllImport(user32)] public static extern IntPtr SendMessage(IntPtr hWnd,
im using the following method [DllImport(kernel32.dll, SetLastError=true)] static extern int GetProcessId(IntPtr hWnd); to try
Given the following code public static Bitmap PrintWindow(IntPtr hWnd) { int width = GetWindowInfo(hWnd).rcWindow.Width;
I have Created a static control using following styles... picBoxDisp = CreateWindow(STATIC, image box,
I was using GetWindowLong like this: [DllImport(user32.dll)] private static extern IntPtr GetWindowLong(IntPtr hWnd, int
If the parent form of a (text) static control has a pattern on its

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.