-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e611fa1
commit 147dac8
Showing
17 changed files
with
1,762 additions
and
1,762 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,62 @@ | ||
Attribute VB_Name = "API_AlwaysOnTop" | ||
'REFERENCE: https://www.mrexcel.com/forum/excel-questions/386643-userform-always-top-2.html | ||
'PURPOSE: This module includes the functions used to make sure that the Timer stays on top of all windows. | ||
|
||
Option Explicit | ||
|
||
Public Const SWP_NOMOVE = &H2 | ||
Public Const SWP_NOSIZE = &H1 | ||
|
||
' For hWndInsertAfter in SetWindowPos | ||
Public Enum HWND_TYPE | ||
HWND_TOP = 0 | ||
HWND_NOTOPMOST = -2 | ||
HWND_TOPMOST = -1 | ||
HWND_BOTTOM = 1 | ||
End Enum | ||
|
||
'https://msdn.microsoft.com/en-us/library/office/gg264421.aspx | ||
'64-Bit Visual Basic for Applications Overview | ||
'See also: https://sysmod.wordpress.com/2016/09/03/conditional-compilation-vba-excel-macwin3264/ | ||
'For Mac declarations | ||
|
||
|
||
#If VBA7 Then ' Excel 2010 or later for Windows | ||
|
||
'VBA version 7 compiler, therefore >= Office 2010 | ||
'PtrSafe means function works in 32-bit and 64-bit Office | ||
'LongPtr type alias resolves to Long (32 bits) in 32-bit Office, or LongLong (64 bits) in 64-bit Office | ||
|
||
Public Declare PtrSafe Function SetWindowPos Lib "user32" _ | ||
(ByVal hWnd As LongPtr, _ | ||
ByVal hWndInsertAfter As LongPtr, _ | ||
ByVal x As Long, _ | ||
ByVal Y As Long, _ | ||
ByVal cx As Long, _ | ||
ByVal cy As Long, _ | ||
ByVal uFlags As Long) As Long | ||
|
||
Public Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" _ | ||
(ByVal lpClassName As String, _ | ||
ByVal lpWindowName As String) As LongPtr | ||
|
||
#Else ' pre Excel 2010 for Windows | ||
'VBA version 6 or earlier compiler, therefore <= Office 2007 | ||
|
||
Public Declare Function SetWindowPos Lib "user32" _ | ||
(ByVal hWnd As Long, _ | ||
ByVal hWndInsertAfter As Long, _ | ||
ByVal X As Long, _ | ||
ByVal Y As Long, _ | ||
ByVal cx As Long, _ | ||
ByVal cy As Long, _ | ||
ByVal uFlags As Long) As Long | ||
|
||
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ | ||
(ByVal lpClassName As String, _ | ||
ByVal lpWindowName As String) As Long | ||
|
||
#End If | ||
|
||
|
||
|
||
Attribute VB_Name = "API_AlwaysOnTop" | ||
'REFERENCE: https://www.mrexcel.com/forum/excel-questions/386643-userform-always-top-2.html | ||
'PURPOSE: This module includes the functions used to make sure that the Timer stays on top of all windows. | ||
|
||
Option Explicit | ||
|
||
Public Const SWP_NOMOVE = &H2 | ||
Public Const SWP_NOSIZE = &H1 | ||
|
||
' For hWndInsertAfter in SetWindowPos | ||
Public Enum HWND_TYPE | ||
HWND_TOP = 0 | ||
HWND_NOTOPMOST = -2 | ||
HWND_TOPMOST = -1 | ||
HWND_BOTTOM = 1 | ||
End Enum | ||
|
||
'https://msdn.microsoft.com/en-us/library/office/gg264421.aspx | ||
'64-Bit Visual Basic for Applications Overview | ||
'See also: https://sysmod.wordpress.com/2016/09/03/conditional-compilation-vba-excel-macwin3264/ | ||
'For Mac declarations | ||
|
||
|
||
#If VBA7 Then ' Excel 2010 or later for Windows | ||
|
||
'VBA version 7 compiler, therefore >= Office 2010 | ||
'PtrSafe means function works in 32-bit and 64-bit Office | ||
'LongPtr type alias resolves to Long (32 bits) in 32-bit Office, or LongLong (64 bits) in 64-bit Office | ||
|
||
Public Declare PtrSafe Function SetWindowPos Lib "user32" _ | ||
(ByVal hWnd As LongPtr, _ | ||
ByVal hWndInsertAfter As LongPtr, _ | ||
ByVal x As Long, _ | ||
ByVal Y As Long, _ | ||
ByVal cx As Long, _ | ||
ByVal cy As Long, _ | ||
ByVal uFlags As Long) As Long | ||
|
||
Public Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" _ | ||
(ByVal lpClassName As String, _ | ||
ByVal lpWindowName As String) As LongPtr | ||
|
||
#Else ' pre Excel 2010 for Windows | ||
'VBA version 6 or earlier compiler, therefore <= Office 2007 | ||
|
||
Public Declare Function SetWindowPos Lib "user32" _ | ||
(ByVal hWnd As Long, _ | ||
ByVal hWndInsertAfter As Long, _ | ||
ByVal X As Long, _ | ||
ByVal Y As Long, _ | ||
ByVal cx As Long, _ | ||
ByVal cy As Long, _ | ||
ByVal uFlags As Long) As Long | ||
|
||
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _ | ||
(ByVal lpClassName As String, _ | ||
ByVal lpWindowName As String) As Long | ||
|
||
#End If | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
Attribute VB_Name = "API_Maximize" | ||
'PURPOSE: Contain function that allows to maximize or minimize a window. | ||
'REFERENCE: http://www.vbaexpress.com/forum/archive/index.php/t-36677.html | ||
|
||
Option Explicit | ||
|
||
#If VBA7 Then | ||
|
||
Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hWnd As LongPtr, ByVal nCmdShow As Long) As Long | ||
Declare PtrSafe Function GetForegroundWindow Lib "user32" () As LongPtr | ||
#Else | ||
Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long | ||
Declare Function GetForegroundWindow Lib "user32" () As Long | ||
#End If | ||
|
||
' ShowWindow() Commands | ||
Public Const SW_HIDE = 0 | ||
Public Const SW_SHOWNORMAL = 1 | ||
Public Const SW_NORMAL = 1 | ||
Public Const SW_SHOWMINIMIZED = 2 | ||
Public Const SW_SHOWMAXIMIZED = 3 | ||
Public Const SW_MAXIMIZE = 3 | ||
Public Const SW_SHOWNOACTIVATE = 4 | ||
Public Const SW_SHOW = 5 | ||
Public Const SW_MINIMIZE = 6 | ||
Public Const SW_SHOWMINNOACTIVE = 7 | ||
Public Const SW_SHOWNA = 8 | ||
Public Const SW_RESTORE = 9 | ||
Public Const SW_SHOWDEFAULT = 10 | ||
Public Const SW_MAX = 10 | ||
|
||
|
||
Attribute VB_Name = "API_Maximize" | ||
'PURPOSE: Contain function that allows to maximize or minimize a window. | ||
'REFERENCE: http://www.vbaexpress.com/forum/archive/index.php/t-36677.html | ||
|
||
Option Explicit | ||
|
||
#If VBA7 Then | ||
|
||
Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hWnd As LongPtr, ByVal nCmdShow As Long) As Long | ||
Declare PtrSafe Function GetForegroundWindow Lib "user32" () As LongPtr | ||
#Else | ||
Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long | ||
Declare Function GetForegroundWindow Lib "user32" () As Long | ||
#End If | ||
|
||
' ShowWindow() Commands | ||
Public Const SW_HIDE = 0 | ||
Public Const SW_SHOWNORMAL = 1 | ||
Public Const SW_NORMAL = 1 | ||
Public Const SW_SHOWMINIMIZED = 2 | ||
Public Const SW_SHOWMAXIMIZED = 3 | ||
Public Const SW_MAXIMIZE = 3 | ||
Public Const SW_SHOWNOACTIVATE = 4 | ||
Public Const SW_SHOW = 5 | ||
Public Const SW_MINIMIZE = 6 | ||
Public Const SW_SHOWMINNOACTIVE = 7 | ||
Public Const SW_SHOWNA = 8 | ||
Public Const SW_RESTORE = 9 | ||
Public Const SW_SHOWDEFAULT = 10 | ||
Public Const SW_MAX = 10 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,70 @@ | ||
Attribute VB_Name = "API_Pixel" | ||
'PURPOSE: This module have functions to help convert pixels to points in Excel, allowing to scale things. | ||
'REFERENCE: http://www.vbaexpress.com/forum/showthread.php?21896-Pixel-to-Point-ratio | ||
|
||
Option Explicit | ||
|
||
#If VBA7 Then | ||
Private Declare PtrSafe Function GetDC Lib "user32" (ByVal hWnd As LongPtr) As LongPtr | ||
Private Declare PtrSafe Function ReleaseDC Lib "user32" (ByVal hWnd As LongPtr, ByVal hdc As LongPtr) As Long | ||
Private Declare PtrSafe Function GetDeviceCaps Lib "gdi32" (ByVal hdc As LongPtr, ByVal nIndex As Long) As Long | ||
#Else | ||
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long | ||
Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hdc As Long) As Long | ||
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long | ||
#End If | ||
|
||
Private Const LOGPIXELSX As Long = 88 | ||
Private Const LOGPIXELSY As Long = 90 | ||
|
||
Function PointPerPixelX() As Double | ||
#If VBA7 Then | ||
Dim hdc As LongPtr | ||
#Else | ||
Dim hdc As Long | ||
#End If | ||
hdc = GetDC(0) | ||
PointPerPixelX = 1 / (GetDeviceCaps(hdc, LOGPIXELSX) / 72) | ||
End Function | ||
|
||
Function PointPerPixelY() As Double | ||
#If VBA7 Then | ||
Dim hdc As LongPtr | ||
#Else | ||
Dim hdc As Long | ||
#End If | ||
hdc = GetDC(0) | ||
PointPerPixelY = 1 / (GetDeviceCaps(hdc, LOGPIXELSY) / 72) | ||
End Function | ||
|
||
Sub Example() | ||
#If VBA7 Then | ||
Dim hdc As LongPtr | ||
#Else | ||
Dim hdc As Long | ||
#End If | ||
Dim PixPerInchX As Long | ||
Dim PixPerInchY As Long | ||
Dim PixPerPtX As Double | ||
Dim PixPerPtY As Double | ||
Dim PtPerPixX As Double | ||
Dim PtPerPixY As Double | ||
|
||
hdc = GetDC(0) | ||
|
||
PixPerInchX = GetDeviceCaps(hdc, LOGPIXELSX) | ||
PixPerInchY = GetDeviceCaps(hdc, LOGPIXELSY) | ||
|
||
'there are 72 points per inch | ||
PixPerPtX = PixPerInchX / 72 | ||
PixPerPtY = PixPerInchY / 72 | ||
|
||
Debug.Print "PixPerPtX: " & PixPerPtX, "PixPerPtY: " & PixPerPtY | ||
|
||
PtPerPixX = 1 / PixPerPtX | ||
PtPerPixY = 1 / PixPerPtY | ||
|
||
Debug.Print "PtPerPixX: " & PtPerPixX, "PtPerPixY: " & PtPerPixX | ||
ReleaseDC 0, hdc | ||
End Sub | ||
|
||
Attribute VB_Name = "API_Pixel" | ||
'PURPOSE: This module have functions to help convert pixels to points in Excel, allowing to scale things. | ||
'REFERENCE: http://www.vbaexpress.com/forum/showthread.php?21896-Pixel-to-Point-ratio | ||
|
||
Option Explicit | ||
|
||
#If VBA7 Then | ||
Private Declare PtrSafe Function GetDC Lib "user32" (ByVal hWnd As LongPtr) As LongPtr | ||
Private Declare PtrSafe Function ReleaseDC Lib "user32" (ByVal hWnd As LongPtr, ByVal hdc As LongPtr) As Long | ||
Private Declare PtrSafe Function GetDeviceCaps Lib "gdi32" (ByVal hdc As LongPtr, ByVal nIndex As Long) As Long | ||
#Else | ||
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long | ||
Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hdc As Long) As Long | ||
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long | ||
#End If | ||
|
||
Private Const LOGPIXELSX As Long = 88 | ||
Private Const LOGPIXELSY As Long = 90 | ||
|
||
Function PointPerPixelX() As Double | ||
#If VBA7 Then | ||
Dim hdc As LongPtr | ||
#Else | ||
Dim hdc As Long | ||
#End If | ||
hdc = GetDC(0) | ||
PointPerPixelX = 1 / (GetDeviceCaps(hdc, LOGPIXELSX) / 72) | ||
End Function | ||
|
||
Function PointPerPixelY() As Double | ||
#If VBA7 Then | ||
Dim hdc As LongPtr | ||
#Else | ||
Dim hdc As Long | ||
#End If | ||
hdc = GetDC(0) | ||
PointPerPixelY = 1 / (GetDeviceCaps(hdc, LOGPIXELSY) / 72) | ||
End Function | ||
|
||
Sub Example() | ||
#If VBA7 Then | ||
Dim hdc As LongPtr | ||
#Else | ||
Dim hdc As Long | ||
#End If | ||
Dim PixPerInchX As Long | ||
Dim PixPerInchY As Long | ||
Dim PixPerPtX As Double | ||
Dim PixPerPtY As Double | ||
Dim PtPerPixX As Double | ||
Dim PtPerPixY As Double | ||
|
||
hdc = GetDC(0) | ||
|
||
PixPerInchX = GetDeviceCaps(hdc, LOGPIXELSX) | ||
PixPerInchY = GetDeviceCaps(hdc, LOGPIXELSY) | ||
|
||
'there are 72 points per inch | ||
PixPerPtX = PixPerInchX / 72 | ||
PixPerPtY = PixPerInchY / 72 | ||
|
||
Debug.Print "PixPerPtX: " & PixPerPtX, "PixPerPtY: " & PixPerPtY | ||
|
||
PtPerPixX = 1 / PixPerPtX | ||
PtPerPixY = 1 / PixPerPtY | ||
|
||
Debug.Print "PtPerPixX: " & PtPerPixX, "PtPerPixY: " & PtPerPixX | ||
ReleaseDC 0, hdc | ||
End Sub | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
Attribute VB_Name = "API_Sleep" | ||
'PURPOSE: Define the sleep function to stop the code from running and releasing CPU usage. | ||
|
||
Option Explicit | ||
|
||
#If VBA7 Then ' Excel 2010 or later for Windows | ||
|
||
Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'For 64 Bit Systems | ||
|
||
#Else ' pre Excel 2010 for Windows | ||
|
||
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'For 32 Bit Systems | ||
|
||
#End If | ||
|
||
|
||
Sub SleepTest() | ||
'MsgBox "Execution is started" | ||
Sleep 10000 'delay in milliseconds | ||
MsgBox "Waiting completed" | ||
End Sub | ||
Attribute VB_Name = "API_Sleep" | ||
'PURPOSE: Define the sleep function to stop the code from running and releasing CPU usage. | ||
|
||
Option Explicit | ||
|
||
#If VBA7 Then ' Excel 2010 or later for Windows | ||
|
||
Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'For 64 Bit Systems | ||
|
||
#Else ' pre Excel 2010 for Windows | ||
|
||
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'For 32 Bit Systems | ||
|
||
#End If | ||
|
||
|
||
Sub SleepTest() | ||
'MsgBox "Execution is started" | ||
Sleep 10000 'delay in milliseconds | ||
MsgBox "Waiting completed" | ||
End Sub |
Oops, something went wrong.