Hi all
Paul , thank you for the reply.
I know you are not here to teach the Win APi, so I will limit my questions to you on the structure of FF.
I am assuming that you intended the user of FF to only operate on the Forms visible in the Visual Designer, and we should not have to go browsing other files to add code.
You did understand me correctly about the udt, but I am afraid I didnt understand your reply.
The easiest way to do this would be to store the pointer in the button during WM_CREATE
When the project was created it made two Functions, Form1_WM_Create and FORM1_IMAGEBUTTON1_BN_CLICKED. There is no Form1_ImageButton1_Create.
Expanding the code as per
Code: Select all
Function FORM1_WM_CREATE (.....) As Integer
Var MC = New Machine
SetProp (HWND_Form1_ImageButton1 , "MC UDT",MC)
End Function
'--------------------------------------------------------------------------------
Function FORM1_IMAGEBUTTON1_BN_CLICKED (......) As Integer
Dim MC As Machine Ptr
MC = GetProp (HWND_Form1_ImageButton1 , "MC UDT")
MC->StatPtr->Path(1) = "D:/HMI/Recipes/Hd1/"
End Function
'--------------------------------------------------------------------------------
compiles without error, but is that what you intended.?
Regards
Edit: With reference to the WM_Destroy, do I need to do that each time I close the window created by the button click, or only when terminating the program.If I Destroy the property at the close of end / close of that function, how or where do I SetProp for the next time this button is pressed. What tidying up is done by FF when I close the program.
EDIT2: There are a few errors that I don't have any control over.
Code: Select all
Function FORM1_IMAGEBUTTON1_BN_CLICKED (ControlIndex As Integer,_
hWndForm As HWND,_
hWndControl As HWND,_
idButtonControl As Integer)_
As Integer
Passing scalar as pointer, at parameter 3 of FORM1_IMAGEBUTTON1_BN_CLICKED()
Code: Select all
FLY_hPicture = LoadImage( App.hInstance, "IMAGE_COMPLOGO", IMAGE_BITMAP, 0, 0, 32768 )
Implicit conversion
Code: Select all
ff = FLY_SetControlData( hWndControl, TRUE, FALSE, _
"", 0, FALSE, _
FALSE, FALSE, 0, _
0, -1, Cast(Long,@FORM1_CODEPROCEDURE), "" )
Suspicious pointer assignment
Besides that, I have problem understanding why one of my variables won't print. In the code below, I pass a udt called MC which has pointers to quite a few other udt's. By loading the MC udt in Form1_WM_Create and doing a SetProp I can then print the udt element when the Image button is pressed.However when I try the same approach in Form2, it wont print anything (not even a zero). If I change the print statement in Form2 to "Print @LedPtr->StartTime" then it prints the value of the pointer (not 12345)
So, I thought perhaps a Button in Form2 with the correct GetProp etc would do, but still no luck.
Code: Select all
Function FORM1_WM_CREATE (hWndForm As HWND,ByVal UserData As Integer) As Integer
Var MC = New Machine
MC->StatPtr->Path(1) = "D:/HMI/Recipes/Hd1/"
SetProp (HWND_Form1_ImageButton1 , "MC UDT",MC)
End Function
'--------------------------------------------------------------------------------
Function FORM1_IMAGEBUTTON1_BN_CLICKED (ControlIndex As Integer,_
hWndForm As HWND,_
hWndControl As HWND,_
idButtonControl As Integer)_
As Integer
'----Get udt Details------
Dim MC As Machine Ptr
MC = GetProp (HWND_Form1_ImageButton1 , "MC UDT")
Print MC->StatPtr->Path(1) 'show we can access it
'----Show Form2----
MC->LedPtr->StartTime = 12345 'set some value
Form2_Show(HWND_Form2,True)
SetProp (HWND_Form2,"Led UDT",MC->LedPtr)
End Function
'--------------------------------------------------------------------------------
Function FORM2_WM_CREATE ( _
hWndForm As HWND, _ ' handle of Form
ByVal UserData As Integer _ ' optional user defined value
) As Integer
Dim LedPtr As Leds Ptr
LedPtr = GetProp (HWND_Form2 , "Led UDT")
Print LedPtr->StartTime
Function = True
End Function
Is the order of statements involving GetProp and Show important ?
Regards
EDIT3; Using the return values I have concluded that calling SetProp in Form1 to set the pointer for Form2 is failing, as is obviously the GetProp in Form2. If Form1 or Main is the initialising Form for all my udt's then how do I get these pointers through to Form1 to 10 ? If I can add numerous properties to a Form, where do I execute these SetProp's for all the objects.? The MC udt has about 20 udt Ptr's in it, and a button I create in say Form5, is only allowed to get access to one or two of these. Creating the buttons, and then giving them additional properties is the logical problem.