WinFBE visual designer question

Started by Patrick Beyltjens, April 24, 2019, 05:28:43 PM

Previous topic - Next topic

Patrick Beyltjens

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




Paul Squires

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.
Paul Squires
PlanetSquires Software

Paul Squires

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)

Paul Squires
PlanetSquires Software

Paul Squires

#3
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

Paul Squires
PlanetSquires Software

Paul Squires

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

Paul Squires
PlanetSquires Software

Patrick Beyltjens

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.




raymw

Busy day, Paul? Less than an hour or so to answer a couple of questions with example code.That's pretty impressive!

Paul Squires

Lol, the stars all aligned correctly tonight. :-)
Paul Squires
PlanetSquires Software