Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Message Box Positioning
This works fine for VB 6.0 & Excel 2000, but I get a syntax error when run
on Excel 98. Can I change anything to get it to work on both versions? Thanks lgHook = SetWindowsHookEx(&H5, AddressOf WinProc, 0, GetCurrentThreadId) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Message Box Positioning
Hi John
AddressOf solution for Office97 is available in the following link (Ken Getz and Michael Kaplan): http://www.trigeminal.com/code/CallBacks.zip that becomes much more complicated and it would be simpler to use a userform. Option Explicit ' Excel97 declarations Private Declare Function GetCurrentVbaProject _ Lib "vba332.dll" Alias "EbGetExecutingProj" _ (hProject As Long) As Long Private Declare Function GetFuncID _ Lib "vba332.dll" Alias "TipGetFunctionId" _ (ByVal hProject As Long, ByVal strFunctionName As String, _ ByRef strFunctionID As String) As Long Private Declare Function GetAddr _ Lib "vba332.dll" Alias "TipGetLpfnOfFunctionId" _ (ByVal hProject As Long, ByVal strFunctionID As String, _ ByRef lpfn As Long) As Long ' ------------------------------------------------------- Private Declare Function UnhookWindowsHookEx Lib _ "user32" (ByVal hHook As Long) As Long Private Declare Function GetCurrentThreadId Lib _ "kernel32" () As Long Private Declare Function SetWindowsHookEx Lib _ "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long _ , ByVal lpfn As Long, ByVal hmod As Long _ , ByVal dwThreadId As Long) As Long Private 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 wFlags As Long) As Long Private lgHook As Long Sub Positionned_MsgBox() #If VBA6 Then lgHook = SetWindowsHookEx(&H5, AddressOf WinProc, 0, GetCurrentThreadId) #Else lgHook = SetWindowsHookEx(&H5, AddrOf("WinProc"), 0, GetCurrentThreadId) #End If MsgBox "Special msgbox (Left = 100 / Top = 100) !", 64 End Sub Private Function WinProc(ByVal lMsg As Long, ByVal wParam As Long) As Long If lMsg = 5 Then SetWindowPos wParam, 0, 100, 100, 0, 0, &H15 UnhookWindowsHookEx lgHook End If WinProc = False End Function #If VBA6 Then #Else '* AddressOf operator replacement for Office97 VBA '* Authors: Ken Getz and Michael Kaplan Public Function AddrOf(CallbackFunctionName As String) As Long Dim aResult As Long, CurrentVBProject As Long, strFunctionID As String Dim AddressOfFunction As Long, UnicodeFunctionName As String '* Convert the name of the function to Unicode system UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode) '* If the current VBProjects exists... If Not GetCurrentVbaProject(CurrentVBProject) = 0 Then '* ...get the function ID of the callback function, based on its '* unicode-converted name, in order to ensure that it exists aResult = GetFuncID(hProject:=CurrentVBProject, _ strFunctionName:=UnicodeFunctionName, strFunctionID:=strFunctionID) '* If the function exists indeed ... If aResult = 0 Then ' *...get a pointer to the callback function based on ' * the strFunctionID argument of the GetFuncID function aResult = GetAddr(hProject:=CurrentVBProject, _ strFunctionID:=strFunctionID, lpfnAddressOf:=AddressOfFunction) '* If we've got the pointer pass it to the result of the function If aResult = 0 Then AddrOf = AddressOfFunction End If End If End Function #End If Regards; MP "John Keturi" a écrit dans le message de news:950dd.49649$hj.16256@fed1read07... This works fine for VB 6.0 & Excel 2000, but I get a syntax error when run on Excel 98. Can I change anything to get it to work on both versions? Thanks lgHook = SetWindowsHookEx(&H5, AddressOf WinProc, 0, GetCurrentThreadId) |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Message Box Positioning
Win32API on a Mac ? I think you already know the answer !
The good news is, both platforms will happily show a Userform that looks and acts like a msgbox anywhere on the screen. Regards, Vic Eldridge "John Keturi" wrote: This works fine for VB 6.0 & Excel 2000, but I get a syntax error when run on Excel 98. Can I change anything to get it to work on both versions? Thanks lgHook = SetWindowsHookEx(&H5, AddressOf WinProc, 0, GetCurrentThreadId) |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Message Box Positioning
Excel 98 is the Macintosh version.
-- Regards, Tom Ogilvy "Michel Pierron" wrote in message ... Hi John AddressOf solution for Office97 is available in the following link (Ken Getz and Michael Kaplan): http://www.trigeminal.com/code/CallBacks.zip that becomes much more complicated and it would be simpler to use a userform. Option Explicit ' Excel97 declarations Private Declare Function GetCurrentVbaProject _ Lib "vba332.dll" Alias "EbGetExecutingProj" _ (hProject As Long) As Long Private Declare Function GetFuncID _ Lib "vba332.dll" Alias "TipGetFunctionId" _ (ByVal hProject As Long, ByVal strFunctionName As String, _ ByRef strFunctionID As String) As Long Private Declare Function GetAddr _ Lib "vba332.dll" Alias "TipGetLpfnOfFunctionId" _ (ByVal hProject As Long, ByVal strFunctionID As String, _ ByRef lpfn As Long) As Long ' ------------------------------------------------------- Private Declare Function UnhookWindowsHookEx Lib _ "user32" (ByVal hHook As Long) As Long Private Declare Function GetCurrentThreadId Lib _ "kernel32" () As Long Private Declare Function SetWindowsHookEx Lib _ "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long _ , ByVal lpfn As Long, ByVal hmod As Long _ , ByVal dwThreadId As Long) As Long Private 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 wFlags As Long) As Long Private lgHook As Long Sub Positionned_MsgBox() #If VBA6 Then lgHook = SetWindowsHookEx(&H5, AddressOf WinProc, 0, GetCurrentThreadId) #Else lgHook = SetWindowsHookEx(&H5, AddrOf("WinProc"), 0, GetCurrentThreadId) #End If MsgBox "Special msgbox (Left = 100 / Top = 100) !", 64 End Sub Private Function WinProc(ByVal lMsg As Long, ByVal wParam As Long) As Long If lMsg = 5 Then SetWindowPos wParam, 0, 100, 100, 0, 0, &H15 UnhookWindowsHookEx lgHook End If WinProc = False End Function #If VBA6 Then #Else '* AddressOf operator replacement for Office97 VBA '* Authors: Ken Getz and Michael Kaplan Public Function AddrOf(CallbackFunctionName As String) As Long Dim aResult As Long, CurrentVBProject As Long, strFunctionID As String Dim AddressOfFunction As Long, UnicodeFunctionName As String '* Convert the name of the function to Unicode system UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode) '* If the current VBProjects exists... If Not GetCurrentVbaProject(CurrentVBProject) = 0 Then '* ...get the function ID of the callback function, based on its '* unicode-converted name, in order to ensure that it exists aResult = GetFuncID(hProject:=CurrentVBProject, _ strFunctionName:=UnicodeFunctionName, strFunctionID:=strFunctionID) '* If the function exists indeed ... If aResult = 0 Then ' *...get a pointer to the callback function based on ' * the strFunctionID argument of the GetFuncID function aResult = GetAddr(hProject:=CurrentVBProject, _ strFunctionID:=strFunctionID, lpfnAddressOf:=AddressOfFunction) '* If we've got the pointer pass it to the result of the function If aResult = 0 Then AddrOf = AddressOfFunction End If End If End Function #End If Regards; MP "John Keturi" a écrit dans le message de news:950dd.49649$hj.16256@fed1read07... This works fine for VB 6.0 & Excel 2000, but I get a syntax error when run on Excel 98. Can I change anything to get it to work on both versions? Thanks lgHook = SetWindowsHookEx(&H5, AddressOf WinProc, 0, GetCurrentThreadId) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Forms Positioning | Excel Discussion (Misc queries) | |||
Cursor positioning | Excel Discussion (Misc queries) | |||
AutoShape Positioning? | Excel Discussion (Misc queries) | |||
Positioning a DOS Window | Excel Programming | |||
= positioning | Excel Programming |