Hi, I'm trying to get a handle to the active window on Mac OS so that I can use it later to check the window position. But I'm having trouble passing values back from the C function into Bmax. Can anyone help please as this is really not my area of expertise...Thanks!
First here's the C code I've got (saved in GAGMacLib.m):
It supposed to return an NSWindow class to the calling code.
I want to store that class (well a pointer to it) in Blitz so that later on I can call this C code:
So how do I store a pointer to the NSWindow class and then pass it into the second function later? I have this code in which print appears to print some kind of value but then the app just crashes.
First here's the C code I've got (saved in GAGMacLib.m):
#include <AppKit/AppKit.h> NSWindow macGetActiveWindow(){ NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init]; NSApplication *myApp; myApp=[NSApplication sharedApplication]; NSWindow *myWindow = [myApp keyWindow]; [pool release]; return *myWindow; }
It supposed to return an NSWindow class to the calling code.
I want to store that class (well a pointer to it) in Blitz so that later on I can call this C code:
void macGetWindowOrigin(NSWindow *myWindow, int *x, int *y){ NSRect myFrame = [myWindow frame]; *x = myFrame.origin.x; *y = myFrame.origin.y; }
So how do I store a pointer to the NSWindow class and then pass it into the second function later? I have this code in which print appears to print some kind of value but then the app just crashes.
Strict Import "../include/GAGMacLib.m" Extern Function macGetWindowOrigin(handle: Int Ptr, x:Int Ptr, y:Int Ptr) Function macGetActiveWindow:Int Ptr() End Extern Graphics 640,480, 0 Global WindowHandle: Int Ptr = macGetActiveWindow() Print WindowHandle[0] While Not KeyDown(KEY_ESCAPE) Cls DrawText "testing...",10,10 Flip Wend End