• Re: tip614 implementation: find HWND from TkWindow structure

    From Christian Werner@21:1/5 to All on Tue Jan 18 13:32:11 2022
    Howdy Harald,

    the Tk toplevel window is wrapped/contained/enslaved(!pc) by another native window which most likely is the one you need to deal with the operating system.Maybe the logic can be deduced by reading {win,unix,macosx}/tk(Win,Unix,MacOSX)Wm.c. It's the so
    called wrapper window which might be the required one when dealing with session management stuff.

    HTH,
    Christian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Tue Jan 18 22:18:29 2022
    Dear Tk Wizards,

    I try to make some easy steps in Tk and I am facing a lot of very silly questions. Sorry for that.

    The aim is to call windows OS WIN32 function:
    WTSRegisterSessionNotification( HWNDCur, NOTIFY_FOR_THIS_SESSION)
    with a windows handle. The Windows should be the window handle of the
    toplevel given in the command "wm protocol toplevel protocol command".
    The command gets a TkWindow structure with lots of members.
    Now, which one is the Window handle?

    I tried: TkWinGetHWND(winPtr) as shown here:

    https://core.tcl-lang.org/tk/info/bded9fe3463781c7

    Is this the right function ?

    If yes, the message is not send in my example solution, when the windows
    user is changed. Maybe any insights ?

    I still have the book "TCL/Tk" by Jeffrey Hobbs. There is a chapter for
    Tk programming. Maybee, this may help...

    Thank you for any insight,
    Harald

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Wed Jan 19 09:49:15 2022
    Am 18.01.2022 um 22:32 schrieb Christian Werner:
    Howdy Harald,

    the Tk toplevel window is wrapped/contained/enslaved(!pc) by another native window which most likely is the one you need to deal with the operating system.Maybe the logic can be deduced by reading {win,unix,macosx}/tk(Win,Unix,MacOSX)Wm.c. It's the so
    called wrapper window which might be the required one when dealing with session management stuff.

    HTH,
    Christian


    Christian,

    thank you for the comment. As there is just a:
    case WM_QUERYENDSESSION:
    above the new:
    case WM_WTSSESSION_CHANGE:
    , I thought, it might work in a similar way.

    The challenge is to find the Windows handle of the concerned toplevel.
    I suppose, it is the handle of the toplevel given in the "wm protocol <toplevel>" command.

    That is why I have tried to get the HWND out of the passed TkWindow
    structure.

    Thank you,
    Harald

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Wed Jan 19 11:04:58 2022
    Am 19.01.2022 um 10:54 schrieb Christian Werner:
    Harald,

    I think you want to perform the WTS registration on the wmPtr->wrapper handle, since that is the container which is seen by the Windows "window/session manager".

    HTH,
    Christian

    Thanks ! I will try that !

    I feel so blind in Tk...

    Thanks,
    Harald

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Werner@21:1/5 to All on Wed Jan 19 01:54:00 2022
    Harald,

    I think you want to perform the WTS registration on the wmPtr->wrapper handle, since that is the container which is seen by the Windows "window/session manager".

    HTH,
    Christian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Wed Jan 19 11:37:46 2022
    Am 19.01.2022 um 10:54 schrieb Christian Werner:
    Harald,

    I think you want to perform the WTS registration on the wmPtr->wrapper handle, since that is the container which is seen by the Windows "window/session manager".

    HTH,
    Christian

    Thanks Magic Christian, works like a charm !

    https://core.tcl-lang.org/tk/info/75bea34e67b7e33b

    Take care,
    Harald

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Werner@21:1/5 to Harald Oehlmann on Wed Jan 19 04:22:56 2022
    Harald Oehlmann schrieb am Mittwoch, 19. Januar 2022 um 11:37:50 UTC+1:

    https://core.tcl-lang.org/tk/info/75bea34e67b7e33b

    I see. Things to consider: are winPtr->wmInfoPtr and in turn winPtr->wmInfoPtr->wrapper always not NULL? Otherwise you would need to call at least Tk_MakeWindowExist(winPtr) before in order to have all the native window stuff be setup before calling
    WTSRegisterSessionNotification().

    HTH,
    Christian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)