FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Force dialog to foreground
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Force dialog to foreground
Posted: Fri Apr 21, 2023 03: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
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Force dialog to foreground
Posted: Fri Apr 21, 2023 04:03 PM
Tim:
Prueba con
Code (fw): Select all Collapse
.....
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"
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: Force dialog to foreground
Posted: Fri Apr 21, 2023 04: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
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Force dialog to foreground
Posted: Fri Apr 21, 2023 04:30 PM
hi Tim,

try this
Code (fw): Select all Collapse
   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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Force dialog to foreground
Posted: Fri Apr 21, 2023 05: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
Posts: 181
Joined: Thu Apr 17, 2008 02:38 PM
Re: Force dialog to foreground
Posted: Fri Apr 21, 2023 09: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

Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Force dialog to foreground
Posted: 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
Posts: 181
Joined: Thu Apr 17, 2008 02:38 PM
Re: Force dialog to foreground
Posted: 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 (fw): Select all Collapse
*----------------------------------------------------------------------------------------------
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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Force dialog to foreground
Posted: 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
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: Force dialog to foreground
Posted: Sat Apr 22, 2023 05: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.

Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Force dialog to foreground
Posted: Mon Apr 24, 2023 08: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

Continue the discussion