So,
I'm firm enough to use MSDN and a lot of Windows APIs (surely just a tiny bit, but that suits my additional needs). However, I'm absolutely not firm with Mac OSX. I am currently programming a Ribbon Menu (already shown in the German forum, but still under development), which uses a few Windows APIs. I would like to make it available on Mac OSX too, but I've never used it (and never will). So, what I've already learned, is that I need "CocoaMessage()" and I know a bare minimum about the syntax from the help. However, can someone please help me convert some Windows API calls into CocoaMessages?
Namely SHAppBarMessage_ (or another way to the height of the taskbar), GetModuleHandle_ (needed for Tooltips), CreateWindowEx_ (for creating ToolTips), DestroyWindow_ (for uncreating ToolTips), SendMessage_ (for a lot of messages, is this even possible?), GetWindowRect_/GetClientRect_ (maybe not really needed), SetWindowLong_/GetWindowLong_ (manipulating control parameters, maybe done in different way), SetWindowPos_ (maybe not needed), CreateRoundRectRgn_/SetWindowRgn_/DeleteObject_ (rounding window corners), SetParent_ (move a control into another window), MoveWindow_ (maybe not needed), GetCursorPos_/ScreenToClient_/ClientToScreen_ (converting coordinates, maybe doable in another way), IsWindowVisible_ (check if window is visible), GetForegroundWindow_ (determine active window (systemwide)), IsWindowEnabled_ (determine whether window is enabled oder not), IsIconic_ (determine whether window was minimized or not), GetObject_/GetIconInfo_/DestroyIcon_ (not really needed, just for shared objects maybe), GetSysColor_ (the only one I know).
I know that's a lot, but I also didn't find the right documentation to learn it myself. same goes with Linux, I'd relly like to add it to the compatibility list too (maybe even the Raspi).
"Converting" Windows APIs to MacOS-APIs
"Converting" Windows APIs to MacOS-APIs
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: "Converting" Windows APIs to MacOS-APIs
Hi. The first thing you need to understand is that Windows, Linux and macOS are really different in many ways. You can't simply "convert" API calls, because usually the UI/API logic is different. Sometimes you can do something the way it's done in Windows, but that way you are simply transferring Windows UX and that can feel completely alien to Linux and macOS.
With that said, I'll post the ones I know
With that said, I'll post the ones I know
Code: Select all
Debug CocoaMessage(0,CocoaMessage(0,CocoaMessage(0,0,"NSApplication sharedApplication"),"mainMenu"),"menuBarHeight")
https://www.purebasic.fr/english/viewto ... 06#p427506
Code: Select all
Define cursor.CGPoint
CocoaMessage(@cursor,0,"NSEvent mouseLocation")
Debug cursor\x
Debug cursor\y
https://github.com/fantaisie-software/p ... ns.pb#L209 + https://developer.apple.com/documentati ... guage=objc
Re: "Converting" Windows APIs to MacOS-APIs
macOS works very differently than Windows.
But there are many examples how to work with CocoaMessage. Is all Objective-C and therefore take the examples and functions (Objects).
Links:
Methods, Tips & Tricks
Dump Object Methods
https://developer.apple.com/documentation/
Example with colors
But there are many examples how to work with CocoaMessage. Is all Objective-C and therefore take the examples and functions (Objects).
Links:
Methods, Tips & Tricks
Dump Object Methods
https://developer.apple.com/documentation/
Example with colors
Code: Select all
Procedure NSColorByNameToRGB(NSColorName.s)
Protected.cgfloat red, green, blue
Protected nscolorspace, rgb
nscolorspace = CocoaMessage(0, CocoaMessage(0, 0, "NSColor " + NSColorName), "colorUsingColorSpaceName:$", @"NSCalibratedRGBColorSpace")
If nscolorspace
CocoaMessage(@red, nscolorspace, "redComponent")
CocoaMessage(@green, nscolorspace, "greenComponent")
CocoaMessage(@blue, nscolorspace, "blueComponent")
rgb = RGB(red * 255.0, green * 255.0, blue * 255.0)
ProcedureReturn rgb
EndIf
EndProcedure
color = NSColorByNameToRGB("controlTextColor")
Debug Hex(color)
color = NSColorByNameToRGB("controlBackgroundColor")
Debug Hex(color)
color = NSColorByNameToRGB("systemGrayColor")
Debug Hex(color)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: "Converting" Windows APIs to MacOS-APIs
Ah, thanks to all of you. This is already something I'm able to work with. I'll read through all the basics and try my best. Maybe I should also use a virtual machine, that should make it easier.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB