Old 03-08-2019, 03:21 PM   #1
Human being with feelings
Join Date: Jul 2009
Posts: 2,659
Default macOS Objective C: When is a HWND not isKindOfClass:[NSWindow class]?

I am trying out some code for Apple, using Objective-C.

AFAIK, I am supposed to check whether HWNDs are usable, using
if ([(id)hwnd isKindOfClass:[NSWindow class]])
However, this seems to always return false, even for standard REAPER windows such as the MIDI editor, returned by MIDIEditor_GetActive.
juliansader is offline   Reply With Quote
Old 03-09-2019, 05:11 AM   #2
Human being with feelings
mespotine's Avatar
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,396

I don't know, if that helps, but as far as I could see, no hwnd on the mac-version of Reaper has a class-name available using JS_Window_GetClassName.
So maybe, it isn't available that way on Mac.
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 08-08-2019, 07:19 AM   #3
Human being with feelings
Join Date: Jul 2009
Posts: 2,659

To answer my own question, as far as I understand it: the child HWNDs inside a top-level parent window are of class NSView, and only the parent is the NSWindow. (And the ContentView is the highest accessible NSView object in the window’s view hierarchy.)

Some functions, such as setting opacity, only apply to NSWindows, so to get the NSWindow that contains the NSView (corresponding to a WDL/swell HWND), one can use:
NSView* view = (NSView*)hwnd;
NSWindow* window = (NSWindow*)[view window];
juliansader is offline   Reply With Quote

Thread Tools
Display Modes

Posting 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

Forum Jump

All times are GMT -7. The time now is 02:06 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.