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

User projects written in or related to FreeBASIC.
Post Reply
Dinosaur
Posts: 1507
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Post by Dinosaur »

Hi all

Drago, can you tell me how you made the link between the TextForm and the UDForm. Did you code that manually or use FF.
I understand the code, but not sure how to automatically create the link.

Regards
Drago
Posts: 116
Joined: Aug 10, 2005 13:15

Post by Drago »

Code: Select all

        FF_UpDown_SetBuddy( HWND_Form3_UDForm3(x), HWND_Form3_txtForm3(x))
        
The _SetBuddy one ?

You can find all FireFly Build in Functions on the Link at the Bottom of FireFly : Functions Library -> FireFly_Functions

On double Click the snippet is inserted into your code, but the vars have to be inserted.

Code: Select all

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

Post by Dinosaur »

Hi all

Drago ,creating a single UpDown control and linking it to a single TextBox as per your code hilights one difference.
You have a "Function FORM3_UDFORM3_WM_VSCROLL " in which you set the Text. Going through the Form creation and adding all the controls does not create that Function. I have looked hi and lo, but can't see when and how to create that Function.(I am referring to the WM_VSCROLL) Sure, I can manually create it, but that is not the idea is it.
REgards
PaulSquires
Posts: 1012
Joined: Jul 14, 2005 23:41

Post by PaulSquires »

When you are in the code editor, look at the top for two drop down combo boxes. The one on the left lists all of the controls. The one on the right lists a selection of message handlers based on whatever control is selected in the left combo box.

Select the UpDown control in the left combo box, and then scroll through the available message handlers in the right combo box to select WM_VSCROLL.

This is specified in the Help file under "The User Interface", "Code Editor" and is very similar to the way that Visual Basic used to handle things.

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

Post by Dinosaur »

Hi all

Thanks for that Paul. Because I am a newcomer to Win gui, I find that the problem is not knowing where to look, but what to pick and why. Now that I have spent a couple of weeks with FF I have some observations, which are not intended as criticism, but encouragement to expand.
1. When I have two instances of FF open, some features can only be used by one of them.eg;FFWorkSpace/Properties/WindowStyles. When trying to learn from other projects or examples, that makes it difficult to compare settings.
2. The serach facility nearly always returns Zero results. So when looking for WM_SCROLL in the Help there is no result.
3. You mentioned somewhere in your Doc's that ideally the user doesnt need to edit or modily code,(or something like that), but have a look at what is required in cgui to create a Tabwindow.
Tabs.id = CreateTabWindow (X,Y,AdaptiveSizing, @userdata)
AddTab( Tabs.id, @Routine2Call, userdata, "Tab Label")
id = AddEditBox(Cgui_Right, Width, " Fast Speed =", Cgui_FINT, 0, @userdata))
HookSpinButtons(id, @userdata, DecAmount, IncAmount, MinVal, MaxVal)
4. The Editor allows for the contraction of Functions by clicking the - symbol. However, when saving the project this is lost. So next time you have to minimise them again.

Granted cgui is not a Visual Design system, but it allows the creation of every type of Window control without editing except for parameters.
I will persevere until I find an obstacle that prevents or reduces the performance compared to cgui.

Regards
EDIT: One Question.
I have a lot of hardware to look after that is time critical.Normally I have a single Do/Loop that holds calls to these routines, yet it allows attention to all other Windows and Buttons where needed.Where do I place that Loop ? Also because I run my program in Embedded Priority, there is little or no time returned to Windows. As a result my latest version scans all hardware in less then 1 micro sec. What complications do you see to implement this in FF ?
PaulSquires
Posts: 1012
Joined: Jul 14, 2005 23:41

Post by PaulSquires »

Dinosaur wrote:Thanks for that Paul.
You're very welcome. I'll try to help as much as I can :-)
Because I am a newcomer to Win gui, I find that the problem is not knowing where to look, but what to pick and why.
No truer words have ever been spoken. I hear this all the time and I sympathize with newcomers to the WinAPI. It can be very overwelming because there is just sooooooooo much information out there and it can be a needle in a haystack to find the right solution or even where to start.

