Page 1 of 2

Simulates "Set Confirm Off" and Overwrite in TextBoxes

Posted: Sun Mar 23, 2014 1:47 am
by Pablo César
This improved example was extracted from this post of Toledo forum which I believe could it be usefull and we wish to share with you.

Code: Select all

#include <hmg.ch>

Function Main()
SET NAVIGATION EXTENDED
SET DATE TO BRITISH
SET CENTURY ON

DEFINE WINDOW Form_1 AT 0,0 ;
    WIDTH 400 HEIGHT 175 NOSIZE ;
    TITLE 'Simulating SET CONFIRM OFF at TextBoxes' ;
    MAIN
    
    ON KEY ESCAPE ACTION ThisWindow.Release()
    
    DEFINE STATUSBAR FONT "Courier New" SIZE 9
        STATUSITEM PadC("Press <Insert> key and type again",44)
        STATUSITEM " Insert" WIDTH 94 ICON if ( IsInsertActive() , "zzz_led_off" , "zzz_led_on" )
    END STATUSBAR
    
    DEFINE LABEL Label_1
        ROW   20
        COL   30
        WIDTH 160
        VALUE 'Field 1 (Length 10):'
        FONTBOLD .T.
    END LABEL

    DEFINE TEXTBOX Text_1
        ROW       20
        COL       160
        WIDTH     180
        MAXLENGTH 10
        ON CHANGE {|| SetConfOFF(10,0) }
    END TEXTBOX

    DEFINE LABEL Label_2
        ROW    48
        COL    30
        WIDTH  160
        VALUE 'Field 2 (Length 10):'
        FONTBOLD .T.
    END LABEL

    DEFINE TEXTBOX Text_2
        ROW   48
        COL   160
        WIDTH   180
        MAXLENGTH 10
        DATE .T.
        ON CHANGE {|| SetConfOFF(10,0) }
    END TEXTBOX

    DEFINE LABEL Label_3
        ROW   76
        COL   30
        WIDTH 160
        VALUE 'Field 3 (Length 14):'
        FONTBOLD .T.
    END LABEL

    DEFINE TEXTBOX Text_3
        ROW     76
        COL     160
        WIDTH   180
        INPUTMASK "999.999.999-99"
        ON CHANGE {|| SetConfOFF(0,Len("999.999.999-99")) }
    END TEXTBOX
    
    _DefineTimer ( 'StatusKeyBrd' , "Form_1" , 50 , ;
        {|| _SetStatusIcon ( 'StatusBar' , "Form_1" , 2 , if ( IsInsertActive() , "zzz_led_off" , "zzz_led_on" ) ) } )

END WINDOW
CREATE EVENT PROCNAME OnkeyAllEditBox()
Form_1.Center
Form_1.Activate
Return Nil

Function SetConfOFF( nMaxLength, nInputMask )
Local cFrmName   := ThisWindow.Name
Local cCmpName   := This.FocusedControl

If nInputMask > 0
   nMaxLength := nInputMask
Endif
If !Empty(cCmpName)
   If nMaxLength == GetProperty(cFrmName,cCmpName,"CaretPos")
      InsertTab()
   Endif
Endif
Return Nil

Function OnkeyAllEditBox()
Local nIndex := GetControlIndexByHandle (EventHWND())

If nIndex > 0 .AND. GetControlTypeByIndex (nIndex) == "TEXT"
   If EventMSG() == WM_CHAR
      If .NOT. (GetKeyState (VK_INSERT) == 0) .AND. HMG_GetLastVirtualKeyDown() != VK_RETURN .AND. HMG_GetLastVirtualKeyDown() != VK_BACK
         SendMessage (EventHWND(), WM_KEYDOWN, VK_DELETE, 0)
         KSETINS(.T.)
      Else
         KSETINS(.F.)
      Endif
   Endif
