FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Mdichild frivolos - SOLUCIONADO
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Mdichild frivolos
Posted: Thu Aug 05, 2010 06:10 AM
Armando Picon wrote:Anserkk

Only it has a disadvantage. If the user has minimized the MDICHILD, the function always will come back .T. If the user is careful he will look on his screen for the minimized window and will activate her. But if he is not careful, the first thing that will do is to protest with regard to the quality of the application.

Armando


You can resolve the abve said problem by adding a line of code

Code (fw): Select all Collapse
wndMain():oWndClient:aWnd[i]:Restore()


Code (fw): Select all Collapse
*------------------------------------------------------*
Function wndSetFocus(cTitle)
*------------------------------------------------------*
/* Here is a function to prevent opening more than one copy of a MDI child window. 
聽 聽It also brings the window to the top and set the focus to it. 
   Title/Caption of the window is passed as a parameter
*/
local i:=0,lSuccess:=.f.
cTitle:=upper(cTitle)
For i=1 to len(wndMain():oWndClient:aWnd)
聽 if upper( wndMain():oWndClient:aWnd[i]:cCaption )=cTitle
聽 聽 聽wndMain():oWndClient:aWnd[i]:setFocus()
聽 聽 聽wndMain():oWndClient:aWnd[i]:Restore()
聽 聽 聽lSuccess:=.t.
聽 endif
Next
Return lSuccess


Here is the video demonstrating the same. An MDI child window is minmized and then the user tries to calll a new instance of the same MDI child window. See how the above code finds/locates the MDI child window, set focus to that window and then restore that window back so that multiple instances of the same MDI chaild window is not opened.

Video : http://screencast.com/t/NTE5NDNlNm

Regards
Anser
Posts: 446
Joined: Mon Dec 26, 2005 09:11 PM
Re: Mdichild frivolos - SOLUCIONADO
Posted: Thu Aug 05, 2010 05:38 PM

Anserkk

Yes, really it is a good solution. I am going to evaluate the convenience of establishing for me, as a standard, the function that you indicate. I do not understand very the sequence of actions from Class Window towards the Class tMdiChild.
The sequence seems to me to be confused between Window -> tFrame -> tMdiClient -> tMdiChild. There is repetition of bylines oWndClient and, the truth, I cannot imagine how they are interrelated.

In the tests that I did with Daniel, in a simple example, there works very well the variant that he proposes. But when the inserted thing in a big application, which was a motive of the consultation, since it does not work.

Regards

Armando

FWH + BCC582 + WorkShop 4.5 + Resource Hacker + Mingw
Mis nuevas herramientas
Comunicacion via WhatsApp (+51) 957549 665
Comunicaci贸n via Correo: apic1002002 at yahoo dot es; apic1002002@gmail.com
Posts: 446
Joined: Mon Dec 26, 2005 09:11 PM
Re: Mdichild frivolos - SOLUCIONADO
Posted: Thu Aug 05, 2010 08:49 PM

Daniel

Tuve la impresi贸n que tu c贸digo funcionaba en raz贸n a que no utilizaba muchos recursos del equipo y, ante esa ocurrencia, revis茅 el c贸digo llamador y reun铆 muchas variables en una Clase tipo oApp publica. Despu茅s de esto, volv铆 a insertar el c贸digo sugerido en las pruebas y, efectivamente, nuevamente vuelve a reconocer al c贸digo, tal como indicaste. Es decir tu c贸digo act煤a perfectamente. Es posible, en mi caso, que estuviera utilizando mucho recurso de la m谩quina y cuando disminu铆 la carga todo volvi贸 a la normalidad. As铆 que voy a utilizar tu c贸digo, indistintamente tambi茅n, con lo que sugiere Anserkk.

Expreso mi gratitud a ambos, a t铆 y tambi茅n a Anserkk

Saludos

Armando

FWH + BCC582 + WorkShop 4.5 + Resource Hacker + Mingw
Mis nuevas herramientas
Comunicacion via WhatsApp (+51) 957549 665
Comunicaci贸n via Correo: apic1002002 at yahoo dot es; apic1002002@gmail.com

Continue the discussion