Welcome, Guest. Please login or register.

Author Topic: get window list from current screen  (Read 1175 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline kas1eTopic starter

get window list from current screen
« on: December 25, 2004, 12:14:16 PM »
where the best and easy way for getting list of my windows from current screen ? (need name of fuctions, or source example).
thanks.
 

Offline MickJT

  • Full Member
  • ***
  • Join Date: May 2004
  • Posts: 153
    • Show only replies by MickJT
    • http://members.iinet.net.au/~trebs/AmiMSN
Re: get window list from current screen
« Reply #1 on: December 25, 2004, 01:17:01 PM »
Just a guess here.. Tried the "Scout" source code?
 

Offline Thomas

Re: get window list from current screen
« Reply #2 on: December 25, 2004, 11:49:08 PM »

Do LockIBase(), then use IntuitionBase->FirstScreen, Screen->FirstWindow and Window->NextWindow until Window is NULL, then do UnlockIBase(). You must not use any functions inbetween LockIBase() and UnLockIBase() and you have to consider that windows may be closed after UnLockIBase() so you must not use the window pointers.

Bye,
Thomas

Offline kas1eTopic starter

Re: get window list from current screen
« Reply #3 on: December 26, 2004, 04:44:43 PM »
Thanks. LockIBase is very good for determine active screen/window too. But one more question, about messages/ports/gadgets. for example:

I found active window, and want to close it. Of course if I just use CloseWindow(); on non-gatgest/busy window I have a lot of bugs. Well, I need 'closewindow gadget' emulation, I think ? As I founded in docs, i can sending some kind of message to my active window port (window->UserPort). So, can i send message like "we press close gadget" ?

 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: get window list from current screen
« Reply #4 on: December 26, 2004, 05:06:55 PM »
You need to use input.device IND_WRITEVENT command to send IECLASS_CLOSEWINDOW event, with ie_EventAddress set to the window address.

This only works for programs that actually handle IDCMP_CLOSEWINDOW messages. It won't work if the program is stalling for some reason (for example: app has crashed, or a requester is open).

Also, you need to be extra careful here, the window could close at any time, and sending the message for a non-existing window is a bad idea.
 

Offline kas1eTopic starter

Re: get window list from current screen
« Reply #5 on: December 26, 2004, 08:06:40 PM »
thanks agayn Piru :)
I am writing some minuts ago alt+f4 commoditie like a win32 hotkey. It's realy help in work now :) input.device rokz. thanks.

ps. closing opus4 by alt+f4 so unacusstomed :)
 

Offline itix

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 2380
    • Show only replies by itix
Re: get window list from current screen
« Reply #6 on: December 26, 2004, 08:54:15 PM »
Not that simple. Some apps dont close window but go to iconify mode on IDCMP_CLOSEREQUEST, some another may bring a requester.

Btw. in MUI apps you can close windows by esc key.. this is configurable from MUI prefs. Take a look.
My Amigas: A500, Mac Mini and PowerBook
 

Offline kas1eTopic starter

Re: get window list from current screen
« Reply #7 on: December 26, 2004, 09:33:31 PM »
Mui is ok, but i am testing now my tool (by Piru way), and i can close: opus4, cli, jaberrwocky(is mui), ibrowse, amirc(all mui too), golded, yam, artm, songplayer,atc - in other worlds - all program which i use. If apps have 'close
gadget' (IDCMP CloseWindow) - this window will be close.

ps. of course opus4 (as example) said Quit/No requestor. Is
good too. Just like a win32 hotkey.


 

Offline kas1eTopic starter

Re: get window list from current screen
« Reply #8 on: December 28, 2004, 02:07:00 AM »
thomas, there is a little problem anyway :( for example i want to store in my array/list (how big/long it?) all addresses of my screens (but, i do not know how many screens was opening). So my problem is it: i need to know how many screen was opening in the system, and how i can create list of all addresses of my screens. (in next i want to cycle beetwen screens for example by my created list).

The same question and for window too. How i can to know how many window was openenig for on active screen,and where/how storage all address of windows. I think it will be like this for screens:

lock = LockIBase(0);
screen = IntuitionBase->FirstScreen; //first in list

while(screen!=0)
 {
   screen = screen->NextScreen;
   // ??? how to create list of addresses
   // here ? how much it will big/long ?
 };

UnlockIBase(lock);        


thanks in advance
 

Offline Thomas

Re: get window list from current screen
« Reply #9 on: December 30, 2004, 02:03:42 PM »

Well, there are several possibilities to solve this.

One is to prepare an array which is big enough for most cases, for example to hold 100 screens and 1000 windows or something like that. If the limits are reached anyway, you can either inform the user that he is using too much windows or just omit the remaining ones.

The second possbility is to go through the lists twice: first count the number of screens and windows, then allocate the array (using malloc or AllocVec) and finally go through the lists again and fill the array.

And the third solution is to use pointered lists yourself. This is the most dynamic version but it might be quite difficult to access because you don't have an array but have to walk through your own lists, too.

Bye,
Thomas