Endif
Return NIL
This demo when editing and fill TextBox will change focus to next field. Also can be use overwrite editing but works only when is TEXT and with no mask in it.

I hope you enjoy it !

Re: Simulates "Set Confirm Off" and Overwrite in TextBoxes

Posted: Sun Mar 23, 2014 2:10 am
by Javier Tovar
Hola Pablo César,

Muy bonito ejemplo! Felicidades!

Saludos

Simulates "Set Confirm Off" and Overwrite in TextBoxes

Posted: Sun Mar 23, 2014 2:25 am
by Pablo César
Gracias, Javier. Como siempre, muy atento ! :)

Re: Simulates "Set Confirm Off" and Overwrite in TextBoxes

Posted: Sun Mar 23, 2014 9:30 am
by mustafa
Hola amigo Pablo César
Encontre un sample del amigo LuchoMiranda "El Salmes"
sobre desglose de Cambio en la Moneda, estaba adaptando el
su ejemplo, cuando he visto tu magnifica rutina, me he permitido
adaptarla a mi codigo simplificando un poco, espero que les guste

Para que haga el salto automatico en TEXTBOX hay que poner
tambien los decimales ejemplo 234,00 € para que haga el salto
hay que poner los 2 ceros

Saludos
Mustafa
*-------------------------------- Google ----------------------------------------------*
Hello friend Pablo César
I found a sample LuchoMiranda Friend "The Salmes"
on breakdown of Currency Substitution, was adapting the
his example, when I saw your magnificent routine, I have allowed
adapt it to my code simplifying a bit, hope you like it

To make the automatic jump TEXTBOX must put
also decimal example 234.00 €to do the jump
must add 2 zeros

Regards
Mustafa :idea:

Re: Simulates "Set Confirm Off" and Overwrite in TextBoxes

Posted: Sun Mar 23, 2014 10:31 am
by esgici
Thanks, Pablo and Mustafa :)

Both samples are useful and educative :arrow:

Viva HMG :D

Simulates "Set Confirm Off" and Overwrite in TextBoxes

Posted: Sun Mar 23, 2014 2:53 pm
by Pablo César
Gracias Mustafa por tu contribuicion y me alegra que te haya sido útil.

Thank you Esgici for your usual interest.

Re: Simulates "Set Confirm Off" and Overwrite in TextBoxes

Posted: Tue Apr 01, 2014 9:19 am
by mustafa
Hola amigos:
Les presento una ampliación del Sample anterior
he incorporado opción tarjeta de Crédito, salvar
ventas en un fichero y opción a Listado Reporter
espero que les guste.
Saludos
Mustafa
*--------------- Google -----------------------*
Hello friends:
I present an extension of the previous Sample
I have incorporated credit card option, save
sales in a file and option Reporter Listing
hope you like.
regards
Mustafa :idea:

Re: Simulates "Set Confirm Off" and Overwrite in TextBoxes

Posted: Tue Apr 01, 2014 5:07 pm
by Javier Tovar
Gracias Mustafa por compartir! :D

Saludos

Re: Simulates "Set Confirm Off" and Overwrite in TextBoxes

Posted: Tue Apr 01, 2014 5:20 pm
by danielmaximiliano
Muy bueno Mustafá.....

Re: Simulates "Set Confirm Off" and Overwrite in TextBoxes

Posted: Fri Apr 04, 2014 10:40 am
by mustafa
Hola amigos:
Nueva ampliación del Sample
He incorporado Password y Usuario
que se graba en Base de Datos de Ventas
asi como Hora de la operación ver listado
Lean Fichero 'readme_key.pdf' donde hay
unos permisos autorizados.
Espero les guste
Saludos
Mustafa
*----------------- Google -------------------*
Hello friends:
Further enlargement of the Sample
I incorporated Password and User
which is recorded in Sales Database
also see Operation Time List
Read file 'readme_key.pdf' where
some permits authorized.
Hope you like
regards
Mustafa :idea: