FindWnd()-Mdi-Dialog NoWait (SOLUCIONADO)

FindWnd()-Mdi-Dialog NoWait (SOLUCIONADO)

Postby FranciscoA » Sat Dec 08, 2012 1:14 am

Hola amigos, ¿pueden ayudar con esto?

En un ambiente MDI, desde WinMain abro un Dialog NOWAIT incrustado en una oChild MDICHILD con 2 xBrowses. Luego abro otro Dialog NOWAIT incrustado en otra MDICHILD. Este último quiero que el usuario no pueda abrirlo mas de 1 vez. Para esto utilizo las siguientes funciones que encontré aquí en el foro:
Code: Select all  Expand view
Function ShowApplication(cWndTitle)
   local hWnd := FindWnd( cWndTitle )   //cFileNoExt( HB_ARGV( 0 ) ) ) // Use the window title here!
   
   if hWnd != nil
      if IsIconic( hWnd )
         ShowWindow( hWnd, SW_RESTORE )
      endif
      SetForeGroundWindow( hWnd )
   endif  
   
Return if(hWnd != nil, .t.,.f.)  //nil  
//----------------------------
Function FindWnd( cTitle )
   local hWnd := GetWindow( GetDesktopWindow(), GW_CHILD )

   while hWnd != 0
      if Upper( cTitle ) $ Upper( GetWindowText( hWnd ) )
         return hWnd
      endif

      hWnd = GetWindow( hWnd, GW_HWNDNEXT )
   enddo

return nil
 


Aparentemente trabajan bien, pero no funcionan en algunos casos:
1 - Si abro por primera vez DIALOG NOWAIT incrustado en la oChild MAXIMIZADA y luego trato de abrir la misma ventana, las funciones detectan correctamente, pero si la minimizo, cambio su tamaño a NORMAL o abro otro DIALOG NOWAIT diferente superpuesto al anterior descrito, las funciones no detectan que tengo esa ventana abierta y permite abrirla nuevamente.
¿Cómo se puede solucionar esto?
Agradezco de antemano.

Saludos.
Last edited by FranciscoA on Sat Dec 08, 2012 6:19 am, edited 1 time in total.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2110
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: FindWnd()-Mdi-Dialog NoWait

Postby FranciscoA » Sat Dec 08, 2012 2:51 am

Hola, con este ejemplo autocontenido lo pueden observar. Si abren las child normalmente, no son detectadas, pero si maximizan alguna si.
Code: Select all  Expand view
#include "FiveWin.ch"

#define GW_CHILD      5
#define GW_HWNDNEXT   2
#define SW_RESTORE    9

static oWnd
//--------------------------------------------------------------------
Function Main()

   SET CENTURY ON

   DEFINE WINDOW oWnd MDI  TITLE "PRUEBA" ;
          MENU BuildMenu()  

   ACTIVATE WINDOW oWnd MAXIMIZED ;
       VALID  MsgNoYes("¿Desea salir?","Salir")

return nil

//----------------------------------------------------------------------------//
Function BuildMenu()
local oMenu

   MENU oMenu 2007
      MENUITEM  "&Abiertas" ACTION Abiertas()
      MENUITEM "&Salir..."  ACTION oWnd:End()
   ENDMENU

return oMenu

//-------------------------
Function Abiertas()
LOCAL oChild, cTitle :="PROBANDO EVITAR ABRIR 2 VECES"
   
if ShowApplication(cTitle)
   MsgStop("Que tratas de hacer?")
   return nil

else

  DEFINE WINDOW oChild MDICHILD OF oWnd ;
       TITLE cTitle  ;
       COLOR 0, GetSysColor( )
     
  ACTIVATE WINDOW oChild;
      VALID ( .T. )
endif

RETURN NIL

//-----------------------------------------
Function ShowApplication(cWndTitle)
   local hWnd := FindWnd( cWndTitle )   //cFileNoExt( HB_ARGV( 0 ) ) ) // Use the window title here!
   
   if hWnd != nil
      if IsIconic( hWnd )
         ShowWindow( hWnd, SW_RESTORE )
      endif
         SetForeGroundWindow( hWnd )
   endif  
   
Return if(hWnd != nil, .t.,.f.)  //nil  
//----------------------------
Function FindWnd( cTitle )
   local hWnd := GetWindow( GetDesktopWindow(), GW_CHILD )

   while hWnd != 0
      if Upper( cTitle ) $ Upper( GetWindowText( hWnd ) )
         return hWnd
      endif

      hWnd = GetWindow( hWnd, GW_HWNDNEXT )
   enddo

return nil
 

Saludos.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2110
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: FindWnd()-Mdi-Dialog NoWait (SOLUCIONADO)

Postby FranciscoA » Sat Dec 08, 2012 6:15 am

Hola, aquí encontré la solución: (sólo unas dos "horitas" en el foro)
viewtopic.php?f=6&t=19505&hilit=mdi&start=15#p102852

Gracias anserkk, Daniel y Armando Picón.

Saludos.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2110
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.


Return to FiveWin para Harbour/xHarbour

Who is online

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