Get Window Handle on Mac
BlitzMax Forums/BlitzMax Programming/Get Window Handle on Mac
| ||
Hi All, for a long time I've used this code to get a handle to the game window on Mac. I do this so I can work out where the window is positioned so that I can make the mouse cursor move in and out of the window nicely. However there's a fairly rare issues with it, which is that when the code is called, there's a chance the ANOTHER window (not the game) has the focus and so my code will screw up big time. So my question is, can anyone help get a handle to the actual BlitzMax window created with Graphics w,h,0 please? This code is in Objective C and is imported into my BMax code: NSWindow* macGetActiveWindow(){ NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init]; NSApplication *myApp; myApp=[NSApplication sharedApplication]; NSWindow *myWindow = [myApp keyWindow]; [pool release]; return myWindow; } Here's what I'm doing in Windows which is nice and safe for DirectX: ?Win32 If Driver=0 Then Local my_driver:TD3D7Graphicsdriver=D3D7GraphicsDriver() Local my_graphics:TD3D7Graphics=my_driver.Graphics() Return my_graphics._hwnd Else 'Use unreliable method in OpenGL until I get better code. Return GetActiveWindow() EndIf ? So I'm guessing the Mac solution may be similar, and might require a module tweak... Any help greatly appreciated as it'll help out a friend who's app is getting rejected in the Mac App Store at the moment, possible due to this code. Thanks! Last edited 2011 |
| ||
Just bumping this in case anyone has solved it in the last year? |