Force dialog to foreground

Post Reply
User avatar
TimStone
Posts: 2955
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Has thanked: 25 times
Been thanked: 2 times
Contact:

Force dialog to foreground

Post by TimStone »

A client has problems because a popup dialog sometimes reverts to the background and he cant see it. Is there a command that can force a dialog to stay in the foreground until it is closed

In this case, an invoice is started in dialog 1. Dialog 2 is called to select the customer. It somehow disappears behind #1. The icon on the task bar does not display the individual screens ( as some programs do ) so its hard to retrieve the dialog back to the desired one. If dialog 1 is closed #2 is visible, but since it sends data back to 1, it crashes the system.

So I need to keep it forced to the foreground. This is NOT an MDI program so that is not the issue


Sent from my iPhone using Tapatalk
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
cmsoft
Posts: 1297
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina
Been thanked: 2 times

Re: Force dialog to foreground

Post by cmsoft »

Tim:
Prueba con

Code: Select all | Expand

.....
ACTIVATE DIALOG oDlg CENTER ON INIT DlgOnTop( .t.,oDlg:hWnd )

function DlgOnTop( lState, hWnd )

   local nRet := 0

   DEFAULT hWnd := GetActiveWindow()

   if !lState
      nRet = AcpOnTop( hWnd, -2, 0, 0, 0, 0, 3 )
   else
      nRet = AcpOnTop( hWnd, -1, 0, 0, 0, 0, 3 )
   endif

return nRet

dll32 static function AcpOnTop( hWnd AS LONG, hWndInsertAfter AS LONG, x AS LONG, y AS LONG, cx AS LONG, cy AS LONG, wFlags AS LONG ) ;
      AS LONG PASCAL  FROM "SetWindowPos" LIB "User32.dll"
 
User avatar
karinha
Posts: 7935
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 3 times
Contact:

Re: Force dialog to foreground

Post by karinha »

Good afternoon, what is a pop-up dialog? Do you have any models?

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
Jimmy
Posts: 1740
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 2 times

Re: Force dialog to foreground

Post by Jimmy »

hi Tim,

try this

Code: Select all | Expand

   ACTIVATE DIALOG oDlg ON INIT MakeTop( oDlg, oListbox ) CENTER

PROCEDURE MakeTop( oWnd, o1stFocus )
LOCAL oTimer

DEFAULT o1stFocus := oWnd

   SetWindowPos( oWnd:hWnd, HWND_TOPMOST, ;
                 oWnd:nTop, oWnd:nLeft, ;
                 oWnd:nWidth, oWnd:nHeight, nOr( SWP_NOMOVE, SWP_NOSIZE ) )
   oWnd:SetFocus()
   o1stFocus:SetFocus()

RETURN
using HWND_TOPMOST will do the Job
greeting,
Jimmy
User avatar
TimStone
Posts: 2955
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Has thanked: 25 times
Been thanked: 2 times
Contact:

Re: Force dialog to foreground

Post by TimStone »

Karinha,

A popup dialog is one called from another dialog. My post gave an example. In this case the popup ( secondary ) dialog is for looking up ( or adding ) a client and a vehicle being serviced. Because it’s two databases a simple list doesnt work


Sent from my iPhone using Tapatalk
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
mauri.menabue
Posts: 163
Joined: Thu Apr 17, 2008 2:38 pm

Re: Force dialog to foreground

Post by mauri.menabue »

Hi All,
Tim, check if the child popup dialog has the 'OF' clause set with the parent value,
obviously the child popup must be modal.
TIA
User avatar
TimStone
Posts: 2955
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Has thanked: 25 times
Been thanked: 2 times
Contact:

Re: Force dialog to foreground

Post by TimStone »

Normally that might work but it can be called from different places. For example it can be called from the main Window or from other dialogs.


Sent from my iPhone using Tapatalk
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
mauri.menabue
Posts: 163
Joined: Thu Apr 17, 2008 2:38 pm

Re: Force dialog to foreground

Post by mauri.menabue »

it is normal, being a customer registry, it can start from the main menu,
but also from the button in the customer field of the invoice, or of the order,
in any case it must have the father's reference as launch parameters.

Code: Select all | Expand

*----------------------------------------------------------------------------------------------
Function GesClients (oParents, lModal, ....)
*----------------------------------------------------------------------------------------------

   LOCAL oDlg

   DEFAULT lModal := .F.

    IF lModal
       DEFINE DIALOG oDlg  TRUEPIXEL TITLE "customer registry" SIZE 800, 600 OF oParents
       ACTIVATE DIALOG oDlg  CENTERED 
    ELSE
       DEFINE DIALOG oDlg  TRUEPIXEL TITLE "customer registry" SIZE 800, 600 OF oParents
       ACTIVATE DIALOG oDlg  CENTERED NOMODAL
    ENDIF

return CLI_COD

from invoice
GesClients (oWndInvoice, .T.) MODAL

from order
GesClients (oWndOrder, .T.) MODAL

from Main Menu
GesClients (oWndMain, .F.) NO MODAL
 
TIA
Maurizio Menabue
User avatar
TimStone
Posts: 2955
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Has thanked: 25 times
Been thanked: 2 times
Contact:

Re: Force dialog to foreground

Post by TimStone »

Good point. I will try that


Sent from my iPhone using Tapatalk
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
reinaldocrespo
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Force dialog to foreground

Post by reinaldocrespo »

Or, if working from inside a Class, I like to always have an ::oOwner property that can be set on object init or down the road. Any dialog is OF ::oOwner.

Just my 2 cents,


Reinaldo.
User avatar
TimStone
Posts: 2955
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Has thanked: 25 times
Been thanked: 2 times
Contact:

Re: Force dialog to foreground

Post by TimStone »

Good point.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Post Reply