Make a dialog never lost focus

MGA
Posts: 1219
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá
Contact:

Re: Make a dialog never lost focus

Post by MGA »

static oTimer, oWnd, oButton[2]

#Define SW_MINIMIZE 6
#Define SW_RESTORE 9

/*******************************/
function Main()
/*
*/
define window ownd from 10, 10 to 20, 30 ;
nozoom ;
noiconize ;
nosysmenu ;
no caption ;
border none title 'Focus Test Application '

@ 3, 5 BUTTON oButton[1] prompt "&Ok" SIZE 40, 20 ACTION MsgInfo( "Any action here!" )
@ 3, 16 BUTTON oButton[2] prompt "&Cancel" SIZE 40, 20 ACTION oWnd:End() cancel

define timer oTimer of oWnd interval 1000 action(oTimer:Deactivate(), TestFocusApp(), oTimer:Activate())

activate window ownd on init(setwindowpos( oWnd:hwnd, -1, 0, 0, 0, 0, 3 ),obutton[1]:setfocus(),otimer:activate())

return nil

/**************************************/
static function TestFocusApp()
/*
*/
if !oButton[1]:lfocused .and. !oButton[2]:lfocused
ShowWindow(ownd:hwnd, SW_MINIMIZE)
ShowWindow(ownd:hwnd, SW_RESTORE)
endif
return .t.
ubiratanmga@gmail.com

FWH17.04
FWPPC
Harbour/xHarbour
xMate
Pelles´C
TDolphin
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Make a dialog never lost focus

Post by James Bott »

How about something like:

oDlg:bLostFocus:= {|oDlg| SetActiveWindow(oDlg:hWnd)}
Post Reply