Hi - I've written my first program using FireFly 3.70 However it is experiencing a usability issue in that it does not seem as responsive as other programs I have written in PowerBasic as it looses mouse clicks. So I wrote something very very simple to compare FireFly with PBForms generated code. The PBForms works as expected but not the FireFly.
For the experiment it is a Form with a Single command button and a single text box with an initial text of "0".
Clicking the button reads the text box value increments it by 1 and writes it back to the text box.
For simplicity the sleep 500 is just simulating it doing some work e.g. receiving an image from the web
For FireFly in the handler of the button click
FF_TEXTBOX_SETTEXT HWND_FORM1_TEXT1, STR$(VAL(FF_TEXTBOX_GETTEXT( HWND_FORM1_TEXT1 ))+ 1)
SLEEP 500
For the PBForms generated version
local txt as string
CONTROL GET TEXT CB.HNDL, %IDC_TEXTBOX1 TO txt
txt = str$(val(txt)+1)
CONTROL SET TEXT CB.HNDL, %IDC_TEXTBOX1, txt
sleep 500
If you do a couple of clicks similar to a double click on the PBForms version the text box value increments by 2 (after a short delay) as expected
however the FireFly version only increments by 1 it misses the second mouse click
Similarly if you do 5 clicks on the PBForms version it increments by 5 but not the FireFly
I practise in my application when the button is retreiving data from a file it is very annoying as it misses mouse clicks.
Am I doing something wrong or is this an issue with the Firefly message handler - Is there a simple work around?
Thanks
Jon
Misses mouse clicks? I can't fathom how that is even possible. All messages are dispatched from the message queue to the windows procedure for the form/control. FireFly doesn't eat any messages. Can you post the source for the DDT program and maybe attach the FireFly project to your post? Maybe because FireFly uses straight Win32 API and DDT uses the Windows Dialog engine? Not sure at this point.
I assume that you are responding to the BN_CLICKED notification in both cases, right?
Interesting question.
Thanks for the reply
Yes responding to the same events.
About as simple as I could make it
PBForms generated version
#PBFORMS CREATED V2.01
'--------------------------------------------------------------------------------------------------
' The first line in this file is a PB/Forms metastatement.
' It should ALWAYS be the first line of the file. Other
' PB/Forms metastatements are placed at the beginning and
' end of "Named Blocks" of code that should be edited
' with PBForms only. Do not manually edit or delete these
' metastatements or PB/Forms will not be able to reread
' the file correctly. See the PB/Forms documentation for
' more information.
' Named blocks begin like this: #PBFORMS BEGIN ...
' Named blocks end like this: #PBFORMS END ...
' Other PB/Forms metastatements such as:
' #PBFORMS DECLARATIONS
' are used by PB/Forms to insert additional code.
' Feel free to make changes anywhere else in the file.
'--------------------------------------------------------------------------------------------------
#COMPILE EXE
#DIM ALL
'--------------------------------------------------------------------------------------------------
' ** Includes **
'--------------------------------------------------------------------------------------------------
#PBFORMS BEGIN INCLUDES
#RESOURCE "TestMouseClick.pbr"
#INCLUDE ONCE "WIN32API.INC"
#INCLUDE ONCE "COMMCTRL.INC"
#INCLUDE ONCE "PBForms.INC"
#PBFORMS END INCLUDES
'--------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------
' ** Constants **
'--------------------------------------------------------------------------------------------------
#PBFORMS BEGIN CONSTANTS
%IDD_DIALOG1 = 101
%IDC_BUTTON1 = 1001
%IDC_TEXTBOX1 = 1002
#PBFORMS END CONSTANTS
'--------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------
' ** Declarations **
'--------------------------------------------------------------------------------------------------
DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
#PBFORMS DECLARATIONS
'--------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------
' ** Main Application Entry Point **
'--------------------------------------------------------------------------------------------------
FUNCTION PBMAIN()
PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR %ICC_INTERNET_CLASSES)
ShowDIALOG1 %HWND_DESKTOP
END FUNCTION
'--------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------
' ** CallBacks **
'--------------------------------------------------------------------------------------------------
CALLBACK FUNCTION ShowDIALOG1Proc()
SELECT CASE AS LONG CB.MSG
CASE %WM_INITDIALOG
' Initialization handler
CASE %WM_NCACTIVATE
STATIC hWndSaveFocus AS DWORD
IF ISFALSE CB.WPARAM THEN
' Save control focus
hWndSaveFocus = GetFocus()
ELSEIF hWndSaveFocus THEN
' Restore control focus
SetFocus(hWndSaveFocus)
hWndSaveFocus = 0
END IF
CASE %WM_COMMAND
' Process control notifications
SELECT CASE AS LONG CB.CTL
CASE %IDC_BUTTON1
IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
local txt as string
CONTROL GET TEXT CB.HNDL, %IDC_TEXTBOX1 TO txt
txt = str$(val(txt)+1)
control set text CB.HNDL, %IDC_TEXTBOX1, txt
sleep 500
END IF
CASE %IDC_TEXTBOX1
END SELECT
END SELECT
END FUNCTION
'--------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------
' ** Dialogs **
'--------------------------------------------------------------------------------------------------
FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
LOCAL lRslt AS LONG
#PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
LOCAL hDlg AS DWORD
LOCAL hFont1 AS DWORD
DIALOG NEW hParent, "Dialog1", 70, 70, 201, 121, %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR _
%WS_SYSMENU OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR _
%DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING _
OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
CONTROL ADD BUTTON, hDlg, %IDC_BUTTON1, "Button1", 75, 30, 50, 20
CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX1, "0", 65, 65, 70, 15
FONT NEW "MS Sans Serif", 14, 0, %ANSI_CHARSET TO hFont1
CONTROL SET FONT hDlg, %IDC_TEXTBOX1, hFont1
#PBFORMS END DIALOG
DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
#PBFORMS BEGIN CLEANUP %IDD_DIALOG1
FONT END hFont1
#PBFORMS END CLEANUP
FUNCTION = lRslt
END FUNCTION
'--------------------------------------------------------------------------------------------------
I've attached the FireFly version
Thanks - Hopefully it should be easy to see the difference
Jon
Thanks Jon - the difference is that FireFly uses the %BS_NOTIFY style and DDT does not (by default). This allows FireFly users to capture %BN_DBLCLK notifications. In your DDT example you will never get the double click notification. You will get two single click notifications (therefore incrementing your textbox by 2).
You would have to add this code to your Form to get similar behaviour that you are seeing in DDT:
'--------------------------------------------------------------------------------
Function FORM1_WM_COMMAND ( _
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
wNotifyCode As Long, _ ' notification code
wID As Long _ ' item, control, or accelerator identifer
) As Long
Select Case hWndControl
Case HWND_FORM1_COMMAND1
If wNotifyCode = %BN_DBLCLK Then
FF_TextBox_SetText HWND_FORM1_TEXT1, Str$(Val(FF_TextBox_GetText( HWND_FORM1_TEXT1 ))+ 1)
Sleep 500
End If
End Select
End Function
Thanks
Have built a variation of that into my app now and works perfect. I'm going to have to be careful with that though I can see that causing me some issues. I knew I never had that issue with the PBForms programs. Can't remember how VB6 handled it will have to test it unless anyone has got a better memory than me (Not hard!). But quite often have buttons to nudge sliders - presumably these would have the same problem, as you need every click to count.
Thanks again
Jon
Hi - Had a sleep on it now.
I've also now tried VB6, Phoenix 3.0 and PBForms, none of the others seem to operate in this manner. In the others a command button gets every click.
You can take out the Sleep 500 from the code I supplied in post 1 and it becomes more noticeable.
Shouldn't the button get every click - I can't think of why you would want a double click on a button being in mind it gets the first click straight away.
Thanks - I look forward to any comments.
Jon
I remember a long time ago in the early days of FireFly 1 that there was a discussion about trapping double clicks on buttons. I can't remember the exact details of it but I assume it must have along the lines of not wanting that second mouse click to hit the button. Users would double click a button to perform an action (when single clicking is what was intended by the programmer). I do know that this has been the default behaviour in FireFly for almost 10 years. :)
Unless the general populous of FireFly users want a change, I would rather stick with the current design in fear that it would break legacy code.
Thanks Paul,
I totally understand the fear of breaking legacy code - I'm probably wrong but can't think of a situation that it could break. Lets see what others can think of. But a change would probably improve many legacy and future applications as unless I'm wrong other peoples apps must be exhibiting the same symptoms. I thought I saw a Calculator sample written in Firefly somewhere but can't find it now -- is there one?. I would imagine that if you are using the mouse to enter the numbers on a calculator written in Firefly and you enter a double or triple digit then it is going to lose one of the clicks - (Unless of course you go to special lengths to process the other messages) I appreciate this is the first app that I've written in Firefly which I must say has some very good points, but it was something I noticed as a problem the first time I ran the App I had created, especially as PowerBasic programs are usually so responsive.
Any comments from others?
Jon