Page 1 of 2

Menu actions

PostPosted: Mon Oct 30, 2006 4:40 am
by pawelu
Antonio,

When I call window with menu program don't stop execution after activate clause. Below is sample.

Regards
Pawel

Code: Select all  Expand view
// testmenu.prg
#Include 'FwCe.Ch'

Function TestMenu ()

   Local oWnd := Nil
   Local oMnu := Nil

   Define Menu oMnu Resource 1001
   ReDefine MenuItem Id 1011 Of oMnu Action oWnd : End ()
   ReDefine MenuItem Id 1021 Of oMnu Action Window1 ()
   ReDefine MenuItem Id 1022 Of oMnu Action Window2 ()

   Define Window oWnd Title 'Test menu' Menu oMnu
   Activate Window oWnd

Return .T.

Function Window1 ()

   Local oWnd := Nil
   Local oGrp := Nil
   Local nGrp := 1

   Define Window oWnd Title 'Window1'

   @   5,   5 Group oGrp To 219, 230 Prompt 'Wybierz czynność do wykonania' Pixel
   @   1,   2 Radio nGrp Items 'Archiwizacja danych', 'Weryfikacja tabel', ;
   'Reindeksacja tabel', 'Usunięcie tabel', 'Ograniczenie danych', ;
   'Pobranie nowej wersji', 'Lista parametrów' Of oGrp Size 150, 15
   @ 246, 116 Button 'OK' Pixel Size 60, 20 Action oWnd : End ()
   @ 246, 178 Button 'Anuluj' Pixel Size 60, 20 Action oWnd : End ()

   Activate Window oWnd On Init EmptyMenu (oWnd : hWnd)

   MsgInfo ('Action after activate window')

Return .T.

Function Window2 ()

   Local oWnd := Nil
   Local oGrp := Nil
   Local nGrp := 1

   Define Window oWnd Title 'Window2'

   @   5,   5 Group oGrp To 175, 230 Prompt 'Wybierz dane konfiguracyjne' Pixel
   @   1,   2 Radio nGrp Items 'użytkownik', 'o firmie', 'uprawnienia', 'lista magazynów', 'adresy serwerów' Of oGrp Size 160, 15
   @ 246, 116 Button 'OK' Pixel Size 60, 20 Action Nil
   @ 246, 178 Button 'Anuluj' Pixel Size 60, 20 Action oWnd : End ()

   Activate Window oWnd On Init EmptyMenu (oWnd : hWnd)

   MsgInfo ('Action after activate window')

Return .T.

#pragma BEGINDUMP

#include <hbapi.h>
#include <hbapirdd.h>

#include <windows.h>
#include <aygshell.h>

HB_FUNC (EMPTYMENU)
{
   SHINITDLGINFO shidi;
   HWND hWnd = (HWND) hb_parnl (1);

   shidi.dwMask  = SHIDIM_FLAGS;
   shidi.hDlg    = hWnd;
   shidi.dwFlags = SHIDIF_EMPTYMENU;
   SHInitDialog (&shidi);
}

#pragma ENDDUMP

// testmenu.rc
#include "c:\vce\include\arm\windows.h"
#include "c:\vce\include\arm\commctrl.h"

LANGUAGE LANG_POLISH,SUBLANG_DEFAULT

1001 RCDATA
BEGIN
  1001, 2
  (-2), 10001, 4, 24, 10001, 0, 0
  (-2), 10002, 4, 24, 10002, 0, 1
END

1001 MENU
BEGIN
  POPUP "File"
  BEGIN
    MENUITEM "Exit", 1011
  END
  POPUP "Test"
  BEGIN
    MENUITEM "Window2", 1022
    MENUITEM "Window1", 1021
  END
END

STRINGTABLE
BEGIN
  10001, "File"
  10002, "Test"
END

Re: Menu actions

PostPosted: Mon Oct 30, 2006 7:58 am
by Enrico Maria Giordano
It's normal behavior. Just don't put anything after the inner ACTIVATE WINDOW command. Use VALID clause instead.

EMG

PostPosted: Mon Oct 30, 2006 8:15 am
by pawelu
Enrico,

Yes, but when I'm use previous version of FWPPC, commands after activate window clause were run after window close. In this moment probably I must change program code.

Regards
Pawel

PostPosted: Mon Oct 30, 2006 8:32 am
by pawelu
Enrico,

