FireFly Visual Designer for FreeBASIC (Updated March 8, 2016)

User projects written in or related to FreeBASIC.
Post Reply
Loe
Posts: 323
Joined: Apr 30, 2006 14:49

Post by Loe »

Hi Randdal,
you can use OCX in firefly using axsuite
here the step
- Add in FF_AppStart

Code: Select all

#Include once "axsuite.bi" 'use axsuite library aka axsupport
axinit (true) 'set to true to initialize axsuite to use ActiveX control (OCX)
- place FF custom control in form
- set ClassName to AtlAxWin
- set Caption to OCX ProgID eg MSCAL.Calendar
- compile and run

good luck
rdhays82604
Posts: 14
Joined: May 19, 2011 11:43

Unicode Characters

Post by rdhays82604 »

I am trying to put the down pointing triangle as the caption of a button.

I've tried using \u25bc with various combinations of upper/lower case letters and with/without single and double quotes resulting in the what ever was typed.

I've tried copying from the Character map into both the editor and the form.inc file and get a '?' either way.

So...

How do I get a unicode character into the caption of a button control?
PaulSquires
Posts: 1012
Joined: Jul 14, 2005 23:41

Re: Unicode Characters

Post by PaulSquires »

rdhays82604 wrote: So...

How do I get a unicode character into the caption of a button control?
I doubt that you will be able to use any unicode character in the button because this version of FireFly uses the ansi version of CreateWindowEx to create controls rather than the unicode version.

Maybe you would be better off using an ImageButton and use a down arrow bitmap or icon.
MilesAhead
Posts: 26
Joined: Jul 18, 2010 19:06

Firefly3

Post by MilesAhead »

Just what I've been looking for. FB compiles small win32 apps with no run-time and this form designer really kills off the learning curve for Gui.

Very nice!

Image
MusicianKool
Posts: 57
Joined: May 13, 2010 22:30

Post by MusicianKool »

I don't get it... cant figure out how to do anything other then make buttons and text boxes and frames, don't know how to draw dynamic circles/lines or colors of them on a form, don't know how to make one control adjust a field in another control, and I don't know how to use control values or selections to effect what code should be used or use the value of a control in code.
Any help/tutorials would be awesome and very appreciated.
Cman
Posts: 30
Joined: May 10, 2011 22:01

Post by Cman »

Very nice, but for now I am going to stick with FBide.
Dinosaur
Posts: 1507
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Post by Dinosaur »

Hi all

I am currently evaluating different options to replace my GUI which is made using CGUI, and I think I am about the only one on this forum using that.

Having a look at making some sample apps using FireFly, and can't get past the need to pass pointers to udt's.

I made a simple Form1 , and added a button. The code below is the totality of the project. Now I need to pass a pointer to the button, so that the button can retrieve a udt that it needs to work with. How do I do that.?

Code: Select all

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

End Function


'--------------------------------------------------------------------------------
Function FORM1_IMAGEBUTTON1_BN_CLICKED ( _
                                       ControlIndex     As Integer, _   ' index in Control Array
                                       hWndForm         As HWND, _      ' handle of Form
                                       hWndControl      As HWND, _      ' handle of Control
                                       idButtonControl  As Integer   _  ' identifier of button
                                       ) As Integer
    
End Function

Regards
PaulSquires
Posts: 1012
Joined: Jul 14, 2005 23:41

Post by PaulSquires »

So, if I understand you correctly, when you click on the button you want to retrieve a pointer to a UDT that is associated with that button, right?

The easiest way to do this would be to store the pointer in the button during WM_CREATE using the api function SETPROP. During the BN_CLICKED event you would retrieve the pointer from the button using GETPROP.

For example,

pUDT = pointer to the UDT

SetProp HWND_FORM1_IMAGEBUTTON1, "UDTHANDLE", pUDT

pUDT = GetProp( HWND_FORM1_IMAGEBUTTON1, "UDTHANDLE" )

Lastly, in WM_DESTROY you should clean up by deleting the property that you assigned to the control

RemoveProp HWND_FORM1_IMAGEBUTTON1, "UDTHANDLE"
Dinosaur
Posts: 1507
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Post by Dinosaur »

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.
Dinosaur
Posts: 1507
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Post by Dinosaur »

Hi all

Having spent some time now working with FF, I have found the reason for my problems noted above. (although not the cure)

To pass Pointers to a Form, the pointer has to be Dim Shared, otherwise the Form can't see it. Now if there is one thing I have learned (Thanks to Fxm & TJF) is to avoid Sharing pointers or udt's.

