Force dialog to foreground

Force dialog to foreground

Postby TimStone » Fri Apr 21, 2023 3:53 pm

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
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Force dialog to foreground

Postby cmsoft » Fri Apr 21, 2023 4:03 pm

Tim:
Prueba con
Code: Select all  Expand view  RUN

.....
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
cmsoft
 
Posts: 1291
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Force dialog to foreground

Postby karinha » Fri Apr 21, 2023 4:10 pm

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
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Force dialog to foreground

Postby Jimmy » Fri Apr 21, 2023 4:30 pm

hi Tim,

try this
Code: Select all  Expand view  RUN
  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
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Force dialog to foreground

Postby TimStone » Fri Apr 21, 2023 5:22 pm

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
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Force dialog to foreground

Postby mauri.menabue » Fri Apr 21, 2023 9:53 pm

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
mauri.menabue
 
Posts: 155
Joined: Thu Apr 17, 2008 2:38 pm

Re: Force dialog to foreground

Postby TimStone » Fri Apr 21, 2023 10:15 pm

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
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Force dialog to foreground

Postby mauri.menabue » Fri Apr 21, 2023 11:47 pm

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 view  RUN

*----------------------------------------------------------------------------------------------
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
mauri.menabue
 
Posts: 155
Joined: Thu Apr 17, 2008 2:38 pm

Re: Force dialog to foreground

Postby TimStone » Fri Apr 21, 2023 11:50 pm

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
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Force dialog to foreground

Postby reinaldocrespo » Sat Apr 22, 2023 5:52 pm

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
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Force dialog to foreground

Postby TimStone » Mon Apr 24, 2023 8:57 pm

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
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 61 guests