microsoft_excel:macros:window_api_declarations
Differences
This shows you the differences between two versions of the page.
microsoft_excel:macros:window_api_declarations [2021/08/04 14:28] – created peter | microsoft_excel:macros:window_api_declarations [2021/08/04 15:22] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Microsoft Excel - Macros - Window API Declarations ====== | ||
- | |||
- | <code excel> | ||
- | ' Window API Declarations | ||
- | ' These Declares MUST appear at the top of the code module, above and before any VBA procedures. | ||
- | |||
- | 'Const HWND_BOTTOM = 1 | ||
- | Const SWP_NOSIZE = &H1 | ||
- | Const SWP_NOMOVE = &H2 | ||
- | Const SWP_NOACTIVATE = &H10 | ||
- | Const SWP_SHOWWINDOW = &H40 | ||
- | |||
- | Public Const HWND_TOPMOST = -1 | ||
- | Public Const HWND_NOTOPMOST = -2 | ||
- | Public Const HWND_TOP = 0 | ||
- | Public Const HWND_BOTTOM = 1 | ||
- | |||
- | |||
- | ' http:// | ||
- | ' | ||
- | ' Message boxes are always modal, which means that the underlying application (e.g. Excel) waits for a response from | ||
- | ' the User and does not allow any other interaction until one is given. | ||
- | ' By default they are application modal (they remain in front of all other windows belonging to the owning application | ||
- | ' but have no impact on other applications), | ||
- | ' windows although they have no non-visual impact on applications other than the owning one). | ||
- | ' | ||
- | ' Use the Message Box facility directly, via the Windows API, instead of via the VBA interface. | ||
- | ' Using it is pretty much the same as using MsgBox, except that you have the opportunity to set some parameter values | ||
- | ' which are defaulted in the VBA interface, in particular the message box, although technically still modal, can be | ||
- | ' attached to any window, or none. If you do not attach it to your window, it will not restrict your User's interaction | ||
- | ' with the application. | ||
- | Private Declare Function MessageBox _ | ||
- | Lib " | ||
- | | ||
- | ByVal lpText As String, _ | ||
- | ByVal lpCaption As String, _ | ||
- | ByVal wType As Long) _ | ||
- | As Long | ||
- | |||
- | |||
- | ' Used to have XL be on top of all other windows. | ||
- | #If Win64 Then | ||
- | Public Declare PtrSafe Function SetWindowPos _ | ||
- | Lib " | ||
- | 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 wFlags As Long) _ | ||
- | As Long | ||
- | #Else | ||
- | Public Declare Function SetWindowPos _ | ||
- | Lib " | ||
- | 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 wFlags As Long) _ | ||
- | As Long | ||
- | #End If | ||
- | </ | ||
microsoft_excel/macros/window_api_declarations.1628087316.txt.gz · Last modified: 2021/08/04 14:28 by peter