Em 22/01/2010 19:41, Pritpal Bedi escreveu:
The example works correctly if you close the other
opened window before closing main. On my XP machine
the above code is working fine even if I close the main
without closing the other windows. But I am sure GPF can
appear in this case.
I am using Windows Vista and have GPF all times if I close the main
window without closing the child windows.
A new version of the sample, using a static variable to control the
windows opened. The main window only close if all child windows are closed.
[begincode]
#include "xbp.ch"
#include "appevent.ch"
Static nWindowsOpen := 0
PROCEDURE Main ()
LOCAL oDlg
LOCAL mp1
LOCAL mp2
LOCAL oXbp
LOCAL nEvent
LOCAL oMenuBar
LOCAL oSubMenu
oDlg := XbpDialog():new( , , {10,10}, {800,600}, , .f. )
oDlg:title := "Test"
oDlg:create()
SetAppWindow( oDlg )
oMenuBar := XbpMenuBar():new(oDlg)
oMenuBar:create()
oSubMenu := XbpMenu():new(oMenuBar)
oSubMenu:create()
oSubMenu:title := "Menu"
oSubMenu:addItem( { "New window",
{||hb_threadstart({||NewWindow()})} } )
oMenuBar:addItem( { oSubMenu, NIL } )
oDlg:Show()
DO WHILE .t.
nEvent := AppEvent( @mp1, @mp2, @oXbp )
IF nEvent == xbeP_Close .AND. nWindowsOpen <> 0
MsgBox( "Close child windows first", "Alert" )
ENDIF
IF nEvent == xbeP_Close .AND. nWindowsOpen == 0
MsgBox( "Closing main window", "Alert" )
EXIT
ENDIF
oXbp:handleEvent( nEvent, mp1, mp2 )
ENDDO
oDlg:destroy()
RETURN
STATIC FUNCTION NewWindow ()
LOCAL oDlg
LOCAL nEvent
LOCAL mp1
LOCAL mp2
LOCAL oXbp
oDlg := XbpDialog():new( , , {20,20}, {640,480}, , .f. )
oDlg:title := "New window"
oDlg:create()
oDlg:Show()
++nWindowsOpen
DO WHILE .t.
nEvent := AppEvent( @mp1, @mp2, @oXbp )
IF nEvent == xbeP_Close
EXIT
ENDIF
oXbp:handleEvent( nEvent, mp1, mp2 )
ENDDO
oDlg:destroy()
--nWindowsOpen
RETURN NIL
[endcode]
The windows are empty. Next step is to add things to the windows.
Thanks!
--
Regards,
Marcos Antonio Gambeta
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour