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

twapi unable to modify window size

65 views
Skip to first unread message

sled...@gmail.com

unread,
Feb 16, 2018, 1:16:50 PM2/16/18
to
Using tkcon with the tclkit-gui-8_6_6-twapi-4_1_27-x86-max.exe produces the following result.

Need help with regard to what I am doing incorrectly - do not understand the meaning of or how to rectify the "Invalid pointer..." condition.

Rick

Main console display active (Tcl8.6.6 / Tk8.6.6)
(bin) 54 % package require twapi_ui
4.1.27
(bin) 55 % set hndl [twapi::get_desktop_window]
65552 HWND
(bin) 56 % set dimensions [twapi::get_display_size]
1280 1024
(bin) 57 % set dimensions [twapi::resize_window 65552 1024 768]
Invalid pointer or opaque value '65552'.

Mike Griffiths

unread,
Feb 16, 2018, 5:01:06 PM2/16/18
to
I am taking a guess from your snippet that you're actually trying to change the screen resolution by resizing the desktop, and I have no idea if that'll work (if my assumption is even correct). However, as to the specific error you're getting: You need to pass the entire value (including ' HWND'):

(Mike) 5 % twapi::tkpath_to_hwnd .
0x0000000000080764 HWND
(Mike) 6 % twapi::resize_window [twapi::tkpath_to_hwnd .] 1024 768
(Mike) 7 % twapi::resize_window [lindex [twapi::tkpath_to_hwnd .] 0] 1024 768
Invalid pointer or opaque value '0x0000000000080764'.

(That being said, although the resize_window with the whole string didn't throw an error, it also didn't actually do anything for me, so take with a pinch of salt.)

Ashok

unread,
Feb 17, 2018, 12:01:31 AM2/17/18
to
The following works for me in a shell

% package require twapi
4.2.12
% exec notepad &
1680
% set w [lindex [twapi::find_windows -toplevel 1 -text Untitled* -match
glob] 0]
984802 HWND
% twapi::resize_window $w 400 200

Note that for this to work, the window has to be resizable in the first
place. I doubt that the desktop window can be resized this way. Not even
sure what the semantics would be.

Regarding invalid pointer error, pointers/handles are typed in twapi and
consist of a pair containing the pointer value and its type. Thus above
the window handle is {984802 HWND}, not just the 984802.

/Ashok

sled...@gmail.com

unread,
Feb 19, 2018, 10:10:10 AM2/19/18
to
You have assumed correctly. Thanks for trying...

sled...@gmail.com

unread,
Feb 19, 2018, 10:17:26 AM2/19/18
to
Thanks for the reply. The challenge is to change the display screen resolution, not the window of the tcl app.

The following commands work as described. What is the corresponding command that will change the display size? Am able to do it with WMIC but would prefer do to it with TWAPI or tcom.

get_desktop_window
Returns a handle to the desktop window.
get_display_size
Returns a list of two integers specifying the width and height of the display.

Rick

Ashok

unread,
Feb 20, 2018, 12:27:29 AM2/20/18
to
Instead of using the wmic command line program, you can use twapi's WMI
interfaces to do so. See http://www.magicsplat.com/book/wmi.html for a
tutorial on WMI calls using twapi.

/Ashok
0 new messages