Page 1 of 2

Textbox Problem

Posted: Tue May 30, 2017 10:38 pm
by franco
I have seen this post before but can not locate it.
When in a textbox and when using ONENTER, if I hit the enter button very very fast, program crashes and error message.
Window _Inputbox is not active. Program terminated. The inputbox is my next control in a different window.
I know this was caught with an error but not sure how. I have tried all kinds of things to correct it but I think it is in the keyboard buffer timer.
Any help appreciated ............ Franco ;)

Re: Textbox Problem

Posted: Wed May 31, 2017 4:11 am
by Rathinagiri
Can you provide a small working sample?

Re: Textbox Problem

Posted: Wed May 31, 2017 2:57 pm
by franco
I made up a sample but it works ok. I need to do more checking and I will send in error message.

Re: Textbox Problem

Posted: Wed May 31, 2017 4:52 pm
by franco
SUCCESS,
I found an earlier post from Roberto and srvet_claudio.
After the function causing the problem I use hmg_keyboardclearbuffer() which clears the second ENTER HIT.
Should I leave this post for others to see if they have this problem.
Franco ..... ;) .. :lol:

Re: Textbox Problem

Posted: Wed May 31, 2017 4:58 pm
by Rathinagiri
Yes. Let it be! :)

Re: Textbox Problem

Posted: Wed May 31, 2017 8:18 pm
by franco
Ok..They are hard to find sometimes .. ;)

Re: Textbox Problem

Posted: Thu Jun 01, 2017 5:18 am
by franco
I am still not happy with the way I resolved the problem.
Does anyone know if there is a way to slow the windows keyboard buffer, or have an error return from my error program that will resume the program. I thought I remember someone had a simular situation of a client pressing keys to fast, and they put in an error like ?to fast then return to program.
clearbuffer works but you must put it where ever someone might hit keys fast.
Thanks Franco ;)

Re: Textbox Problem

Posted: Fri Jun 02, 2017 5:22 am
by mol
you can catch errors with begin sequence/recover/end sequence.

Re: Textbox Problem

Posted: Sat Jun 03, 2017 5:17 pm
by franco
This is a example of my problem.
Mol do you know where in the sample I would put your suggestion.

Code: Select all

#include <hmg.ch>

Function Main
PUBLIC MYBOXV:= '', V_QTY := 0, RE := 'F'

        DEFINE WINDOW FORM_1 ;
		AT 0,0 ;
		HEIGHT 360 WIDTH 510 ;
		TITLE ' Enter Speed Test' ;
		MAIN
		
		DEFINE BUTTON BUTTON_1
		ROW 60
		COL 145
		WIDTH 120
		HEIGHT 80
		CAPTION 'Enter Item'
		ACTION { || {ADDTOINVOICE()}}
		END BUTTON
		
		END WINDOW
        FORM_1.Center
        FORM_1.Activate

Return

FUNCTION ADDTOINVOICE
	LOCAL M_ITEM
	MYBOX('Add to Invoice')
	M_ITEM := UPPER(MYBOXV)
	MYBOXV:= ""
	IF RE = 'T'
		RE := 'F'
		RETURN
	ENDIF
	**** This is where crash is if hit enter key twicw very fast in function mybox
	**** This little program does not crash it is not doing much
	V_QTY := VAL(INPUTBOX('Enter Quantity','Quantity', '1'))
	MSGBOX(M_ITEM+'     '+STR(V_QTY))
	
RETURN

FUNCTION MYBOX(Tit)

	            // Private variable myboxv must be set to use as return variable to change
	DEFINE WINDOW Mybox ;
		AT  getDeskTopHeight()/2-50 ,getdesktopWidth() /2-175 ;
		WIDTH 350 ;
		HEIGHT 150 ;
		TITLE TIT ;
		MODAL 
		
		DEFINE LABEL LAB1
         ROW 10
         COL 10
         WIDTH 280
         HEIGHT 20
		 VALUE 'Enter Text    (Escape/Blank to Exit)'
	END LABEL
	
	DEFINE TEXTBOX TEXT1
         ROW 30
         COL 10
         WIDTH 280
         HEIGHT 30
		 ON ENTER { ||  {MYBOXV := MYBOX.TEXT1.VALUE}, {MyBox.Release} }
											// MessageBoxTimeout(,,,500)  //works
	END TEXTBOX
	
		*SetKeys('MYBOX') 
		*ON KEY F1 ACTION Helping('CRSWin.hlp')
		ON KEY ESCAPE OF MyBox Action { || { re := 'T' } ,{MyBox.Release} }	 
		END WINDOW
		
		*MYBOX.TEXT1.VALUE := MYBOXV
		*MYBOX.TEXT1.SETFOCUS
		Mybox.Activate

	Return 
Please see if you see anythng wrong here.
Thanks,.... Franco ;)

Re: Textbox Problem

Posted: Mon Jun 05, 2017 8:21 am
by serge_girard
Hi Franco,

This sample works fine.. I can't reproduce no runtime-error while pressing ENTER key.

Serge