Disabling/removing menu

Disabling/removing menu

Postby Roberto Parisi » Fri Jan 25, 2008 2:09 pm

Hi Antonio,
I can't disable or remove menuitems... is it a FWPPC bug??

I post you a sample:

#include "FWCE.ch"

static oMenu1, oMenu2, oMenu

function Main()

local oWnd

DEFINE WINDOW oWnd TITLE "TestMenu" ;
MENU BuildMenu()

@0,0 button "Disable" size 100, 20 action oMenu1:Disable() pixel
@30,0 button "Remove" size 100, 20 action RemoveMenu(oMenu:hMenu, 1) pixel

ACTIVATE WINDOW oWnd ;
ON CLICK MsgInfo( "Click!" )

return nil

//----------------------------------------------------------------------------//

function BuildMenu()

DEFINE MENU oMenu RESOURCE 102

REDEFINE MENUITEM oMenu1 ID 110 OF oMenu ACTION MsgInfo( "First" ) when .F.

REDEFINE MENUITEM oMenu2 ID 120 OF oMenu ACTION MsgInfo( "Second" )

return oMenu

//----------------------------------------------------------------------------//

#pragma BEGINDUMP
#include "windows.h"

HB_FUNC(REMOVEMENU) {
RemoveMenu((HMENU) hb_parnl(1), (UINT) hb_parnl(2), MF_BYPOSITION);
}

#pragma ENDDUMP


Regards,
Roberto Parisi
Roberto Parisi
 
Posts: 116
Joined: Thu Oct 13, 2005 5:14 pm
Location: Italy

Postby Antonio Linares » Fri Jan 25, 2008 5:25 pm

Roberto,

We are going to review it and we will provide you an answer asap
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Fri Jan 25, 2008 9:25 pm

Roberto,

Please try these functions:
Code: Select all  Expand view  RUN
TB_ENABLE( oMenu:hMenu, oMenuItem:nId )
TB_DISABLE( oMenu:hMenu, oMenuItem:nId )

Code: Select all  Expand view  RUN
HB_FUNC( TB_DISABLE )
{
   HWND hMenuBar = (HWND)SHFindMenuBar(hb_parnl(1));

   TBBUTTONINFO tbbi;
   tbbi.cbSize = sizeof(tbbi);
   tbbi.dwMask = TBIF_STATE;
   tbbi.fsState = TBSTATE_INDETERMINATE;

   SendMessage( hMenuBar, TB_SETBUTTONINFO, hb_parnl( 2 ), ( LPARAM ) &tbbi );
   return;
}

