A
alex2005
Guest
Hi!
I want to make it possible for the user to click a button in a report but I understand that it's impossible. So im thinking, what if I can subclass a report and then use WM_LBUTTONDOWN, check the cursor position and take appropriate action if its over the button. However when I try to subclass the report access freezes and I have to restart it.. Can anyone tell me what im doing wrong? Im using Access 2002, and windows xp..
Here's the code im using..
----------------------------------- This code is in a module
Option Compare Database
Option Explicit
Public Const GWL_WNDPROC = -4
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Long, _
ByVal hwnd As Long, _
ByVal msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Public Const WM_LBUTTONDOWN = &H201
Public Const GWL_WNDPROC = -4
Public lpPrevWndProc As Long
Public Function WindowProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Function
--------------------------------------------
------------------------- This code is in a Report named "Report_Rapport1"
Private Sub Report_Open(Cancel As Integer)
lpPrevWndProc = SetWindowLong(Report_Rapport1.hwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Private Sub Report_Close()
Call SetWindowLong(Report_Rapport1.hwnd, GWL_WNDPROC, lpPrevWndProc)
End Sub
--------------------------------------------------------
This code shouldnt do anything as all messages is passed to the default window procedure right?
I want to make it possible for the user to click a button in a report but I understand that it's impossible. So im thinking, what if I can subclass a report and then use WM_LBUTTONDOWN, check the cursor position and take appropriate action if its over the button. However when I try to subclass the report access freezes and I have to restart it.. Can anyone tell me what im doing wrong? Im using Access 2002, and windows xp..
Here's the code im using..
----------------------------------- This code is in a module
Option Compare Database
Option Explicit
Public Const GWL_WNDPROC = -4
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Long, _
ByVal hwnd As Long, _
ByVal msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Public Const WM_LBUTTONDOWN = &H201
Public Const GWL_WNDPROC = -4
Public lpPrevWndProc As Long
Public Function WindowProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Function
--------------------------------------------
------------------------- This code is in a Report named "Report_Rapport1"
Private Sub Report_Open(Cancel As Integer)
lpPrevWndProc = SetWindowLong(Report_Rapport1.hwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Private Sub Report_Close()
Call SetWindowLong(Report_Rapport1.hwnd, GWL_WNDPROC, lpPrevWndProc)
End Sub
--------------------------------------------------------
This code shouldnt do anything as all messages is passed to the default window procedure right?