[Subclass] Truble on A_XP

A

ALESSANDRO Baraldi

Hi all.

I build an Application on A97 wich is SubClassed by "addrOf"
all work good, no one problem.

I convert my application from A97 to A_Xp, i change the callback
function to AddressOf.
My Application woek good, but when i open my Subclassed Form
on Design View ad after this i try to Run my application the
SubClass fail an access Crash.
Each time i open on Design view i need to Close Access, and reopen.
In this way i have no problem.

I don't understand what can be my problem, but on A97 all work goos
so i think a Bug.
Some one know about a Bug or have any idea of what happened..?

Thank you very much.
 
S

Stephen Lebans

There is no Bug. For A2K or higher you can use the native AddressOf
method.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
T

TC

Just for interest, when you personally write an app for A97 & above, and you
need to use the AddressOf function in A97, & the native operator in A2k+, do
you bracket the two methods with a compile-time IF/ELSE, a runtime IF/ELSE,
or do you just comment the appropruiate lines in & when you produce each
version's MDE?

TIA,
TC


Stephen Lebans said:
There is no Bug. For A2K or higher you can use the native AddressOf
method.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
S

Stephen Lebans

Because I am coding a solution for others to use I leave the code in for
both A97 and A2K or higher and simply comment out the appropriate lines.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


TC said:
Just for interest, when you personally write an app for A97 & above, and you
need to use the AddressOf function in A97, & the native operator in A2k+, do
you bracket the two methods with a compile-time IF/ELSE, a runtime IF/ELSE,
or do you just comment the appropruiate lines in & when you produce each
version's MDE?

TIA,
TC


"Stephen Lebans"
wrote in message news:[email protected]...
 
A

ALESSANDRO Baraldi

Stephen Lebans said:
There is no Bug. For A2K or higher you can use the native AddressOf
method.


Hi Stephen.
On my conversion occur a strange problem.
On A97 no problem at all my Subclass method work good.

On A_XP when i open my SubClassed Form in Design View to
make some change(only graphic, no necessary on the code), i
close the form (Saveyes).
I open my form on NormalView my application crash, the Subclass
crash my application.
If i close all application, reopen my form no problem on my application
i can Close/Open any time i need, but only NormalView, if i use Design
is necessary to close Access.

It's a very strange operation.

I put Subclass code on Load and Usubclass on Unload.

Have you some idea....?
(I do not know if I have explained the problem correctly, my english
is no good)

Thank you very much.
 
A

ALESSANDRO Baraldi

This Code build by "COMCTL32" a Slider Control on my Form.
The control have no problem, work good, i'm sure is SubClassing
method....!



On Module "basSubClass"

Public NextProcs As Long

Public Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
On Error Resume Next
Select Case hWnd


Case Forms!Slider.hWnd
Forms!Slider.ProcMsg hWnd, uMsg, wParam, lParam, 0& ', 0&

End Select
WindowProc = CallWindowProc(NextProcs, hWnd, uMsg, wParam, ByVal lParam)
End Function


On Form "Slider"

Private Sub SubClass(hWnd As Long)
On Error Resume Next
'Access_XP
NextProcs = SetWindowLong(Me.hWnd, GWL_WNDPROC, AddressOf WindowProc)

'Access 97
'NextProcs = SetWindowLong(Me.hwnd, GWL_WNDPROC, AddrOf("WindowProc"))

End Sub

Private Sub UnSubClass()
If NextProcs Then
SetWindowLong Me.hWnd, GWL_WNDPROC, NextProcs
NextProcs = 0
End If
End Sub

Public Sub ProcMsg(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As
Long, ByVal lParam As Long, result As Long)

On Error Resume Next
Select Case uMsg

Case WM_HSCROLL
'the window being scrolled is the slider we created then
'Get the position
If lParam = SliderH.GetTracBarHwnd Then
Me.Text1 = SliderH.Position
End If

Case WM_VSCROLL
If lParam = SliderV.GetTracBarHwnd Then
Me.Text2 = SliderV.Position
End If

End Select
End Sub

Thanks again.
 
S

Stephen Lebans

Alessandro you do know about the A2K or higher subclassing bug don't
you?

From: Stephen Lebans ([email protected])
Subject: Re: Sizing forms when Access MDI is resized


View this article only
Newsgroups: microsoft.public.access.forms
Date: 2003-01-19 13:42:02 PST


There is no exposed event. You would have to have to subclass the
window. For A2K or higher this would require the subclassing code to be
in an external DLL. This is due to a bug in the interaction between
Access and VB IDE(unless you are running an MDE or can absolutely
guarantee that the VB IDE will never be active during the current
session).




--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
A

ALESSANDRO Baraldi

Alessandro you do know about the A2K or higher subclassing bug don't
you?

From: Stephen Lebans ([email protected])
Subject: Re: Sizing forms when Access MDI is resized


View this article only
Newsgroups: microsoft.public.access.forms
Date: 2003-01-19 13:42:02 PST


There is no exposed event. You would have to have to subclass the
window. For A2K or higher this would require the subclassing code to be
in an external DLL. This is due to a bug in the interaction between
Access and VB IDE(unless you are running an MDE or can absolutely
guarantee that the VB IDE will never be active during the current
session).

MMMmmm....!!!
Now i understand.
I don't like much this solution.
Buolding a VB(dl) i need to distribute VBRuntime.
Have you some reference to build or to find builded dll.
If i try to build SubClass(dll) on VC++ is possible to make
it work in Access(i think yes).
Bye Stephen good week end to you and your family.


Alessandro Baraldi
 
S

Stephen Lebans

Yes you can easily build an ActiveX or a standard Windows DLL to hold
the subclassing code. There are tons of examples out there in C++ land.
THe MouseHook solution on my site is an example of using a standard
WIndows DLL to hold subclassing, or in my case, Message Hook code.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
A

ALESSANDRO Baraldi

Yes you can easily build an ActiveX or a standard Windows DLL to hold
the subclassing code. There are tons of examples out there in C++ land.
THe MouseHook solution on my site is an example of using a standard
WIndows DLL to hold subclassing, or in my case, Message Hook code.

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.

Yes i think it's very good Solution.
I use with good success your Win Dll, with no problem at all.
I never use C++, but i have Visual Studio, sò i start studing
some sample code.
It's a good way to learn a new language.

Thanks again Stephen info.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top