How can I get PB window of an NSWindow?

Mac OSX specific forum
Wolfram
Enthusiast
Enthusiast
Posts: 568
Joined: Thu May 30, 2013 4:39 pm

How can I get PB window of an NSWindow?

Post by Wolfram »

Is there a way to get the PB internal handle of an NSWindow?
The opposed of WindowID()
macOS Catalina 10.15.7
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: How can I get PB window of an NSWindow?

Post by Shardik »

You may take a look into mk-soft's cross-platform system module and call procedure System::WindowPB(WindowHandle). For your conveniance I have extracted the essential MacOS parts into the following example:

Code: Select all

ImportC ""
  PB_Object_EnumerateStart(PB_Objects.I)
  PB_Object_EnumerateNext(PB_Objects.I, *ID.Integer )
  PB_Object_EnumerateAbort(PB_Objects.I)
  PB_Window_Objects.I
EndImport

Procedure GetPBWindowIDFromWindowHandle(WindowHandle.I)
  Protected Result.I = -1
  Protected PBWindowID.I

  PB_Object_EnumerateStart(PB_Window_Objects)

  While PB_Object_EnumerateNext(PB_Window_Objects, @PBWindowID)
    If WindowHandle = WindowID(PBWindowID)
      Result = PBWindowID
      Break
    EndIf
  Wend

  PB_Object_EnumerateAbort(PB_Window_Objects)

  ProcedureReturn Result
EndProcedure

OpenWindow(3, 270, 100, 200, 170, "Test")
MessageRequester("Info",
  "PB WindowID = " + Str(GetPBWindowIDFromWindowHandle(WindowID(3))))
Justin
Addict
Addict
Posts: 832
Joined: Sat Apr 26, 2003 2:49 pm

Re: How can I get PB window of an NSWindow?

Post by Justin »

Or you can save it first and then retrieve it:

Code: Select all

EnableExplicit

Define.i win

win = OpenWindow(#PB_Any, 10, 10, 600, 400, "test")
Debug win
objc_setAssociatedObject_(WindowID(win), "_PBWinID", win, 0)

MessageRequester("Info", "PB WindowID: " + Str(objc_getAssociatedObject_(WindowID(win), "_PBWinID")))
Wolfram
Enthusiast
Enthusiast
Posts: 568
Joined: Thu May 30, 2013 4:39 pm

Re: How can I get PB window of an NSWindow?

Post by Wolfram »

Shardik wrote:You may take a look into mk-soft's cross-platform system module and call procedure System::WindowPB(WindowHandle). For your conveniance I have extracted the essential MacOS parts into the following example:
Thanks Shardik. I didn't notice mk-soft's post.
macOS Catalina 10.15.7
Post Reply