On my commercial forum there are over 10,000 posts so it can be MUCH easier to find that starting point. Granted, the code is all PowerBASIC related but it is not much of a stretch to convert it to FB.
1. When I have two instances of FF open, some features can only be used by one of them.eg;FFWorkSpace/Properties/WindowStyles. When trying to learn from other projects or examples, that makes it difficult to compare settings.
I think I see what you mean. The 'problem' is that the popup Styles selection pop closes when it goes out of focus (happens when you switch to the other instance). This is by design. In FireFly 2 the dialog was modal but many users wanted just to click elsewhere to close the dialog rather than have to always specifically click on the "x" close button.
2. The serach facility nearly always returns Zero results. So when looking for WM_SCROLL in the Help there is no result.
I can't disagree. The search facility in the Help file is not great.
3. You mentioned somewhere in your Doc's that ideally the user doesnt need to edit or modily code,(or something like that), but have a look at what is required in cgui to create a Tabwindow.
Tabs.id = CreateTabWindow (X,Y,AdaptiveSizing, @userdata)
AddTab( Tabs.id, @Routine2Call, userdata, "Tab Label")
id = AddEditBox(Cgui_Right, Width, " Fast Speed =", Cgui_FINT, 0, @userdata))
HookSpinButtons(id, @userdata, DecAmount, IncAmount, MinVal, MaxVal)
A TabControl in WinAPI can be a very involved process. You can do the whole thing from within FireFly without ever writing code (TabControl Editor). Code is created using the WinAPI, I could have very easily created a gui system on top of the WinAPI and then used that gui system in the code generation... it wouldn't really add much to the output other than adding an additional layer of abstraction.
4. The Editor allows for the contraction of Functions by clicking the - symbol. However, when saving the project this is lost. So next time you have to minimise them again.
Right you are, and this is in my feature tracker to be implemented in the future. I wrote the entire code editor from scratch using only the WinAPI. Because it is totally all my code, I can really do anything with it to modify it (not like using CodeMax or Scintilla which would be harder for me to modify).
EDIT: One Question.
I have a lot of hardware to look after that is time critical.Normally I have a single Do/Loop that holds calls to these routines, yet it allows attention to all other Windows and Buttons where needed.Where do I place that Loop ? Also because I run my program in Embedded Priority, there is little or no time returned to Windows. As a result my latest version scans all hardware in less then 1 micro sec. What complications do you see to implement this in FF ?
You could put your scan in a WM_TIMER event that could trigger every so many milliseconds. If you need to be constantly scanning your hardware then you could even put it in the special FF_PumpHook. Code put in there is injected directly into the applications main message pump. Everytime a message is received by your application then the code would execute. Probably a bit overkill and resource consuming.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Post by MichaelW »

PaulSquires wrote: You could put your scan in a WM_TIMER event that could trigger every so many milliseconds. If you need to be constantly scanning your hardware then you could even put it in the special FF_PumpHook. Code put in there is injected directly into the applications main message pump. Everytime a message is received by your application then the code would execute. Probably a bit overkill and resource consuming.
But probably the only workable solution if the 10-15ms minimum period of the timer (or 1ms with the aid of timeBeginPeriod) is not fast enough.
Dinosaur
Posts: 1507
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Post by Dinosaur »

Hi all

Just trying to create a test, and keep getting Errors when I try to add a simple line like "Print Timer". The error is ,
Variable not declared, MsgBox in 'MsgBox "timer"'
Are certain FB functions not allowed ? I have not added any Includes in the FF_AppStart. Do I need to specifically add FB includes ?
Regards
PaulSquires
Posts: 1012
Joined: Jul 14, 2005 23:41

Post by PaulSquires »

There are two ways to create a Timer in FireFly. The easiest way is to simply add the Timer control from the ToolBox on to a Form. Then set the "Interval" property of the Timer to the number of milliseconds that you want the timer to fire at. Finally, double click on the Timer icon that was added to the Form and you will be placed in the code editor in a special WM_TIMER message handler.

Code: Select all

'--------------------------------------------------------------------------------
Function FORM1_TIMER1_WM_TIMER ( _
                               hWndForm      As HWND, _     ' handle of Form
                               wTimerID      As Integer  _  ' the timer identifier
                               ) As Integer

   Static nCount As Integer
   
   nCount = nCount + 1
   
   Print nCount
   
End Function
Run the project and the output display will update and print the count whenever the timer fires.

The second approach is to manually create/destroy the Timer using the api functions SetTimer/KillTimer:
http://msdn.microsoft.com/en-us/library ... S.85).aspx
I won't get into that stuff yet unless the first approach is not useful for you.
Dinosaur
Posts: 1507
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Post by Dinosaur »

Hi all

Paul , are you saying that the FB Timer (and other FB specific) functions are not available in FF ?

Regards
Drago
Posts: 116
Joined: Aug 10, 2005 13:15

Post by Drago »

Hoi,

to use the FireFly Timer Control I had to disable the message Box Sniplet:

Image


and sure FB Timer is usable too....

Code: Select all

Sub StartRennen
Dim As Integer thread    
    evTimer ("neu")
    If terminate = -1 Then
        terminate = 0
        thread = ThreadCreate(Cast(Any Ptr, @zeit))
    End If
End Sub

Sub Zeit()
    Do
        evTimer("Go")
        Sleep 250, 1
    Loop While terminate = 0
End Sub