However, the intention of my testing of FF, is to give pointers to certain buttons or forms, thus preventing that button or Form modifying other instances of a udt.
Using FF, I have no idea how to do that. If I don't share, then I can't pass pointers. If I share the pointers into a Main Form, then when other forms are created, there appears to be no way of passing these pointers to them.
Setting properties (SetProp) for each Form or button allows me to assign pointers, but that would then have to be done in the Main Form when the others havent been created yet. Not to mention that each Form or Button must have the latest copy of the udt pointed to.
As this is my first foray into the Win API, I must obviously be unaware of some basic principles, so hopefully someone can enlighten me.
Regards

EDIT:
The only way I can get this to work is to Dim Shared my Pointers udt.
This means that it is visible in every Form. Then by using SetProp only passing
the udt's needed for each button.However this causes a problem when a child Form/Button
needs a udt that wasn't passed to the Parent.

However, what is more concerning is the amount of compile errors/warnings created
in a very simple app which has two forms with a couple of buttons.
I have created the project in FF, and only added the code shown within the functions
and not changed the calling structure, declares etc.
FF may be a stable product in PB, but I think it needs more work to make
it so in FB. In my CGUI code I use the highest warning level on the compiler
and don't get a single warning.I would hate to see the number of error/warnings
if I completely converted to FF.

Code: Select all

Function FORM1_WM_CREATE (.....) As Integer
    Dim As Integer nReturn
    nReturn = SetProp (HWND_Form1_ImageButton1 , "Dump UDT",MC->DumpStPtr)
    If nReturn = 0 Then
        Print "Form1 Properties, Dump not Loaded"
        Function = False
        Exit Function
    EndIf
    Function = True
End Function
Function FORM1_IMAGEBUTTON1_BN_CLICKED (.....)As Integer
    Dim DumpStPtr As DumpSt Ptr
    DumpStPtr = GetProp (HWND_Form1_ImageButton1 , "Dump UDT")
    Print DumpStPtr->StepNbr    'Show test value
    Form2_Show(HWND_Form2,True) 'Open Form2
    Function = True
End Function
Function FORM1_IMAGEBUTTON2_BN_CLICKED (.....) As Integer
    FF_CloseForm hWndForm,True
    Function = True
End Function
'----------------------------------------------------------
Function FORM2_WM_CREATE (.....) As Integer
    Dim As Integer nReturn
    nReturn = SetProp (HWND_FORM2_COMMAND1,"Led UDT",MC->LedPtr)
    If nReturn = 0 Then
        Print "Button2 Properties, Led not Loaded";HWND_FORM2_COMMAND1
        Function = False
        Exit Function
    EndIf
    Print MC->StatPtr->Path(1)
    Function = True
End Function
Function FORM2_COMMAND1_BN_CLICKED (.....) As Integer
    Dim LedPtr As Leds Ptr
    LedPtr = GetProp (HWND_Form2_COMMAND1,"Led UDT")
    Print LedPtr->StartTime     'Show test value
    FF_CloseForm hWndForm,True
    Function = True
End Function
'-----------------------------------------------------------
warning 1(1): Passing scalar as pointer, at parameter 1 of ISWINDOW()
warning 1(1): Passing scalar as pointer, at parameter 1 of ENABLEWINDOW()
warning 1(1): Passing scalar as pointer, at parameter 1 of SETACTIVEWINDOW()
warning 4(1): Suspicious pointer assignment
warning 1(1): Passing scalar as pointer, at parameter 3 of FORM2_COMMAND1_BN_CLICKED()
warning 4(1): Suspicious pointer assignment
warning 5(0): Implicit conversion
warning 4(1): Suspicious pointer assignment
warning 5(0): Implicit conversion
warning 1(1): Passing scalar as pointer, at parameter 3 of FORM1_IMAGEBUTTON1_BN_CLICKED()
warning 1(1): Passing scalar as pointer, at parameter 3 of FORM1_IMAGEBUTTON2_BN_CLICKED()
PaulSquires
Posts: 1012
Joined: Jul 14, 2005 23:41

Post by PaulSquires »

Hi Dinosaur,

I'll try to answer as best that I can because I don't totally understand the structure of your program and how all your UDT's and pointers interact with each other.

Maybe it is better that I try to describe how FF handles Forms/Controls, etc. When a Form is created all of the controls on that Form are created by the time the WM_CREATE message fires. Therefore, the Window Handles for each control are known at that point. Now, as you have found out, other Forms/Controls in your project are not created when your project runs (only the main startup form is known at startup). In your code, you try to show Form2 and then do the SETPROP. What you don't realize is that you were showing Form2 as modal. Therefore your SETPROP that followed the Form2_Show is not executed until Form2 is closed.

DIM SHARED for your udt's is certainly the easiest answer to ensuring that your udt's are visible throughout your project. I am thinking that maybe another thing that you could do is in your WM_CREATE for your main startup form is to load all other Forms as non-modal (with the WS_VISIBLE in WindowStyles) initially unchecked. Doing this makes all Forms/Controls known and valid at application startup. Then in each WM_CREATE for each non-modal Form you could set your pointers to each control.

