 |
 |
window positions
|
 |
|
 |
|
Forum Regular
Join Date: Jan 2001
Status:
Offline
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jan 2001
Status:
Offline
|
|
Tank you Dalgo, isVisable should do it, I really love this forum.
Have a nice day.
./geran
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jan 2001
Status:
Offline
|
|
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
|
|
/* 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];
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jan 2001
Status:
Offline
|
|
Hi, Dalgo can you please mail me, I got some more questions.
clarkone@hotmail.com
cheers. Have a nice day
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jan 2001
Status:
Offline
|
|
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
|
|
/*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).]
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jan 2001
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|