Trying to understand MacOS Declare

I have been attempting to understand how to use the Declare keyword to open a page setup dialog box.

I know you can do this internally but the HTMLViewer does not work with this hence I am trying a direct call into MacOS.

A Applescript version of this works but I can’t seem to get Declare to work. I must be doing something wrong.

Can someone help please.

Thanks

Terry

  declare function NSClassFromString lib "Foundation" (aClassName as CFStringRef) as Ptr
  declare function pageLayout  lib "AppKit" selector "pageLayout"(classRef as Ptr) as Ptr
  declare function runModal  lib "AppKit" selector "runModal"(classRef as Ptr) as Integer
  
  dim pageLayoutInstance as Ptr = pageLayout(NSPageSetupRef)
  dim keyPressed As Integer = runModal(pageLayoutInstance)

Aha,

Found why it wouldn’t work.

This will allow you to select have a Page Setup dialog box that seems at first use will work with the HTMLViewer.

Terry

  declare function NSClassFromString lib "Foundation" (aClassName as CFStringRef) as Ptr
  declare function pageLayout  lib "AppKit" selector "pageLayout"(classRef as Ptr) as Ptr
  declare function runModal  lib "AppKit" selector "runModal"(classRef as Ptr) as Integer
  
  dim NSPageSetupRef as Ptr = NSClassFromString("NSPageLayout")
  dim pageLayoutInstance as Ptr = pageLayout(NSPageSetupRef)
  dim keyPressed As Integer = runModal(pageLayoutInstance)