Also, you can pass a 32 bit value to each Form when you use the _Show syntax. For example:

Code: Select all

'--------------------------------------------------------------------------------
Function FORM1_COMMAND1_BN_CLICKED ( _
                                   ControlIndex     As Integer, _   ' index in Control Array
                                   hWndForm         As HWND, _      ' handle of Form
                                   hWndControl      As HWND, _      ' handle of Control
                                   idButtonControl  As Integer   _  ' identifier of button
                                   ) As Integer

   Dim p As Long
   p = 123456
   
   Form2_Show hWndForm, True, p
   
End Function
Then, in Form2 WM_CREATE you can retrieve the incoming integer as follows:

Code: Select all

'--------------------------------------------------------------------------------
Function FORM2_WM_CREATE ( _
                         hWndForm As HWND, _          ' handle of Form
                         ByVal UserData As Integer _  ' optional user defined value
                         ) As Integer

   Print UserData
   
End Function
I can appreciate how difficult it must be trying to convert other program design approaches into the way that FF handles things. With regard to the compile warnings, well, that's simply my lack of understanding of the nuances of the way FB passes certain variables to certain winapi functions. I guess the compile does some behind the scenes conversions that present themselves as warnings. I do remember making changes to code generation some time ago to help prevent some of these warnings. You could try downloading the latest FF version to see if it made any difference at all.
Dinosaur
Posts: 1507
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Post by Dinosaur »

Hi all

Paul , thank you for your detailed reply.
I'll try to answer as best that I can because I don't totally understand the structure of your program and how all your UDT's and pointers interact with each other.
It is really simple. I have one udt that holds pointers to about twenty other udt's.
Some of the udt's have multiple copies depending on the number of "users".
At programming time, I decide which udt's are allowed to be modified
and only send those pointers to that Function / Routine. The "user" works with & modifies the
elements of the udt's and then releases control for the next "user". This rotation of users
happens all day long. Some screens get updated by each of the "users" during production.
I am thinking that maybe another thing that you could do is in your WM_CREATE for your main startup
form is to load all other Forms as non-modal (with the WS_VISIBLE in WindowStyles) initially unchecked.
If I then call that Form with Form_Show, does that automatically become visible ?
Also, you can pass a 32 bit value to each Form when you use the _Show syntax.
Now this is the biggest surprise. After looking at the syntax in your Help file examples
I can only see two parameters in the call ."hwndHandle = FRMPOPUP_Show (%HWND_DESKTOP, %FALSE)" You have simply added a third with P "Form2_Show hWndForm, True, p". Where and how do I know which functions allow this additional parameter,
as that is the reason why I couldn't work out how to use the userdata.
I recently joined the PB Forum in an attempt to see examples or perhaps a manual, but to no avail.
Although I am very impressed with the PB documentation.
My FF version is v.3.10, and looking at the site http://www.freebasiccompiler.com the zip file
has the same date .Exe 2011-01-02. Is that the latest version ?
Do you have any plans for correcting these errors, as I feel very uncomfertable about
putting an application into the field that has errors like "Passing Scalar as Pointer"
without being able to fix them.

Regards
Dinosaur
Posts: 1507
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Post by Dinosaur »

Hi all

More playing around and have now made a small project for dowloading by other beginners of FF, whom are equally concerned about being able to pass selected pointers to diffrent Forms or Buttons.
http://www.compu-weigh.com.au/DownLoads/Project1.zip

Regards
EDIT: I can create a Tab control, but don't seem to be able to add items to each Tab like the picture below.Anyone have any ideas.Image
Drago
Posts: 116
Joined: Aug 10, 2005 13:15

Post by Drago »

Dinosaur wrote: I can create a Tab control, but don't seem to be able to add items to each Tab like the picture below.Anyone have any ideas.Image
TabControl is really easy...

Here is the way I Do it :

1. Add TabControl to the Base Form
2. Add as many forms to your Project as Tabs are needed
3. Set on every new Form the Properties
....TabControlChild and TabControlChildAutoSize to True
4. back to base Form ab the tabControl Properties
....there is a Properie : (Custom) ... select
....add Tabs to the control....set StartTab and Select the ChildPageDialog to assign to the tab..
Ready...

All Tab work then is only done in the assigned Form...

I put a 10 min Test together from the pic below.... 5kG.jvp as a Test.

http://www.file-upload.net/download-3629026/5kg.7z.html

Greetings
Drago
Dinosaur
Posts: 1507
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Post by Dinosaur »

Hi all

Drago, thank you for that. It would have taken me days to figure out how to do that. I am currently looking at all the features in my old package, and seeing if I can replicate them in FF.
Will perservere untill everyone has been tested, then attempt a complete re-write.
Once again, thank you for the example.
Regards
Post Reply