问题
From kCGWindowNumber
, how do I get NSWindow
ref.
I tried using:
[NSApp windowWithWindowNumber:windowNumber]
but I always get a null value.
I need to get the NSWindow
to apply [window setlevel:NSFloatingWindowLevel]
, that I have set the always on top of a given window.
Does anyone know how to solve this problem or has any alternative solution?
Thanks for the answer, but this is not the solution, I had already tried but it does not work, actually I did a test , I tried the following code:
for (NSInteger i = 0; i <10000; i + +) {
NSWindow * wind;
wind = [NSApp windowWithWindowNumber: windowNumber];
NSLog (@ "\ n Window:% @", wind);
}
but the result is always the Window: (null)
I have a list of window, where can i get OwnerPid Number of window ecc.. ecc... and now I need to set the always on top of some windows.
The Always on top is possible set whit: [window setlevel:NSFloatingWindowLevel]
, window is a NSwindow
object, it's real?
Do you have a solution? or another idea , for my problem?
回答1:
kCGWindowNumber
is a CFNumber
/NSNumber
, -windowWithWindowNumber:
expects an NSInteger
. You'll need to extract the integer out of the window number reference (with -integerValue
) before passing it to -windowWithWindowNumber:
.
来源:https://stackoverflow.com/questions/7587028/get-nswindow-from-kcgwindownumber