Some samples: in first procedure message is show after window closed, in seconds before ... What is properly - my opinion after.

Regards
Pawel

Code: Select all  Expand view
Function TestWnd ()

   Local oWnd := Nil

   Define Window oWnd Title 'Test Window'

   @ 100, 100 Button 'Window2' Size 60, 20 Pixel Action Wnd2 ()

   Activate Window oWnd

   // this is evaluated after window closed
   MsgInfo ('Commands after window activate')

Return .T.

Function Wnd2 ()

   Local oWnd := Nil

   Define Window oWnd Title 'Window 2'
   Activate Window oWnd

   // this is eveluated before window closed
   MsgInfo ('Commands after window activate')

Return .T.

PostPosted: Mon Oct 30, 2006 9:14 am
by Enrico Maria Giordano
This is expected, as far as I know.

EMG

PostPosted: Mon Oct 30, 2006 9:19 am
by pawelu
Enrico,

Other test - comma list: after button press all three window is created and focus is for Window 3 (?).

Pawel

Code: Select all  Expand view
Function TestWnd ()

   Local oWnd := Nil
   Local i := 0

   Define Window oWnd Title 'Test Window'

   @ 100, 100 Button 'Window2' Size 60, 20 Pixel Action (Wnd1 (++ i), Wnd1 (++ i), Wnd1 (++ i))

   Activate Window oWnd

Return .T.

Function Wnd1 (i)

   Local oWnd := Nil

   Define Window oWnd Title 'Window ' + AllTrim (Str (i))
   Activate Window oWnd

Return .T.

PostPosted: Mon Oct 30, 2006 10:14 am
by Antonio Linares
Pawel,

We have modified previous FWPPC behavior to turn it FW compatible.

Only the first ACTIVATE WINDOW waits in a modal way. Next ACTIVATE WINDOW just show it but don't wait.

PostPosted: Mon Oct 30, 2006 10:51 am
by pawelu
Antonio,

This mean that I can't use commands eg:

(BuildAndWaitWithWindow1(), DoOtherCommandsAfterWindow1Close ())

Thanks for reply
Pawel

PostPosted: Mon Oct 30, 2006 10:52 am
by Enrico Maria Giordano
No, just use VALID clause, as I already said.

EMG

PostPosted: Mon Oct 30, 2006 10:57 am
by Pier Luigi
Enrico,

using VALID clause work fine.

Pier Luigi

PostPosted: Mon Oct 30, 2006 11:00 am
by pawelu
Enrico,

What would be in Valid clause for my test code ?

Thanks
Pawel

PostPosted: Mon Oct 30, 2006 11:04 am
by Enrico Maria Giordano
Code: Select all  Expand view
ACTIVATE WINDOW oWnd
         VALID MYCLOSEFUNCTION()

STATIC FUNCTION MYCLOSEFUNCTION()

    // Do what you want

    RETURN .T.


EMG

PostPosted: Mon Oct 30, 2006 11:10 am
by pawelu
Enrico,

What this change in this code:

Code: Select all  Expand view
Function Window1 ()

   Local oWnd := Nil

   Define Window oWnd Title 'Window 1'
   @ 100, 100 Button 'Window 2' Size 80, 20 Pixel Action (Wnd2 (), MsgBox ('Ok'))
   Activate Window oWnd

Return .T.

Function Wnd2 ()

   Define Window oWnd Title 'Window 2'
   @ 100, 100 Button 'Close' Size 80, 20 Pixel Action oWnd : End ()
   // oWnd : bValid := {|| ???}
   Activate Window oWnd

Return .T.

PostPosted: Mon Oct 30, 2006 11:23 am
by Antonio Linares
Pawel,
Code: Select all  Expand view

Function Window1 ()

   Local oWnd := Nil

   Define Window oWnd Title 'Window 1'
   @ 100, 100 Button 'Window 2' Size 80, 20 Pixel Action Wnd2()
   Activate Window oWnd

Return .T.

Function Wnd2 ()

   Define Window oWnd Title 'Window 2'
   @ 100, 100 Button 'Close' Size 80, 20 Pixel Action oWnd : End ()
   Activate Window oWnd ;
      VALID ( MsgBox( "Ok" ), .t. )

Return .T.

PostPosted: Mon Oct 30, 2006 11:26 am
by pawelu
Antonio,

Thanks for help.

Pawel