Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > window positions

window positions
Thread Tools
Forum Regular
Join Date: Jan 2001
Status: Offline
Reply With Quote
Mar 23, 2001, 06:20 AM
 
Anyone got a clue how to get all windows position as a NSRekt.
cheers, have a nice day...
     
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Mar 23, 2001, 07:29 AM
 
Well, if you want the positons of all of the windows in your program, on or offscreen, then first you must get an array of pointers to those windows. You can do so by using the windows method of NSApp. Then, for each window, you should send it a frame message. It'll return it's frame rect. That's all. If you want to know if a window is visible then send it an isVisible message and it'll return either YES or NO.
     
geran  (op)
Forum Regular
Join Date: Jan 2001
Status: Offline
Reply With Quote
Mar 23, 2001, 07:43 AM
 
Tank you Dalgo, isVisable should do it, I really love this forum.

Have a nice day.
./geran
     
geran  (op)
Forum Regular
Join Date: Jan 2001
Status: Offline
Reply With Quote
Mar 30, 2001, 11:30 AM
 
Dalgo, can you please post alittle code sample, I cant get it to work or tell me were to find some info please...

cheers, have a nice day.
geran
     
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Mar 31, 2001, 06:48 AM
 
/* I haven't taken the time to try this but it should work.*/

NSArray * windowArray;
NSRect * windowRects;
int count, i;

windowArray = [NSApp windows];
windowRects = (NSRect*)malloc(sizeof(NSRect)*(count = [windowArray count]));

for(i=0; i<count; i++)
windowRects[i] = [[windowArray objectAtIndex:i] frame];
     
geran  (op)
Forum Regular
Join Date: Jan 2001
Status: Offline
Reply With Quote
Apr 2, 2001, 07:44 AM
 
Hi, Dalgo can you please mail me, I got some more questions.
clarkone@hotmail.com


cheers. Have a nice day
     
geran  (op)
Forum Regular
Join Date: Jan 2001
Status: Offline
Reply With Quote
Apr 4, 2001, 08:20 AM
 
Hi

How can I send it an isVisible message and it'll return either YES or NO.
some sample code please =). (im not a good programmer)
     
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Apr 4, 2001, 10:10 AM
 
/*Okay, your original question was simply how to get the rects for windows in your program. If you want only the rects for windows in your program which are visible on the screen then you can do this:*/

NSArray * windowArray;
NSRect * windowRects;
int count, currentRect, currentWindow;

windowArray = [NSApp windows];
windowRects = (NSRect*)malloc(sizeof(NSRect)*(count = [windowArray count]));

for(currentWindow=0, currentRect = 0; currentWindow<count; currentWindow++)
{
if([[windowArray objectAtIndex:currentWindow] isVisible])
{
windowRects[currentRect] = [[windowArray objectAtIndex:currentWindow] frame];
currentRect++;
}
}

/* Now the rect array windowRects holds the rects for all visible windows. The number of rects that it holds is whatever number is stored in currentRect. If you don't know how to send it an isVisible message at all maybe you should take a look at Apple's tutorials and the pdf "Programming and the objective C language. sending messages is simple. It's just of the form: [pointerToAClass selectorName];*/

[This message has been edited by Dalgo (edited 04-04-2001).]
     
geran  (op)
Forum Regular
Join Date: Jan 2001
Status: Offline
Reply With Quote
Apr 5, 2001, 07:07 AM
 
Is it possible to get ALL windows on screen, not just the windows that belongs to MyApp?


bye.
     
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Apr 5, 2001, 11:17 AM
 
I'm sure that there is a way. It's not part of NSApplication, though and if it is documented it isn't very well documented.
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Apr 5, 2001, 03:15 PM
 
Your application typically shouldn't be concerned with anything other than its own windows. I'm pretty sure you can though, even if it's a CoreGraphics call to get a list of display contexts - QuartzDebug.app shows you some debugging information about other applications' windows.
     
Fresh-Faced Recruit
Join Date: Jun 2001
Status: Offline
Reply With Quote
Jun 5, 2001, 01:07 AM
 
well here's how ya do it...
int n = 0,
windowCount = 0,
contextID = 0,
*WIDlist;

for (contextID = 0; contextID < 0xFFFF; contextID++)
{
NSCountWindowsForContext(contextID, &windowCount);
WIDlist = (int *)malloc(windowCount *sizeof(int));
NSWindowListForContext(contextID, windowCount, WIDlist);
for (n = 0; n < windowCount; n++)
{
printf("0x%04x 0x%04x\n",x, WIDlist[n]);
}
free(WIDlist);
}

it works, it gives out data like the QuartzDebug.app, just is a lil inefficient code.
anybody got improvements/questions? please email me: PhilippeHausler@own3dsoft.com
or post em here
     
   
Thread Tools
Forum Links
Forum 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:46 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2