Make a dialog never lost focus

Make a dialog never lost focus

Postby Francisco Valério » Thu Jul 31, 2014 5:52 pm

Hey

I need to make a dialog that never lost focus, if I click out the dialog, I need the dialog got focus again.

How can I do this ?
Francisco Valério
 
Posts: 18
Joined: Mon Jan 13, 2014 8:37 pm

Re: Make a dialog never lost focus

Postby Antonio Linares » Thu Jul 31, 2014 6:29 pm

You may try this:

oDlg:bLostFocus := { || oDlg:SetFocus() }
regards, saludos

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

Re: Make a dialog never lost focus

Postby Francisco Valério » Thu Jul 31, 2014 7:22 pm

Antonio Linares wrote:You may try this:

oDlg:bLostFocus := { || oDlg:SetFocus() }


I already tried. And it doesn't work.

My app is running in tray, and when I get a command, the app show a dialog and this dialog cannot lost the focus.
Francisco Valério
 
Posts: 18
Joined: Mon Jan 13, 2014 8:37 pm

Re: Make a dialog never lost focus

Postby Antonio Linares » Fri Aug 01, 2014 1:09 am

A possible solution is to use the dialog style DS_SYSMODAL:

DEFINE DIALOG oDlg STYLE DS_SYSMODAL

http://msdn.microsoft.com/en-us/library/windows/desktop/ff729172(v=vs.85).aspx

Though as the Microsoft docs specify, the user may select another window.

Have you considered to disable all other running apps windows ? Another choice is to capture the mouse.

What controls do you have on such dialog ?
regards, saludos

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

Re: Make a dialog never lost focus

Postby Francisco Valério » Fri Aug 01, 2014 2:02 pm

How can I capture the mouse ??
Francisco Valério
 
Posts: 18
Joined: Mon Jan 13, 2014 8:37 pm

Re: Make a dialog never lost focus

Postby Antonio Linares » Fri Aug 01, 2014 2:53 pm

Francisco,

oDlg:Capture()
regards, saludos

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

Re: Make a dialog never lost focus

Postby Francisco Valério » Fri Aug 01, 2014 8:05 pm

Antonio Linares wrote:Francisco,

oDlg:Capture()


Don't work. Capture the mouse neither the STYLE DS_SYSMODAL

Here is my code. It's a normal dialog and I need that the dialog never lost focus.

Code: Select all  Expand view  RUN

function SelecionaFormaDePagamento( )

   local oFonte, oFonte2, oDialog, oLabel, nFormaSelecionada, hButton := HB_Hash()

   Define Font oFonte Name 'Arial' Size -0,20 bold
   Define Font oFonte2 Name 'Arial Black' Size -0,22// bold

   Define dialog oDialog resource "SELECIONADEBCRE" title "Gerenciador TEF -- PAGAMENTO" font oFonte

      oDialog:lTransparent := !IsAppThemed()

      redefine say oLabel id 5001 of oDialog color CLR_HRED ,CLR_WHITE font oFonte2



      redefine buttonbmp hButton['CartaoDebito' ] bitmap "CARTAO"           id 6001           of oDialog action( nFormaSelecionada := CARTAO_DEBITO_A_VISTA , oDialog:End() )     textright
      redefine buttonbmp hButton['CartaoCredito'] bitmap "CARTAO"           id 6002           of oDialog action( AcaoBotaoCredito( @nFormaSelecionada, oDialog ) )                 textright
      redefine buttonbmp hButton['Encerrar'     ] bitmap "M_EXIT"           id 6003           of oDialog action( oDialog:End() )        textright

      oDialog:lHelpIcon := .f.
      oDialog:bKeyDown  := {| nKey | FuncaoTeclas( nKey, hButton ) }
   activate dialog oDialog centered on init ( OnInit( oLabel, oDialog ) )

   oFonte:End()
   oFonte2:End()


return nFormaSelecionada
/******************************************************************************/
static procedure OnInit( oLabel, oDialog )

   oLabel:SetText(CRLF+'Escolha a opcao desejada.')
   oLabel:lTransparent := .f.
   oLabel:SetColor( CLR_HRED ,CLR_WHITE )
   ForcaJanelaAparecer( oDialog )
   oDialog:Capture()

return
/******************************************************************************/
static procedure AcaoBotaoCredito( nFormaSelecionada, oDialog )


   if SelecionaCreditoAVistaOuPrazo( @nFormaSelecionada )
      oDialog:End()
   endif

return
/******************************************************************************/
static procedure FuncaoTeclas( nKey, hButton )

   if nKey == 49
      hButton['CartaoDebito' ]:Click()
   elseif nKey == 50
      hButton['CartaoCredito']:Click()
   elseif nKey == VK_F11
      hButton['Encerrar'     ]:Click()
   endif

return

 
Francisco Valério
 
Posts: 18
Joined: Mon Jan 13, 2014 8:37 pm

Re: Make a dialog never lost focus

Postby Antonio Linares » Fri Aug 01, 2014 9:12 pm

Francisco,

Why don't you want it to never loose focus ?

What is that usefull for ?
regards, saludos

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

Re: Make a dialog never lost focus

Postby Francisco Valério » Mon Aug 04, 2014 2:23 pm

It's an app business rule. The app is a payment system that works with credit card, and when I request to pay with the card, no other app can take the focus. So I need the dialog never lost focus.

Any other idea?
Francisco Valério
 
Posts: 18
Joined: Mon Jan 13, 2014 8:37 pm

Re: Make a dialog never lost focus

Postby Antonio Linares » Mon Aug 04, 2014 2:31 pm

Francisco,

I can not understand why STYLE DS_SYSMODAL does not work for you

Are you able to click on other apps meanwhile it is shown ?
regards, saludos

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

Re: Make a dialog never lost focus

Postby Francisco Valério » Mon Aug 04, 2014 4:59 pm

Image

This is my app. The app run in tray, and in a command it opens a dialog.
Francisco Valério
 
Posts: 18
Joined: Mon Jan 13, 2014 8:37 pm

Re: Make a dialog never lost focus

Postby Antonio Linares » Mon Aug 04, 2014 5:10 pm

Are you using STYLE DS_SYSMODAL to create it ?
regards, saludos

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

Re: Make a dialog never lost focus

Postby Francisco Valério » Mon Aug 04, 2014 5:27 pm

Antonio Linares wrote:Are you using STYLE DS_SYSMODAL to create it ?


Yes.
I only change:
Define dialog oDialog resource "SELECIONADEBCRE" title "Gerenciador TEF -- PAGAMENTO" font oFonte

to
Define dialog oDialog resource "SELECIONADEBCRE" title "Gerenciador TEF -- PAGAMENTO" font oFonte STYLE DS_SYSMODAL

Is it right? But it don't work too.
Francisco Valério
 
Posts: 18
Joined: Mon Jan 13, 2014 8:37 pm

Re: Make a dialog never lost focus

Postby Antonio Linares » Mon Aug 04, 2014 5:41 pm

Ok, I think I know how you may do it:

You may need to "cover" the entire desktop with a transparent dialog and then on top of it, place yours.

Today I am tired (I have been working many hours). I may help you later on or tomorrow, thanks
regards, saludos

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

Re: Make a dialog never lost focus

Postby Francisco Valério » Tue Aug 05, 2014 4:52 pm

But will it work when the user press ALT+TAB ?

I'm working in another features in my app. Later I'll come back to the focus problem. But if you think in any solucion please tell me.
Francisco Valério
 
Posts: 18
Joined: Mon Jan 13, 2014 8:37 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 63 guests

cron