Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 49888

Mac Versions of Library Functions?

$
0
0
I have over 60k lines of code, and therefore use many Library functions for all my features to work. I am aware that they only work for Windows machines, and won't work properly for Mac? Can someone give me the Mac equivalents or advise me what to do if my App is run on Mac? Thanks

Code:

' Functions for the custom menu...
Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
' Functions for the custom menu...
Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
' Functions for the custom menu...
Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
' Functions for the custom menu...
Private Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
' Function for getting cursor position
Private Declare PtrSafe Function GetCursorPos Lib "user32" (lpPoint As XYPosn) As Long
Private Declare PtrSafe Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As XYPosn) As Long
Private Declare PtrSafe Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare PtrSafe Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex As Long) As Long
Private Declare PtrSafe Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDC As Long) As Long
Private Declare PtrSafe Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer ' for detecting key presses and mouse clicks

Private Declare PtrSafe Function GetSystemMetrics Lib "User32.dll" (ByVal nIndex As Long) As Long
Private Declare PtrSafe Function GetCurrentThreadId Lib "kernel32" () As Long
Public Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
#If Win64 Then '64?
    Private Declare PtrSafe Function MsgBoxTimeout _
        Lib "user32" _
        Alias "MessageBoxTimeoutA" ( _
            ByVal hwnd As LongPtr, _
            ByVal lpText As String, _
            ByVal lpCaption As String, _
            ByVal wType As VbMsgBoxStyle, _
            ByVal wlange As Long, _
            ByVal dwTimeout As Long) _
    As Long
#Else
    Private Declare Function MsgBoxTimeout _
        Lib "user32" _
        Alias "MessageBoxTimeoutA" ( _
            ByVal hwnd As Long, _
            ByVal lpText As String, _
            ByVal lpCaption As String, _
            ByVal wType As VbMsgBoxStyle, _
            ByVal wlange As Long, _
            ByVal dwTimeout As Long) _
    As Long
#End If

' Clipboard
#If Mac Then
    ' do nothing
#Else
    #If VBA7 Then
        Declare PtrSafe Function GlobalUnlock Lib "kernel32" (ByVal hMem As LongPtr) As LongPtr
        Declare PtrSafe Function GlobalLock Lib "kernel32" (ByVal hMem As LongPtr) As LongPtr
        Declare PtrSafe Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, _
                                                            ByVal dwBytes As LongPtr) As LongPtr

        Declare PtrSafe Function CloseClipboard Lib "user32" () As Long
        Declare PtrSafe Function OpenClipboard Lib "user32" (ByVal hwnd As LongPtr) As LongPtr
        Declare PtrSafe Function EmptyClipboard Lib "user32" () As Long

        Declare PtrSafe Function lstrcpy Lib "kernel32" (ByVal lpString1 As Any, _
                                                        ByVal lpString2 As Any) As LongPtr

        Declare PtrSafe Function SetClipboardData Lib "user32" (ByVal wFormat _
                                                                As Long, ByVal hMem As LongPtr) As LongPtr
    #Else
        Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
        Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
        Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, _
                                                    ByVal dwBytes As Long) As Long

        Declare Function CloseClipboard Lib "user32" () As Long
        Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
        Declare Function EmptyClipboard Lib "user32" () As Long

        Declare Function lstrcpy Lib "kernel32" (ByVal lpString1 As Any, _
                                                ByVal lpString2 As Any) As Long

        Declare Function SetClipboardData Lib "user32" (ByVal wFormat _
                                                        As Long, ByVal hMem As Long) As Long
    #End If
#End If

' CURSOR

#If VBA7 Then
    Declare PtrSafe Function LoadCursorLong Lib "user32" Alias "LoadCursorA" _
      (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
   
    Declare PtrSafe Function SetCursor Lib "user32" _
      (ByVal hCursor As Long) As Long

    Declare PtrSafe Function GetCursorInfo _
        Lib "user32" (ByRef pci As CURSORINFO) As Boolean
   
    Declare PtrSafe Function LoadCursor _
        Lib "user32" Alias "LoadCursorA" _
        (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
#Else
    Declare Function LoadCursorLong Lib "user32" Alias "LoadCursorA" _
      (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
   
    Declare Function SetCursor Lib "user32" _
      (ByVal hCursor As Long) As Long
     
    Declare Function GetCursorInfo _
        Lib "user32" (ByRef pci As CURSORINFO) As Boolean
   
    Declare Function LoadCursor _
        Lib "user32" Alias "LoadCursorA" _
        (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long

#End If


Viewing all articles
Browse latest Browse all 49888

Trending Articles