Mdichild frivolos - SOLUCIONADO

Re: Mdichild frivolos

Postby anserkk » Thu Aug 05, 2010 6: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: Select all  Expand view
wndMain():oWndClient:aWnd[i]:Restore()


Code: Select all  Expand view
*------------------------------------------------------*
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
User avatar
anserkk
 
Posts: 1331
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Mdichild frivolos - SOLUCIONADO

Postby Armando Picon » Thu Aug 05, 2010 5: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
User avatar
Armando Picon
 
Posts: 446
Joined: Mon Dec 26, 2005 9:11 pm
Location: Lima, Peru

Re: Mdichild frivolos - SOLUCIONADO

Postby Armando Picon » Thu Aug 05, 2010 8: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
User avatar
Armando Picon
 
Posts: 446
Joined: Mon Dec 26, 2005 9:11 pm
Location: Lima, Peru

Previous

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 45 guests