When does what happen in the program generated by Firefly?

Started by Barry Marks, January 02, 2009, 01:32:03 AM

Previous topic - Next topic

Barry Marks

I'm really confused about the startup procedure for a Firefly program.   I think I respond to %WM_CREATE to initialize something about the form (is this correct?) but when do I initialize something about a control?

Do I respond to %WM_CREATE just by creating a function such as FORM1_WM_CREATE?  If so, are all messages handled this way or just some and which?

I'll appreciate any information or pointers to information about this.

Thanks,
Barry

Jean-Pierre LEROY

Hello Barry,

QuoteI'm really confused about the startup procedure for a Firefly program.   I think I respond to %WM_CREATE to initialize something about the form (is this correct?) but when do I initialize something about a control?
Yes you have to respond to the %WM_CREATE message to initialize something about the form but also to initialize the controls on a form.

QuoteDo I respond to %WM_CREATE just by creating a function such as FORM1_WM_CREATE?
Yes the easiest way to answer the %WM_CREATE message is to create a function like FORM1_WM_CREATE; switch to the Code Editor tab, select the name of your form in the left ComboBox (Form1), then the message in the right ComboBox (WM_CREATE) and then FireFly will create for you the function that you have to complete.

By example if you put a TextBox control on this form, you can initialize the text in the TextBox in this function by inserting the line FF_TextBox_SetText (HWND_FORM1_TEXT1, "Hello Word"); see below the whole code for this function.

'------------------------------------------------------------------------------------------------------------------------
Function FORM1_WM_CREATE ( _
                         hWndForm As Dword, _  ' handle of Form
                         ByVal UserData As Long _  'optional user defined Long value
                         ) As Long

' initialize the text in the TextBox control                       
FF_TextBox_SetText (HWND_FORM1_TEXT1, "Hello Word")

End Function


QuoteIf so, are all messages handled this way or just some and which?
Most of the messages could be handled this way.

Hope that's help.

Keep posting if you have any more questions
Jean-Pierre

Barry Marks

That does help.  Thanks. :)

So can I assume that when the %WM_CREATE message is sent the control has already been created?

Is there some sort of timeline in the docs that I've missed so I can know what happens when?

Thanks,
Barry

David Kenny

No real time line in the docs.  You can always check out the code produced by FireFly.  It does a lot for you so there can be quite a bit to wade through, but it can be very enlightening.  Just start with the file called "CODEGEN_" + ProjectName + "_MAIN.bas".  If you add a comment and search for it (I use baregrep because it has a nice GUI interface and is very fast) and it will tell you which file actually has the code you are looking for.

David

Barry Marks

Thanks.  I'll look at that code.

I've just been playing with initializing things in %WM_CREATE and that seems to be working well.

Barry

TechSupport

Hi Barry,

Yes, the controls are already created by the time that control is handed over to the WM_CREATE message handler. You can initialize your controls in WM_CREATE.

Barry Marks

Can I assume the same thing is true about %WM_DESTROY?  If I want to kill a timer or delete a font or some such is that the place to do it?

Thanks,
Barry

TechSupport

Yes, you should delete your user created objects in WM_DESTROY (or WM_NCDESTROY which is the very last message processed by a Window). I routinely delete my objects in WM_DESTROY - it is the normal place for WinAPI programmers to delete things.