Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms Positioning DUknow Excel Discussion (Misc queries) 0 May 6th 09 01:29 AM
Cursor positioning mulligbo Excel Discussion (Misc queries) 6 November 6th 06 05:26 AM
AutoShape Positioning? Ken Excel Discussion (Misc queries) 2 February 8th 05 11:45 PM
Positioning a DOS Window Robin Clay[_3_] Excel Programming 4 August 13th 04 12:30 AM
= positioning snax500[_2_] Excel Programming 1 June 28th 04 08:24 PM


All times are GMT +1. The time now is 11:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"