PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: WinFBE visual designer question  (Read 457 times)

Patrick Beyltjens

  • Little Newbie
  • *
  • Posts: 3
WinFBE visual designer question
« on: April 24, 2019, 04:58: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



Logged

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8865
  • Windows 10
    • PlanetSquires Software
Re: WinFBE visual designer question
« Reply #1 on: April 24, 2019, 05:22: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.
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8865
  • Windows 10
    • PlanetSquires Software
Re: WinFBE visual designer question
« Reply #2 on: April 24, 2019, 05:44: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

Code: [Select]

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)
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8865
  • Windows 10
    • PlanetSquires Software
Re: WinFBE visual designer question
« Reply #3 on: April 24, 2019, 05:59: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.

Code: [Select]
''
''
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
« Last Edit: April 24, 2019, 06:02:27 PM by Paul Squires »
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8865
  • Windows 10
    • PlanetSquires Software
Re: WinFBE visual designer question
« Reply #4 on: April 24, 2019, 06:01: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

Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Patrick Beyltjens

  • Little Newbie
  • *
  • Posts: 3
Re: WinFBE visual designer question
« Reply #5 on: April 24, 2019, 06:23: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.



Logged

raymw

  • Senior Member
  • ***
  • Posts: 318
Re: WinFBE visual designer question
« Reply #6 on: April 24, 2019, 08:58:06 PM »

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

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8865
  • Windows 10
    • PlanetSquires Software
Re: WinFBE visual designer question
« Reply #7 on: April 24, 2019, 09:19:12 PM »

Lol, the stars all aligned correctly tonight. :-)
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer