Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SetCursor and ShowCursor : twapi

156 views
Skip to first unread message

Nicolas Robert

unread,
Nov 6, 2018, 7:17:59 AM11/6/18
to
Hello,

I would like to change the cursor . In twapi documentation , there is an function : twapi::load_cursor_from_file

In Windows API, there is 2 functions : SetCursor and ShowCursor

In twapi, I don't see which function allow me to set cursor and show cursor. In twapi.tcl , I see WM_SETCURSOR , but I don't know how do I use ?

Thanks

Nicolas

Mike Griffiths

unread,
Nov 6, 2018, 7:23:11 PM11/6/18
to
I'm not sure about TWAPI, but this functionality is built into Tk:

. configure -cursor @path/to/cursor.cur

See http://www.tcl.tk/man/tcl/TkCmd/options.htm#M-cursor

Nicolas Robert

unread,
Nov 7, 2018, 4:00:44 AM11/7/18
to
Thanks Mike , but I don’t want to change the Tk window, but the cursor of my application e.g. Notepad...

Ashok

unread,
Nov 7, 2018, 8:15:39 AM11/7/18
to
Sorry, twapi does not have support for SetCursor/ShowCursor.

/Ashok

Nicolas Robert

unread,
Nov 8, 2018, 3:30:29 PM11/8/18
to
> Sorry, twapi does not have support for SetCursor/ShowCursor.
>
> /Ashok

I accept your apologies, simply because you wrote this book "The_Tcl_Programming_Language__A_Comprehensive_Guide" -)

Well, it's a pity

Thank you Ashok

Ashok

unread,
Nov 9, 2018, 7:48:32 AM11/9/18
to
On 11/9/2018 2:00 AM, Nicolas Robert wrote:
>
> I accept your apologies, simply because you wrote this book "The_Tcl_Programming_Language__A_Comprehensive_Guide" -)

Hah, since you mentioned my book, you can try the following
if you are feeling brave:

twapi::ffi_cfuncs [twapi::ffi_load User32.dll] {
HANDLE GetCursor();
HANDLE SetCursor(HANDLE hand);
}

Then call them as

% set cur [GetCursor]
65541 HANDLE
% SetCursor $cur
65541 HANDLE

I'm ignorant/lazy to find a file to actually load a cursor from
but you could try the above passing a handle obtained from
load_cursor_from_file.

Unsupported, caveat emptor! But I'd like to know if you succeed.


/Ashok

Nicolas Robert

unread,
Nov 13, 2018, 2:39:47 PM11/13/18
to
Ashok ,

After few days...

<Setcursor>: modify the cursor, but it does not remain active when my mouse move, for the moment I did not manage to modify it, only in my window TK.

I also have to try this function <SetSystemCursor>, it works well but for all Windows.

And finally… <PostMessage> , works with my window , but the cursor arrow is only modify

# WM_SETCURSOR -> 0x0020
twapi::PostMessage $hwin 0x0020 0 0

twapi::ffi_cfuncs [twapi::ffi_load user32.dll] {
HANDLE GetCursor();
HANDLE SetCursor(HANDLE hand);
BOOLEAN SetSystemCursor(HANDLE hand, int id);
}

set CursorWait [twapi::load_cursor_from_system wait]
set Arrow_cur 32513

SetCursor $CursorWait
SetSystemCursor $CursorWait $Arrow_cur


Nicolas
0 new messages