Problema con botón Cancelar

HMG en Español

Moderator: Rathinagiri

Post Reply
citro
Posts: 52
Joined: Wed Dec 22, 2010 3:45 pm

Problema con botón Cancelar

Post by citro »

Dado el siguiente ejemplo:

Function Main

DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE 'HMG Demo' ;
MAIN

@ 10,10 TEXTBOX Text_1 ;
VALUE 0 ;
TOOLTIP 'Numeric TextBox' ;
NUMERIC ;
MAXLENGTH 5 ;
RIGHTALIGN ;
ON LOSTFOCUS if ( This.Value < 100 , This.SetFocus , Nil)

DEFINE BUTTON C
ROW 250
COL 100
WIDTH 160
CAPTION 'Cancel'
ACTION Form_1.Release
END BUTTON

DEFINE BUTTON D
ROW 250
COL 290
WIDTH 160
CAPTION 'Other'
ACTION Process()
END BUTTON

END WINDOW

Form_1.Center

Form_1.Activate

Return Nil

static Function Process()

...
...

retu Nil


Si estoy posicionado en el control TEXTBOX y pulso el botón CANCEL, no sale del TEXTBOX y tampoco puede salir del formulario. No es un problema extremo porque uno siempre tiene la posibilidad de salir cerrando el formulario desde la "x" de la ventana, pero ¿ Cómo se puede solucionar este problema ?
Antonio
Sistemas
Resipol
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: Problema con botón Cancelar

Post by Pablo César »

Inseri una variable al comienzo para realizar la excepccion. Fijate si es eso lo que precisas:

Code: Select all

#include <hmg.ch>

Function Main
	Local lSale:=.F.

	DEFINE WINDOW Form_1 ;
	AT 0,0 ;
	WIDTH 640 HEIGHT 480 ;
	TITLE 'HMG Demo' ;
	MAIN 

	@ 10,10 TEXTBOX Text_1 ;
	VALUE 0 ;
	TOOLTIP 'Numeric TextBox' ;
	NUMERIC ;
	MAXLENGTH 5 ;
	RIGHTALIGN ;
	ON LOSTFOCUS if ( This.Value < 100 , If(lSale=.T.,This.SetFocus,Nil) , Nil)

	DEFINE BUTTON C
	ROW	250
	COL	100
	WIDTH	160
	CAPTION	'Cancel'
	ACTION	{||Form_1.Release,lSale:=.T.}
	END BUTTON

	DEFINE BUTTON D
	ROW	250
	COL	290
	WIDTH	160
	CAPTION	'Other'
	ACTION	Process()
	END BUTTON
END WINDOW
Form_1.Center
Form_1.Activate
Return Nil

static Function Process()
retu Nil
Creo que esta solución te piueda dar una idea para solucionar este otro tópico: http://hmgforum.com/viewtopic.php?f=24&t=2141. Espero que esto te ayude.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
citro
Posts: 52
Joined: Wed Dec 22, 2010 3:45 pm

Re: Problema con botón Cancelar

Post by citro »

Con ese arreglo sale al pulsar el botón Cancelar, pero si en lugar de Cancelar pulso el botón Other no valida el TextBox.
Antonio
Sistemas
Resipol
Post Reply