HB_FUNC ( TB_ENABLE )
{
   HWND hMenuBar = ( HWND ) SHFindMenuBar( hb_parnl( 1 ) );

   TBBUTTONINFO tbbi;
   tbbi.cbSize = sizeof(tbbi);
   tbbi.dwMask = TBIF_STATE;
   tbbi.fsState = TBSTATE_ENABLED;

   SendMessage( hMenuBar, TB_SETBUTTONINFO, hb_parnl( 2 ), ( LPARAM ) &tbbi);
   return;
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Roberto Parisi » Sat Jan 26, 2008 9:12 am

Thx Antonio but it seems doesn't work:

This is the full sample code:

#include "FWCE.ch"

static oMenuItem1, oMenuItem2, oMenu

function Main()

local oWnd

DEFINE WINDOW oWnd TITLE "TestMenu" ;
MENU BuildMenu()

@0,0 button "Disable" size 100, 20 action TB_Disable(oMenu:hMenu, oMenuItem1:nID) pixel
@30,0 button "Remove" size 100, 20 action TB_Enable(oMenu:hMenu, oMenuItem1:nID) pixel

ACTIVATE WINDOW oWnd ;
ON CLICK MsgInfo( "Click!" )

return nil

//----------------------------------------------------------------------------//

function BuildMenu()

DEFINE MENU oMenu RESOURCE 102

REDEFINE MENUITEM oMenuItem1 ID 110 OF oMenu ACTION MsgInfo( "First" ) when .F.

REDEFINE MENUITEM oMenuItem2 ID 120 OF oMenu ACTION MsgInfo( "Second" )

return oMenu

//----------------------------------------------------------------------------//

#pragma BEGINDUMP
#include "windows.h"
#include "commctrl.h"

HB_FUNC( TB_DISABLE )
{
HWND hMenuBar = (HWND)SHFindMenuBar(hb_parnl(1));

TBBUTTONINFO tbbi;
tbbi.cbSize = sizeof(tbbi);
tbbi.dwMask = TBIF_STATE;
tbbi.fsState = TBSTATE_INDETERMINATE;

SendMessage( hMenuBar, TB_SETBUTTONINFO, hb_parnl( 2 ), ( LPARAM ) &tbbi );
return;
}

HB_FUNC ( TB_ENABLE )
{
HWND hMenuBar = ( HWND ) SHFindMenuBar( hb_parnl( 1 ) );

TBBUTTONINFO tbbi;
tbbi.cbSize = sizeof(tbbi);
tbbi.dwMask = TBIF_STATE;
tbbi.fsState = TBSTATE_ENABLED;

SendMessage( hMenuBar, TB_SETBUTTONINFO, hb_parnl( 2 ), ( LPARAM ) &tbbi);
return;
}

#pragma ENDDUMP

Regards,
Roberto Parisi
Roberto Parisi
 
Posts: 116
Joined: Thu Oct 13, 2005 5:14 pm
Location: Italy

Postby Antonio Linares » Sun Jan 27, 2008 9:14 am

Roberto,

This sample is working fine. No need for the functions that I told you, sorry:
Code: Select all  Expand view  RUN
#include "FWCE.ch"

static oMenuItem1, oMenuItem2, oMenu

function Main()

local oWnd

DEFINE WINDOW oWnd TITLE "TestMenu" ;
MENU BuildMenu()

@  0, 0 button "Disable" size 100, 20 action oMenuItem1:Disable() pixel
@ 30, 0 button "Enable" size 100, 20 action oMenuItem1:Enable() pixel

ACTIVATE WINDOW oWnd ;
ON CLICK MsgInfo( "Click!" )

return nil

//----------------------------------------------------------------------------//

function BuildMenu()

DEFINE MENU oMenu RESOURCE 102

REDEFINE MENUITEM oMenuItem1 ID 110 OF oMenu ACTION MsgInfo( "First" )

REDEFINE MENUITEM oMenuItem2 ID 120 OF oMenu ACTION MsgInfo( "Second" )

return oMenu

//----------------------------------------------------------------------------//
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Roberto Parisi » Mon Jan 28, 2008 7:11 am

Sorry Antonio, but it doesn't work. After pressing "Disable" I still can press on menuitem first and get the MsgInfo()

Have you tried with your testmenu.rc sample?

Regards,
Roberto Parisi
Roberto Parisi
 
Posts: 116
Joined: Thu Oct 13, 2005 5:14 pm
Location: Italy

Postby Antonio Linares » Mon Jan 28, 2008 7:36 am

Roberto,

You must be doing something wrong as here it is working fine.

Please download it and test it:
http://rapidshare.com/files/87217677/test.zip.html
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Roberto Parisi » Mon Jan 28, 2008 8:44 am

Ok Antonio, I understand.

I use another rc file (the same of your testmenu.prg sample) without child menuitems.

This is the rc file:

#ifdef _CE
#include "c:\vce\include\arm\windows.h"
#include "c:\vce\include\arm\commctrl.h"
#endif

#define I_IMAGENONE (-2)
#define IDS_HELP 104

#ifdef _CE
102 RCDATA
BEGIN
102, 2,
I_IMAGENONE, 110, TBSTATE_ENABLED, TBSTYLE_AUTOSIZE, 202, 0, 0,
I_IMAGENONE, 120, TBSTATE_ENABLED, TBSTYLE_AUTOSIZE, 203, 0, 0,
END
#endif

STRINGTABLE DISCARDABLE
BEGIN
202 "First"
203 "Second"
END

102 MENU DISCARDABLE
BEGIN
MENUITEM "", 110
MENUITEM "", 120
END

Regards,
Roberto Parisi
Roberto Parisi
 
Posts: 116
Joined: Thu Oct 13, 2005 5:14 pm
Location: Italy

Postby Antonio Linares » Mon Jan 28, 2008 9:01 am

Roberto,

So is it working fine now for you ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Roberto Parisi » Mon Jan 28, 2008 9:11 am

No, Antonio.

If you use the rc file I provided you, you can't disable the menu item.

Regards,
Roberto Parisi
Roberto Parisi
 
Posts: 116
Joined: Thu Oct 13, 2005 5:14 pm
Location: Italy

Postby Antonio Linares » Mon Jan 28, 2008 10:18 am

Roberto,

Ok, for the top menuitems you have to use the functions that I told you, this way:

@ 0, 0 button "Disable" size 100, 20 action TB_Disable( oWnd:hWnd, 110 ) pixel

tested and working fine
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Roberto Parisi » Mon Jan 28, 2008 3:05 pm

Ok Antonio,
now it works, I needed to pass hWnd instead hMenu as first parameter in TB_Enable.

Many many thx.

Now I've troubles with GetKeyState() function, it returns always .F.

Regards,
Roberto Parisi
Roberto Parisi
 
Posts: 116
Joined: Thu Oct 13, 2005 5:14 pm
Location: Italy

Postby Antonio Linares » Wed Jan 30, 2008 9:39 pm

Roberto,

What value are you checking with GetKeyState() ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Roberto Parisi » Thu Jan 31, 2008 10:05 am

Every value...

With the sample try to press SHIFT + TAB to go to previous control... it goes always to the next control forward.

Regards,
Roberto Parisi

#include "FWCE.ch"

function Main()

local oWnd, cText := Space( 50 ), cText1 := Space( 50 ), cText2 := Space( 50 )

DEFINE WINDOW oWnd TITLE "Test"

@ 0, 0 GET cText SIZE 200, 20 pixel

@ 30, 2 GET cText1 SIZE 200, 20 pixel

@ 60, 2 GET cText2 SIZE 200, 20 pixel

ACTIVATE WINDOW oWnd

return nil
Roberto Parisi
 
Posts: 116
Joined: Thu Oct 13, 2005 5:14 pm
Location: Italy

Postby Antonio Linares » Thu Jan 31, 2008 10:12 am

Roberto,

Shift+Tab is working fine here on the WM2003 emulator.

Its going to the previous control

I email you my EXE
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 2 guests

cron