I put together a test project to demonstrate the problem. I looked at the codegen files to see if it was obvious, but I didn't see anything. I almost debugged it in the PBIDE, but thought you might be able to track it down faster.
In the test project, you will notice that I can call the Test Method in the Form_WM_Size routine, but not in the Form_Custom.
David
Hehehe. Forgot to include the file.
Hello David,
you cannot put code just like that into the Form_Custom function. You have to select the proper wMsg. This works:
Select Case wMsg
Case %WM_NOTIFY
Case %WM_COMMAND
Case %WM_SIZE
zTrace "zTrace Form1_Custom"
Form1.Test "Test Form1_Custom"
Case Else
End Select
Thanks for the reply Rolf.
Actually, you can do it. I just have the test project too stripped to show it. Consider the following changes to the test project:Function FORM1_CUSTOM ( _
hWndForm As Dword, _ ' handle of Form
wMsg As Long, _ ' type of message
wParam As Dword, _ ' first message parameter
lParam As Long _ ' second message parameter
) As Long
zTrace "zTrace Form1_Custom"
TestIt "TestIt Form1_Custom" 'Both these work just fine. Not if the call is changed to a Method though.
End Function
'I put the following function on the module with the Method (I could also leave it with the Form1 code, as it makes no difference).
Function TestIt (info As String) As Long
ztrace "" & info
End Function
My actual Form1_CUSTOM routine is as follows:Function Form_CUSTOM_EnforceMinSize ( _
hWndForm As Dword, _ ' handle of Form
wMsg As Long, _ ' type of message
wParam As Dword, _ ' first message parameter
lParam As Long _ ' second message parameter
)
Local MinMaxPtr As MINMAXINFO Ptr
Select Case wMsg
Case %WM_GETMINMAXINFO
If Sizing.EnforceMinimum Then 'Enforce Minimum dialog Size *Sizing.EnforceMinimum returns True or False
MinMaxPtr=LParam
@MinMaxPtr.ptMinTrackSize.x = Ctrls(0,%DlgOWidth)
@MinMaxPtr.ptMinTrackSize.y = Ctrls(0,%DlgOHeight)
End If
End Select
End Function
Best regards,
David
Just to confirm it's not inherent in PB, I modified a pure PB program that does the same thing I am trying to do in FF. I added a test Class with a Method called in the same manner and location as my FF project. It works as it should. I could post that code if anyone would like to see it.
David
David,
Seeing as I'm totally ignorant about this topic, I'd really appreciate seeing real code in order to study and learn.
Thanks,
-JohnM.
John,
Ok, I grabbed a fine Drag and Drop Listview demo by Pierre Bellisle specifically because it responds to the WM_GETMINMAXINFO message. I modified it to use a Method in a Class called from the dialog callback function. The Class is defined at the bottom.
David
A little more info:
Rolf,
Your code example works as you stated. And that makes my subject inaccurate. You can call a method in Form_Custom - under some circumstances.
But, if you change it to respond to the GETMINMAXINFO message:Select Case wMsg
Case %WM_NOTIFY
Case %WM_COMMAND
Case %WM_GETMINMAXINFO
zTrace "zTrace Form1_Custom"
Form1.Test "Test Form1_Custom"
Case Else
End Select
End Function
It crashes again. The plot thickens... But more info is good.
David
Hi David,
I am finally looking at your test program (I've been a bit slow off the mark with this question).
I compiled and ran your DragListBox example and I never experienced any crash. I did not modify any code.
I am testing the code on a WinXP computer. I could test on my Win7 laptop later if needed.
One thing that strikes me is the return value (or lack thereof) from the WM_GETMINMAXINFO message. The api docs say that if you handle that message yourself then you should return zero from the message. I haven't used DDT in years but maybe you need to return %TRUE to indicate that the callback message handler actually handled the message. In FireFly you would return %TRUE from the message handlers in order to prevent Windows from further processing a message.
Hello Paul,
QuoteI compiled and ran your DragListBox example and I never experienced any crash.
It shouldn't crash in XP or Win7 (and it doesn't for me in either OS). That was a modified demo just to help prove to myself that the problem wasn't in PB itself. I modified it to use a Method call in the same manner and location as I was in FF. I provided that because John wanted to see it. ;)
Paul,
I can be really dense sometimes. :-[ I was assigning the object reference to the object variable in the Form_Create. I didn't realize that a WM_GETMINMAXINFO message might arrive first. One does!
I moved the assignment to the FF_WinMain function and all is well. :)
David
:D Happy to hear that you have it all fixed.