Microsoft are usually in a difficult position when it comes to updating their APIs.
What might seem like strange or clumsy approaches today., made more sense when they were first implemented.
Something to keep in mind is that during the Early 90s with the advent of the Graphics Card, came the 2D Accelerator.
These weren't just Display Adapters., but Graphics Chips that would accelerate various Graphics Tasks... one such task was a Hardware Mouse Cursor., as well Graphics User Interface Operating Systems (Windows) were becoming more common.
A Software Mouse Cursor was quite a performance heavy task... so, offloading it to Hardware helped quite substantially with System Performance.
This however poses a problem... as Hardware doesn't work like Software., they don't "Store" per se; they merely act upon the last state you set and you can't really get any feedback.
As such, there is no way to know if the Hardware Mouse Cursor is Hidden or Visible.
What we also have to consider is that flooding the Window Message Queue with a Hide/Show Command every Synchronisation Loop., well that would add CPU Overhead.
As a result., this message is sent once and is passed on to the Graphics Card; which then behaves based on the last state sent to it.
If we want to change that; then we'd have to see a different command to it.
Now Graphics Cards had (dedicated) 2D Acceleration Components until 2009., the introduction of the AMD Compute and NVIDIA Unified Shader Architectures.
As a result the Cursor switched back from Hardware to Software., although it's still Hardware Accelerated as now it's a Shader Sprite; but here's the thing of it... Microsoft can't simply change how this works.
Why? Well because there is at least a Decade of Software that still remained 100% Compatible with Modern Windows; that still uses these commands how they used to work.
So they can't just change how this works. Even IF there is arguably a much better way, not without breaking all those old applications.
...
I mean *we* as Developers can easily switch this into being a Flag.
MouseCursor.agc
+ Code Snippet#Constant True -1
#Constant False 0
#Constant Enable 1
#Constant Disable 0
Type MouseCursor_t
bShow As Integer
EndType
Global Cursor As MouseCursor_t : Cursor.bShow = True
Function ShowMouseCursor( )
If Cursor.bShow = False
SetRawMouseVisible( Enable )
Cursor.bShow = True
EndIf
EndFunction
Function HideMouseCursor( )
If Cursor.bShow = True
SetRawMouseVisible( Disable )
Cursor.bShow = False
EndIf
EndFunction
Main.agc
+ Code Snippet// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "PrototypeDependancy" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 60, 1 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )
#Include "MouseCursor.agc"
Do
If GetRawKeyState( 32 ) And GetRawKeyPressed( 32 ) <> False
Select Cursor.bShow
Case True:
HideMouseCursor()
EndCase
Case False:
ShowMouseCursor()
EndCase
Case Default:
// ignore
EndCase
EndSelect
EndIf
If Cursor.bShow = True
Print( "Mouse Cursor Visible" )
Else
Print( "Mouse Cursor Hidden" )
EndIf
Sync()
Loop
It works every time