Menu actions

pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

Menu actions

Post 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

// 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
User avatar
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: Menu actions

Post by Enrico Maria Giordano »

It's normal behavior. Just don't put anything after the inner ACTIVATE WINDOW command. Use VALID clause instead.

EMG
pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

Post 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
pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

Post 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

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.
User avatar
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Post by Enrico Maria Giordano »

This is expected, as far as I know.

EMG
pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

Post 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

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.
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Post 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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

Post by pawelu »

Antonio,

This mean that I can't use commands eg:

(BuildAndWaitWithWindow1(), DoOtherCommandsAfterWindow1Close ())

Thanks for reply
Pawel
User avatar
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Post by Enrico Maria Giordano »

No, just use VALID clause, as I already said.

EMG
User avatar
Pier Luigi
Posts: 58
Joined: Fri Oct 07, 2005 6:30 am
Location: Rome - Italy

Post by Pier Luigi »

Enrico,

using VALID clause work fine.

Pier Luigi
pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

Post by pawelu »

Enrico,

What would be in Valid clause for my test code ?

Thanks
Pawel
User avatar
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Post by Enrico Maria Giordano »

Code: Select all | Expand

ACTIVATE WINDOW oWnd
         VALID MYCLOSEFUNCTION()

STATIC FUNCTION MYCLOSEFUNCTION()

    // Do what you want

    RETURN .T.


EMG
pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

Post by pawelu »

Enrico,

What this change in this code:

Code: Select all | Expand

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.
User avatar
Antonio Linares
Site Admin
Posts: 42511
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 73 times
Contact:

Post by Antonio Linares »

Pawel,

Code: Select all | Expand


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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

Post by pawelu »

Antonio,

Thanks for help.

Pawel
Post Reply