Sub evTimer (MakeZero As String)
    Static As Long s,m,h,OldTime
    Static As String myTime,ss,mm,hh
    Static As Double t 
    
    If MakeZero = "neu" Then
        ms = 0: s = 0: m = 0: h = 0
        OldTime = timer - 1
        Exit Sub
    ElseIf Mid(makeZero,3,1) = ":" Then
        h = Val(Left(makeZero,2))
        m = Val(Mid(makeZero,4,2))
        s = Val(Right(makeZero,2))
        OldTime = timer - (h*3600+m*60+s)
        Exit Sub
    End If
    
    t = CDbl(timer - OldTime)
    
    h = Int(t / 3600 )
    m = Int((t-h*3600)/60)
    s = Int((t-h*3600-m*60))
     
    ss = Str(s):mm=Str(m):hh=Str(h)

    If Len(ss) = 1 Then ss = "0" & ss
    If Len(mm) = 1 Then mm = "0" & mm
    If Len(hh) = 1 Then hh = "0" & hh
    
    mytime = hh & ":" & mm & ":" & ss

    FF_TextBox_SetText(HWND_frmTimer_txtTime, myTime )
End Sub
Dinosaur
Posts: 1507
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Post by Dinosaur »

Hi all

Drago, thank you for your help.
However, I have decided not to perservere with FF.
I did a small example as per below, and the only time it updated was when I moved the mouse.

Code: Select all

Function FF_PUMPHOOK( uMsg As Msg ) As Integer
   If (timer * 1000) - StartTime >= 1 Then TimeShow(TimesPtr)
   Function = False    
End Function

Sub TimeShow (ByVal TimesPtr As Timing Ptr)
    StartTime = timer * 1000
    Print StartTime
End Sub
A small test program with a few windows and Tab window also produced 97 error lines with most of them warning about Passing Scalar's as Pointers, and warning about different pointer types. I think the concept is very good, but my need is for machines that run 24 hrs per day, in remote locations, and thus the risk is to great. I will wait and see. Once again many thanks to all contributors.
Regards
Drago
Posts: 116
Joined: Aug 10, 2005 13:15

solved: TrayControl

Post by Drago »

*****argglll.... got It*********
FrmMain_CUSTOM
------------------------------------

Dear Paul,

again I didn't get it.

I want to minimize my prog to the TrayBar..... so far no problem.

but where to set the code to react on a leftMouseButton Click to Restore my Form ?

Code: Select all

Dim Shared As NOTIFYICONDATA NID
#Define FF_Tray WM_USER + 5

Function FRMMAIN_WM_CREATE ( hWndForm As HWND, ByVal UserData As Integer ) As Integer            'Set at Form create and destroy : no problem

With NID
  .cbSize           = SizeOf (NOTIFYICONDATA)
  .hWnd             = HWND_frmMain
  .uID              = 0
  .hIcon            = LoadIcon (Null, IDI_QUESTION)
  .uFlags           = NIF_MESSAGE Or NIF_TIP Or NIF_ICON Or NIF_INFO
  .uCallbackMessage = FF_Tray
  .szTip            = "Prüfe auf Updates"
  .szInfoTitle      = "Checker"
  .szInfo           = "UpdateChecker"
End With

Shell_NotifyIcon (NIM_ADD, @NID)
End Function

Function FF_PUMPHOOK( uMsg As Msg ) As Integer
  Select Case As Const uMsg.Message
    Case WM_CREATE                          'This one never arrives
        Shell_NotifyIcon (NIM_ADD, @NID)
    Case WM_CLOSE                            'This one never arrives
        Shell_NotifyIcon (NIM_DELETE, @NID)        
    Case WM_SYSCOMMAND
        Select Case uMsg.wParam            'This one only work on Click at Taskbar to minimize
        Case SC_MINIMIZE 
            Shell_NotifyIcon (NIM_ADD, @NID)
            ShowWindow(uMsg.hWnd, SW_HIDE)
            Return True
        End Select
    Case FF_Tray                                     'The WM_Notify_Event never arrives 
      If uMsg.lParam = WM_LBUTTONDOWN Then
        ShowWindow(uMsg.hWnd, SW_RESTORE)    
        Shell_NotifyIcon(NIM_DELETE,@NID)
      End If       
  End Select
 
Function = False  ' return TRUE if you need to bypass the FireFly message pump

End Function
Im sure there is an obvious mistake...but I didn't get it.

Greetings
Drago
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Post by AGS »

@Paul
I've got a question.

Years ago you released something called the cheetah database system
http://cheetahdatabase.sourceforge.net/

On the site I found the following
The library is about 90% complete
Why 90% (and not 100%)? I also found this:
Multiuser support will be handled through a client/server implementation (work in progress)
And then I came across sqlitening (which implements multiuser through a client/server implementation on top of sqlite).

Am I right in assuming you abandoned cheetah in favor of sqlitening?
PaulSquires
Posts: 1012
Joined: Jul 14, 2005 23:41

Post by PaulSquires »

AGS wrote:Am I right in assuming you abandoned cheetah in favor of sqlitening?
Exactly correct.

:-)
Post Reply