![]() |
|
Making The Cursor Vanish |
Kris Asick
Member #1,424
July 2001
|
Making the Windows system cursor vanish when windowed is easy under Allegro. Just call install_mouse() and it automatically happens. No problem. My problem however is I want the cursor to disappear but don't want to call install_mouse() because I don't want the Allegro mouse drivers to load. (Since the whole point here is to replace them with my own.) So far I've tried calling each of the various Allegro mouse functions that can make the cursor vanish without success. I've also tried using SetClassLong(), SetCursor() and ShowCursor(), all without success. So either I'm passing the wrong values to those SDK functions, or Allegro's internal Window handler is doing something which is preventing my changes from taking hold. I haven't even been able to get the cursor to change to something other than the default Windows arrow. For example, you would think this line would change the system cursor to the hourglass while over the Allegro window: // Called AFTER Allegro Window is Initialized SetClassLong(win_get_window(),GCL_HCURSOR,(long)LoadCursor(NULL, IDC_WAIT)); Except it doesn't do anything. I'm still trying things but while I'm at that, does anyone have any quick solutions? --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
Marco Radaelli
Member #3,028
December 2002
![]() |
No idea, but Allegro recent versions offer support for hardware cursors and, between all, you can show the hourglass, so a quick look at that code could help. Another opinion I'm having while writing, but for which I'm not 100% sure is that your SetClassLong() could be working with GDI, while you're using the DirectX driver.
|
Kris Asick
Member #1,424
July 2001
|
Quote: No idea, but Allegro recent versions offer support for hardware cursors and, between all, you can show the hourglass, so a quick look at that code could help. I've been looking through the Allegro source. All of the Allegro mouse functions do not work unless a mouse driver is installed, due to the nature of Allegro using virtual tables to call everything. Beyond that, I've discovered that the default Allegro window intercepts WM_SETCURSOR messages as such: if (!user_wnd_proc || _mouse_installed) { mouse_set_syscursor(); return 1; /* not TRUE */ } ...and then that function ALWAYS calls SetCursor(), even if the mouse drivers are not installed, and the call to SetCursor() when the mouse drivers are not loaded is always IDC_ARROW: /* mouse_set_syscursor: [window thread] * Selects whatever system cursor we should display. */ int mouse_set_syscursor(void) { HWND allegro_wnd = win_get_window(); if ((mouse_dinput_device && _mouse_on) || (gfx_driver && !gfx_driver->windowed)) { SetCursor(_win_hcursor); /* Make sure the cursor is removed by the system. */ PostMessage(allegro_wnd, WM_MOUSEMOVE, 0, 0); } else SetCursor(LoadCursor(NULL, IDC_ARROW)); return 0; } So it seems like Allegro overrides all attempts to change the system cursor when the mouse driver isn't installed. I would almost call this a bug. The else statement in that code should be setting the cursor to the cursor registered in the class object registered by the window and not assuming the cursor will always be IDC_ARROW when not using the mouse drivers. Quote: Another opinion I'm having while writing, but for which I'm not 100% sure is that your SetClassLong() could be working with GDI, while you're using the DirectX driver. DirectX has no cursor support. All work with cursors must be done at the API level under Windows. .EDIT: Allegro is very much taking over what cursor shows up. I discovered that the result of the API call GetCursor() does NOT match the cursor that shows up in an Allegro window! (At least, with the mouse drivers disabled.) So as it stands, unless I define my own window and override the built-in Allegro one, disabling the mouse cursor without installing the Allegro mouse drivers is impossible. --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
|