SetCursor under Framework brl.GLMax2D


👉 BlitzCoder will be building a new platform and other plans to preserve and continue the Blitz legacy.

To be able to achieve this goal, we need your support by becoming a Patreon Paid Member 👈

 

Tweet
Taron

For the life of me I can't change the windows cursor while operating in this framework?!

I'm almost certain there's simply something I forgot or never cared about, but if anyone has a hint, that would be awesome.
LoadCursor() doesn't exist
LoadCursorA( hinstance, byte ptr) exists, but no translation for IDC_CROSS or anything to make use of it?
SetCursor( ) useless without getting a cursor to set.

So, yeah, I'd love some advice. Funny how rusty I've gotten. And sad.

Thanks in advance!

markcwm commented:

SetCursor is Windows only, for cross platform you use SetPointer in MaxGUI. SetPointer uses SetCursor in win32maxguiex.mod:

    Method SetPointer(shape)
        Global winptrs[]=[0,32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650,32651]
        If shape<1 Or shape>14 Then
            _cursor = LoadCursorW( Null,Short Ptr( IDC_ARROW ) )
        Else
            _cursor=LoadCursorW(Null,Short Ptr(winptrs[shape]))
        End If
        SetCursor(_cursor)
        If TWindowsTextArea._oldCursor Then TWindowsTextArea._oldCursor = _cursor
        If shape = 0 Then _cursor = 0
    EndMethod

And here's the MaxGui example:

' setpointer.bmx

Import MaxGui.Drivers

Strict 

Local window:TGadget
Local combo:TGadget

window=CreateWindow("SetPointer",40,40,320,240,,WINDOW_TITLEBAR)

CreateLabel "Select a pointer shape:",10,10,200,20,window

combo=CreateComboBox(10,30,200,24,window)
AddGadgetItem combo,"POINTER_DEFAULT"
AddGadgetItem combo,"POINTER_ARROW"
AddGadgetItem combo,"POINTER_IBEAM" 
AddGadgetItem combo,"POINTER_WAIT" 
AddGadgetItem combo,"POINTER_CROSS"
AddGadgetItem combo,"POINTER_UPARROW" 
AddGadgetItem combo,"POINTER_SIZENWSE" 
AddGadgetItem combo,"POINTER_SIZENESW" 
AddGadgetItem combo,"POINTER_SIZEWE" 
AddGadgetItem combo,"POINTER_SIZENS" 
AddGadgetItem combo,"POINTER_SIZEALL" 
AddGadgetItem combo,"POINTER_NO" 
AddGadgetItem combo,"POINTER_HAND"
AddGadgetItem combo,"POINTER_APPSTARTING"
AddGadgetItem combo,"POINTER_HELP"

SelectGadgetItem combo,0

While True
    WaitEvent 
    Select EventID()
        Case EVENT_WINDOWCLOSE
            End
        Case EVENT_GADGETACTION
            SetPointer EventData()
    End Select
Wend
Taron commented:

Dang it, the forum won't send me any notification.
THANK YOU! That's very nice. But since I do not use maxgui I'll have to be a bit more inventive, I'm afraid.

I'm sure it is because I'm opening a window with the brl.GLMax2D framework, I'll have to target the proper hinstance within that window for the LoadCursorW to work.
I know how to get the window (hWnd), but still have to track down how to get the hinstance?! Pfffff... good old "pulling teeth", haha.

In case I figure it out earlier, I'll post my findings here, I promise!

Taron commented:

Alright, so to get the hinstance of the executable itself, one can use "GetModuleHandleW(Null)". Which indeed spits out a good looking int.
However, using LoadCursorW(hinstance ,Short Ptr(winptrs[shape])) with any of the shapes just spits out a 0 without any effect.

Obviously I know not what I'm doing, but yeah... I'll keep doing it!

markcwm commented:

Hi Taron, sorry I can't help you any more as I pretty much don't code any more these days.

I'm sure it wouldn't take you too long to rip that code out of MaxGui and put it into your project.

Taron commented:

No worries, it'll be alright. Sheeesh, back in the day I've always found solutions for virtually everything without much fuzz. I'm getting old.
But THANK YOU, mark, really!

Reply To Topic (minimum 10 characters)

Please log in to reply