bLostFocus in a Dialog

bLostFocus in a Dialog

Postby jose_murugosa » Mon Jul 31, 2006 12:32 pm

The following code must put the window on top always and never loose focus.
Windows is always on top but it looses focus, it seems to me that bLostFocus is not working, I prove with GotFocus and Set Focus and is the same thing.

Could somebody helpme please, becouse I cant find a solution.

Here is the code:

#define SWP_NOSIZE 0x0001
#define SWP_NOMOVE 0x0002
#define SWP_NOACTIVATE 0x0010
#define SWP_SHOWWINDOW 0x0040
#define HWND_TOPMOST -1
//
#include "FiveWin.ch"

FUNCTION MAIN
LOCAL oDlg, oGet, oGet2, oBtn, Capt:=Space(10), Capt2:=" "

DEFINE DIALOG oDlg RESOURCE "Dialogo" Title "Captura"
REDEFINE GET oGet VAR Capt ID 101 OF oDlg;
PICTURE "!!!!!!!!!!" VALID MsgInfo(Capt)
oGet:bLostFocus:={||(oGet:SetText:="", oGet:SetFocus() )}
ACTIVATE DIALOG oDlg CENTER ON INIT ( WindowTopMost( oDlg ), ;
oDlg:bLostFocus := { || oDlg:SetFocus() } ) //esta linea

RETURN NIL

FUNCTION WindowTopMost( oWnd )
SetWindowPos( oWnd:hWnd, HWND_TOPMOST,;
0, 0, 0, 0, ;
SWP_NOMOVE |;
SWP_NOSIZE |;
SWP_SHOWWINDOW |;
SWP_NOACTIVATE )
RETURN NIL
Saludos/Regards,
José Murugosa
"Los errores en programación, siempre están entre la silla y el teclado y la IA!!"
User avatar
jose_murugosa
 
Posts: 1180
Joined: Mon Feb 06, 2006 4:28 pm
Location: Uruguay

Postby Antonio Linares » Thu Aug 03, 2006 4:56 pm

Jose,

Could you post the RC of your sample ? Thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby jose_murugosa » Thu Aug 03, 2006 7:11 pm

Thanks Antonio

http://hyperupload.com/download/0143136 ... A.rar.html

Here you will find the prg and the rc files, you will see that the windows looses focus and the program fails.
Saludos/Regards,
José Murugosa
"Los errores en programación, siempre están entre la silla y el teclado y la IA!!"
User avatar
jose_murugosa
 
Posts: 1180
Joined: Mon Feb 06, 2006 4:28 pm
Location: Uruguay

Postby Antonio Linares » Sat Aug 05, 2006 9:26 am

Jose,

This way works ok:
Code: Select all  Expand view
#define SWP_NOSIZE 0x0001
#define SWP_NOMOVE 0x0002
#define SWP_NOACTIVATE 0x0010
#define SWP_SHOWWINDOW 0x0040
#define HWND_TOPMOST -1
//
#include "FiveWin.ch"

FUNCTION MAIN
LOCAL oDlg, oGet, oGet2, oBtn, Capt:=Space(10), Capt2:=" "

DEFINE DIALOG oDlg RESOURCE "Dialogo" Title "Captura"
REDEFINE GET oGet VAR Capt ID 101 OF oDlg;
PICTURE "!!!!!!!!!!" VALID ( MsgInfo(Capt), .t. )

oGet:bLostFocus := { || oGet:SetText( "" ), oGet:SetFocus() }

ACTIVATE DIALOG oDlg CENTER ;
   ON INIT WindowTopMost( oDlg )

RETURN NIL

FUNCTION WindowTopMost( oWnd )
SetWindowPos( oWnd:hWnd, HWND_TOPMOST,;
0, 0, 0, 0, nOr( SWP_NOMOVE, SWP_NOSIZE, SWP_SHOWWINDOW, SWP_NOACTIVATE ) )

RETURN NIL
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby jose_murugosa » Sat Aug 05, 2006 8:01 pm

Muchas gracias Antonio!!!!! :D
Saludos/Regards,
José Murugosa
"Los errores en programación, siempre están entre la silla y el teclado y la IA!!"
User avatar
jose_murugosa
 
Posts: 1180
Joined: Mon Feb 06, 2006 4:28 pm
Location: Uruguay


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: betoncu and 91 guests

cron