FF has a FF_Control_kill function to remove controls. But how do I create new controls? PowerBasic has the Control Add statements to add controls to a dialog. How can my program add controls to a FireFly form?
Thanks,
Robert
You have to use the CreateWindowEx API function.
:)
QuoteYou have to use the CreateWindowEx API function.
Or you could actually use the CWindow object FF creates for each Form (pWindow). I have included a demo project to show how I have done it (FF v3.70).
Remember this is
undocumented and unsupported, so use at your own risk. That being said, I haven't seen any problems so far.
I've done this before in a program I built for my personal use, but I couldn't remember which one it was an couldn't find it in a quick search. I threw this demo together yesterday afternoon. It's very small and should be easy to understand.
You will need to do your own resizing, if you need it, as I didn't look into getting FF to manage it (not sure if its possible either). Resizing should be pretty straight forward if you have done it before.
As you will see in the demo, you must use the Form's custom message handler to interact with the new controls, because FF creates the message break-out templates we are used to at design time and then adds code to call them when creating the codgen files.
There are some legitimate situations where run time controls make sense. Maybe Paul could add this feature in a way that is programmer and FF friendly to a future FF version. Of course, that is assuming there will be one.
David
Ah, David, right you are! Actually, FF uses Jose's CWindow class to create controls as well. Thanks for the demo project. Awesome, thanks. :)
QuoteActually, FF uses Jose's CWindow class to create controls as well
Yea, I had first thought I needed to use the actual instance FF created to do this, but I didn't.
Local FLY_parent As FLY_DATA Ptr
FLY_parent = GetProp( hWndForm, "FLY_PTR" )
pWindow = CWindow_GetObjectFromCreateStruct(@FLY_parent.lParamCreateStruct)
Could be replace by:
pWindow = Class "CWindow"
in the Form1_WM_CREATE function.
You could remove everything but the call to AddControl method in the CreateTextbox function like this:
Function CreateTextBox (pWindow As IWindow, hParent As Dword, CtrlID As Long, X As Long, Y As Long, nWidth As Long, nHeight As Long) As Dword
Local hWndControl As Dword
hWndControl = pWindow.AddControl( "Edit", hParent, CtrlID, "", _
X, Y, nWidth, nHeight, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %ES_LEFT _
Or %ES_AUTOHSCROLL, _
%WS_EX_CLIENTEDGE Or %WS_EX_LEFT Or %WS_EX_LTRREADING _
Or %WS_EX_RIGHTSCROLLBAR )
Function = hWndControl
End Function
But then you loose many of the extra settings put into that control by the FF form designer. Font, Colors, etc.
Thank you for your help. I appreciate it.
Robert
I downloaded the sample and ran it and got an undefined error in line 1210 of
FRAMEWORK_CLSFRAMEWORK codegen file.
I ran into this same problem recently and after some digging I found the solution to
be very simple.
As explained by Paul in another thread, all I needed to do was use a text editor to change
the UseObjectFramework value from 1 to 0.
Back then, before I found the easy solution, I was able to compile the codegen files after
fixing the spelling of the word Right in the Property assignment (line 1210) below:
'// RIGHTMARGIN
Property Get RightMargin As Long
Property = Edit_GetRigthMargin( MyBase.hWnd )
End Property
Also in my digging a few weeks ago I found this apparent spelling error
in Jose's "hidpi.inc"
' // Sizxe = 4 bytes
TYPE HIDP_KEYBOARD_MODIFIER_STATE_UNION_STRUCT BYTE
LeftControl AS BIT * 1 IN DWORD
LeftShift AS BIT * 1
LeftAlt AS BIT * 1
LeftGUI AS BIT * 1
RightControl AS BIT * 1
RightShift AS BIT * 1
RightAlt AS BIT * 1
RigthGUI AS BIT * 1 '<<< spelling
CapsLock AS BIT * 1
ScollLock AS BIT * 1
NumLock AS BIT * 1
Reserved AS BIT * 21
END TYPE
Thanks Pat, :-[
I will try to do a better job of making sure UseObjectFramework is set to 0 when I post a sample program.
Sorry about that.
BTW, I don't see how fixing the spelling errors in the include files could fix this problem.
Also, if Jose reads this post he will fix it in the next release. Otherwise you might bring it it his attention.
I was referring to the similar problem I had several weeks ago. After I fixed the spelling error in the codegen file, I was able to compile manually.
That is something I had never done before. Loading the codegen _MAIN file into PBWin and compiling.
It seems to me that some people are using the special object version of FF and some are not.
I remember trying it out and there was a project option to use objects or not. My version of FF 3.70 does not have that option.
So, I'm guessing, if I run code made on the object version of FF, even if the author didn't use objects, but they have "Use Objects" checked - then
I will have this (easily solved) problem.
My choice in this event is either fix the spelling error in the codegen file and compile manually or set UseObjectsFramework to 0 and compile from FF.
That makes sense to me now Pat. Thanks