English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 17 June 2019, 13:05   #1
sg00
Registered User
 
Join Date: Jun 2019
Location: Australia
Posts: 6
Get current CLI window width

Hi guys,

I'm trying to write an Amiga C program to run on WB1.3 that, when run, simply outputs:

"The current window width is XXXpx"

Where <XXX> is the width of the CLI window from which the program was run.

There's a lot of literature on the topic of opening new windows in C, and I'm able to do that and access the new window's properties, but there doesn't appear to be any literature on the topic of getting a reference to the current CLI window that the program was run from.

I thought about getting a reference to the current screen and then somehow finding the current window, however that could be unreliable as the current screen may have many windows.

Any advice would be appreciated!
sg00 is offline  
Old 17 June 2019, 14:31   #2
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Get the pointer to the console handler from your process structure (or from pr_CLI->cli_StandardOutput) and send the ACTION_DISK_INFO packet to it. The resulting InfoData and its id_InUse will be a struct ConUnit* to the console, and its id_VolumeNode will be a struct Window* to the console window.
Leffmann is offline  
Old 17 June 2019, 14:37   #3
sg00
Registered User
 
Join Date: Jun 2019
Location: Australia
Posts: 6
Thanks very much Leffmann. This is definitely the info I’m seeking. I’ll try it out this week.
sg00 is offline  
Old 17 June 2019, 16:42   #4
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,267
Quote:
Originally Posted by Leffmann View Post
Get the pointer to the console handler from your process structure (or from pr_CLI->cli_StandardOutput) and send the ACTION_DISK_INFO packet to it. The resulting InfoData and its id_InUse will be a struct ConUnit* to the console, and its id_VolumeNode will be a struct Window* to the console window.
That is not recommended. Please use the window bounds report:

https://wiki.amigaos.net/wiki/Consol..._Bounds_Report

Why is ACTION_DISK_INFO not recommended? First, it will pop-open any console that was hidden as an "Auto" window. Second, a window will also loose its "auto"-ability, and hence cannot be closed anymore afterwards. Third, it will *only* work for streams that are based on the CON-Handler, and not on any other streams, for example, it will not work for the AUX:-Handler. The window bounds report works for AUX:, it will also keep the console closeable and hence does not have all such bad side effects.

If you really must, please send an ACTION_UNDISK_INFO after reading window sizes.
Thomas Richter is offline  
Old 17 June 2019, 17:26   #5
Niklas
Registered User
 
Join Date: Apr 2018
Location: Stockholm / Sweden
Posts: 129
Quote:
Originally Posted by Leffmann View Post
Get the pointer to the console handler from your process structure (or from pr_CLI->cli_StandardOutput) and send the ACTION_DISK_INFO packet to it. The resulting InfoData and its id_InUse will be a struct ConUnit* to the console, and its id_VolumeNode will be a struct Window* to the console window.
I wrote a program in C that does what Leffmann suggests: https://pastebin.com/9cRz6kJE. For many of you Leffmann's answer contains all the information you need, but if someone read Leffmann's answer and were still not sure how to go ahead then this may fill in a some blanks.

Quote:
Originally Posted by Thomas Richter View Post
That is not recommended. Please use the window bounds report:

https://wiki.amigaos.net/wiki/Consol..._Bounds_Report
A window bounds report doesn't return the information that sg00 asked for; he wanted to find out the size of the console window in pixels, not the number of rows and columns.
Niklas is offline  
Old 18 June 2019, 09:09   #6
sg00
Registered User
 
Join Date: Jun 2019
Location: Australia
Posts: 6
Thanks very much All.

Thomas, I will experiment with window bounds report to see if this will suit.

Niklas, thank you very much for the sample code. It definitely helps fill some gaps for me.

This is my first experience with this forum - what a great community!
sg00 is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
startup-sequence without opening CLI window Mathesar support.Apps 12 21 June 2017 19:03
cli window size and position honx support.WinUAE 5 03 September 2016 23:48
Open drawer in current window? DopPie support.Apps 3 21 August 2016 22:04
Closing current Shell window programmatically? tygre Coders. General 5 06 September 2015 06:24
Tools to display IFF on CLI window Leandro Jardim request.Apps 4 20 April 2014 02:31

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 23:29.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.12640 seconds with 15 queries