When one form could not be SetFocused

Moderator: Rathinagiri

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

When one form could not be SetFocused

Post by Pablo César » Thu May 15, 2014 6:19 pm

Thank you guys, for you support and attention.

Basically, It is what I have done recently in FMG_Editor. I needed to PickUpColor function and the only way I found is to include SetFocus in another forms at GotFocus. But of course with some exemptions. Beause I need only when no fmg files was open.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
srvet_claudio
Posts: 2044
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 35 times
Been thanked: 146 times
Contact:

Post by srvet_claudio » Thu May 15, 2014 9:11 pm

Pablo César wrote:But I got only forcing the return to form_3 from the form_2 and have to do it the same to the Form_1. It is not dramatic, because I have something already. But it would be wonder to count with any way that would disrupt the upcoming event. I mean, run something before LOSTFOCUS event and before being executed the next event (GOTFOCUS in Form_2) can be aborted, causing the stay in the form_3.

Code: Select all

#include <hmg.ch>

Function Main()
DEFINE WINDOW Form_1 AT 219 , 253 WIDTH 678 HEIGHT 426 ;
   TITLE "Main Form" MAIN ON INIT Second_Form()

END WINDOW
MAXIMIZE WINDOW Form_1
ACTIVATE WINDOW Form_1
Return Nil


Function Second_Form()
DEFINE WINDOW Form_2 AT 200 , 400 WIDTH 478 HEIGHT 426 ;
   TITLE "Second Form" CHILD ON INIT Third_Form()
   
    DEFINE BUTTON Button_1
       ROW    50
       COL    50
       WIDTH  100
       HEIGHT 28
       ACTION (Return_Third(),SetProperty("Form_2","Label_1","VISIBLE",.F.))
       CAPTION "Back to Third"
       FONTNAME "Arial"
       FONTSIZE 9
       TOOLTIP ""
   END BUTTON
   
   DEFINE LABEL Label_1
       ROW    200
       COL    50
       WIDTH  220
       HEIGHT 48
       VALUE "No focus on Third Form...  :("
       FONTNAME "Arial"
       FONTSIZE 9
      VISIBLE .F.
       BACKCOLOR Nil
       FONTCOLOR RED
   END LABEL

END WINDOW
ACTIVATE WINDOW Form_2
Return Nil

Function Third_Form()
DEFINE WINDOW Form_3 AT 50 , 100 WIDTH 200 HEIGHT 300 ;
   TITLE "Third Form" CHILD ON LOSTFOCUS Return_Third()
   
   DEFINE LABEL Label_1
       ROW    50
       COL    10
       WIDTH  200
       HEIGHT 48
       VALUE "Click on Second Form to see if LOSTFOCUS works"
       FONTNAME "Arial"
       FONTSIZE 9
   END LABEL
      
END WINDOW
CREATE EVENT PROCNAME KillFocus()

ACTIVATE WINDOW Form_3
Return Nil

Function Return_Third()
DoMethod("Form_3","SetFocus")
SetProperty("Form_2","Label_1","VISIBLE",.T.)
Return Nil

FUNCTION KillFocus
LOCAL hWndGotFocus
   #define WM_KILLFOCUS 8
   IF EventHWND() == GetFormHandle("Form_3") .AND. EventMSG() == WM_KILLFOCUS
      hWndGotFocus := EventWPARAM()
      SETFOCUS (GetFormHandle("Form_3"))
      Form_3.Label_1.Value := "GotFocus: " + GetWindowInfoByHandle (hWndGotFocus)
      RETURN 0
   ENDIF
RETURN NIL
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Thu May 15, 2014 9:26 pm

WOW MASTER !!!!

You are so great !!!

Very clever, fantastic !

I loved it !

Thank you, very much. I knew that the ideal solution was to prevent the event ...

But I did not know how to get to it.

You are a genius!

Thank you, friend. Eres un gaucho ! Muchas gracias, Claudio !
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Thu May 15, 2014 9:31 pm

Claudio dame un tiempito, que voy adaptarlo al FMG_Editor. Creo que con la funcion KillFocus, no precisaré hacer la captura de la pantalla como lo hiciste en Coords.

Entonces, por ahora queda sin efecto este mensaje (al menos que no funcione para los dos casos: fmg cargado o sin).
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
srvet_claudio
Posts: 2044
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 35 times
Been thanked: 146 times
Contact:

Post by srvet_claudio » Thu May 15, 2014 10:48 pm

Pablo César wrote:Claudio dame un tiempito, que voy adaptarlo al FMG_Editor. Creo que con la funcion KillFocus, no precisaré hacer la captura de la pantalla como lo hiciste en Coords.

Entonces, por ahora queda sin efecto este mensaje (al menos que no funcione para los dos casos: fmg cargado o sin).
Ok
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Fri May 16, 2014 12:29 am

Hola Claudio,

El KillFocus, dió muy buen resultado, pero me falta resolver en otra situacion.

Y porque se trata del aplicativo FMG_Editor, te pido que tratemos en el tópico: http://hmgforum.com/viewtopic.php?p=34380#p34380
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

Post Reply