ON LOSTFOCUS - PROBLEMA

HMG en Español

Moderator: Rathinagiri

User avatar
mustafa
Posts: 714
Joined: Fri Mar 20, 2009 11:38 am
Location: Alicante - Spain
Been thanked: 86 times

Re: ON LOSTFOCUS - PROBLEMA

Post by mustafa » Fri Oct 19, 2018 11:19 am

Nanu !!!
"molto bene"
Regards
Mustafa

User avatar
SALINETAS24
Posts: 227
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Has thanked: 2 times
Been thanked: 6 times

Post by SALINETAS24 » Sun Dec 02, 2018 10:20 pm

Hola, os paso la ultimo modificación que he realizado.

Code: Select all

/*
 * HMG - Harbour Win32 GUI library Demo
 *
 * Copyright 2002 Roberto Lopez <mail.box.hmg@gmail.com>
 * http://www.hmgforum.com//
 *
 * MODIFICACION PARA VARIOS LOSTFOCUS REALIZADA POR SARGANTANA.SOFT
 * QUE ACTIVA UNA VENTANA PARA PODER HACER LO QUE SE QUIERA.
 * José Manuel Carbonell Bernabe
 * SargantanaSoft@Gmail.com
 * Petrer City - Alicante - Spain.
*/

#include "hmg.ch"
#define WM_KILLFOCUS 

Function Main
LOCAL LOk:=.t.
	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 HEIGHT 480 ;
		TITLE 'HMG Demo' ;
		MAIN 

		@ 10,10 TEXTBOX Text_1 ;
			TOOLTIP 'Pon algo' ;
			VALUE "Uno ";
			ON LOSTFOCUS if(empty(This.Value),;
				IF(Poner_ventana("Text_1","Form_1",@lOk ),nil,msgbox("ME QUEDO") ),NIL)
				
			

		@ 40,10 TEXTBOX Text_2 ;
			TOOLTIP 'Pon algo' ;
			VALUE "dos ";
			ON LOSTFOCUS if(empty(This.Value),Poner_ventana("Text_2","Form_1",@lOk ),nil)
			
			
		@ 70,10 TEXTBOX Text_3 ;
			TOOLTIP "Pon algo" ;
			VALUE "PonAlgo" ;
			ON LOSTFOCUS if(empty(This.Value),Poner_ventana("Text_2","Form_1",@lOk ),nil)

		@ 100,10 TEXTBOX Text_4 ;
			TOOLTIP 'Numeric TextBox' ;
			NUMERIC ;
			MAXLENGTH 5 ;
			RIGHTALIGN 
		
		@ 130,10 TEXTBOX Text_5 ;
			TOOLTIP 'Numeric TextBox' ;
			NUMERIC ;
			MAXLENGTH 5 ;
			RIGHTALIGN 

	END WINDOW

	Form_1.Center
	Form_1.Text_1.Setfocus
	Form_1.Activate

Return Nil

STATIC func Poner_Ventana(cTitulo,cForm)
LOCAL cVar:=""
Local cTrol:=""
LOCAL lOk:=.t.

	IF !EMPTY(GetProperty( cForm, 'FocusedControl'))
			DEFINE WINDOW Form_Main1 ;
				AT 0,0 	WIDTH 240 HEIGHT 200 ;
				TITLE 'pon algo para cambiar focus';
				MODAL ;
				BACKCOLOR   BLUE 
				
				@ 100,100 textbox T1  WIDTH 150 HEIGHT 20 VALUE '' ;
						on lostfocus(cVar:=This.Value)
				
			END WINDOW	 
			CENTER WINDOW Form_Main1
			ON KEY ESCAPE OF FORM_MAIN1 ACTION FORM_MAIN1.RELEASE
			ACTIVATE WINDOW Form_Main1
			
			IF GetProperty( cForm, 'FocusedControl')!=cTitulo 
				cTrol:=GetProperty( cForm, 'FocusedControl')
				DISABLE  CONTROL  EVENT &cTrol OF &cForm
				IF EMPTY(cVar)  // --> Si esta vacio me quedo donde estaba
					DoMethod( cForm,cTitulo, 'SetFocus' )
					lOk:=.f.
				ENDIF
				ENABLE  CONTROL  EVENT &cTrol OF &cForm
			ENDIF
			
	ENDIF
	
RETURN lOk

Post Reply