PlanetSquires Forums

Support Forums => PlanetSquires Software => Topic started by: Patrick Beyltjens on April 24, 2019, 05:28:43 PM

Title: WinFBE visual designer question
Post by: Patrick Beyltjens on April 24, 2019, 05:28:43 PM
Hi,

Iam new in Free Basic.

I use WinFBE and visual designer to learn the first steps.
It works very smoothly.

I have 2 questions for the moment :

1) How can i use a timer in the visual designer code. I like too update the  time in a text controll every second or so.

2) How can i use a tooltip on a button.

Can someone give me an example

Thanks in advance



Title: Re: WinFBE visual designer question
Post by: Paul Squires on April 24, 2019, 05:52:00 PM
No problem... I am working on an example project for you. There is no built in Timer control but I will use Win32 api calls to create one. I will post the results here later.
Title: Re: WinFBE visual designer question
Post by: Paul Squires on April 24, 2019, 06:14:55 PM
This is what the Timer code will look like.
Form is named frmMain
Start button is named cmdStart
Stop button is named cmdStop



const IDT_TIMER = WM_USER + 100

 
''
'' 
sub TimerProc( byval hwnd    as HWND, _
               byval uMsg    as UINT, _
               byval TimerID as UINT ptr, _
               byval dwTime  as DWORD _
               )
               
   frmMain.txtResults.Text = wstr( val(frmMain.txtResults.text) + 1 )
     
end sub


''
''
Function frmMain_cmdStart_Click( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT

   ' Reset the textbox counter
   frmMain.txtResults.Text = "0"

   ' Create a timer that fires every second (1000 ms).
   SetTimer( frmMain.hWindow, _              ' handle to main window
             IDT_TIMER, _                    ' timer identifier
             1000, _                         ' 1-second interval
             cast( TIMERPROC, @TimerProc) )  ' timer callback   
             
   Function = 0
End Function


''
''
Function frmMain_cmdStop_Click( ByRef sender As wfxButton, ByRef e As EventArgs ) As LRESULT
   
   ' Kill the timer that was previously created.
   KillTimer( frmMain.hWindow, IDT_TIMER )
   
   Function = 0
End Function


''
''  Remove the following Application.Run code if it used elsewhere in your application.
Application.Run(frmMain)

Title: Re: WinFBE visual designer question
Post by: Paul Squires on April 24, 2019, 06:29:48 PM
Oh, yes, you also asked about Tooltips. Those are easier. Just look at Jose's AfxCtrl.inc file in the \Inc\Afx folder of your WinFBE Suite compiler install. There is a whole section of functions in that file that handle Tooltips. Here is code for adding a simple tooltip to the Start button in my previous example. I did it in the frmMain Load event.


''
''
Function frmMain_Load( ByRef sender As wfxForm, ByRef e As EventArgs ) As LRESULT

   ' Create tooptip
   dim as HWND hToolTip = AfxAddTooltip( frmMain.cmdStart.hWindow, "This is the Start button.", false, false )

   Function = 0
End Function

Title: Re: WinFBE visual designer question
Post by: Paul Squires on April 24, 2019, 06:31:39 PM
Here is the AfxAddTooltip definition:
' ========================================================================================
' Creates a tooltip for a control.
' Parameters:
' - hwnd      = Handle of the window or control
' - wszText   = Tooltip text
' - bBalloon  = Ballon tip (TRUE or FALSE)
' - bCentered = Centered (TRUE or FALSE)
' Return Value:
'   The handle of the tooltip control
' ========================================================================================
PRIVATE FUNCTION AfxAddTooltip (BYVAL hwnd AS HWND, BYREF wszText AS CONST WSTRING = "", BYVAL bBalloon AS BOOLEAN = FALSE, BYVAL bCentered AS BOOLEAN = FALSE) AS HWND

Title: Re: WinFBE visual designer question
Post by: Patrick Beyltjens on April 24, 2019, 06:53:21 PM
Thanks a lot for the examples Paul.

I just used the modified timer example. It works perfect now.

My problem was in the first parameter from the set_timer function.



Title: Re: WinFBE visual designer question
Post by: raymw on April 24, 2019, 09:28:06 PM
Busy day, Paul? Less than an hour or so to answer a couple of questions with example code.That's pretty impressive!
Title: Re: WinFBE visual designer question
Post by: Paul Squires on April 24, 2019, 09:49:12 PM
Lol, the stars all aligned correctly tonight. :-)