Menu doesn't work CE 6.0

Re: Menu doesn't work CE 6.0

Postby anas » Mon Sep 10, 2018 10:03 am

Hi Antonio,
how can we implement SHCreateMenuBar command in FWPPC ?

We have modified the example with TB_STYLEBUTTON but it doesn't works.

Have you an working menu CE 6.0 example compiled with FWPPC ?

regards
anas
 
Posts: 8
Joined: Wed Sep 05, 2018 8:11 am

Re: Menu doesn't work CE 6.0

Postby Antonio Linares » Mon Sep 10, 2018 10:58 am

SHCreateMenuBar() is already provided in FWPPC with function CESetMenu():

Code: Select all  Expand view  RUN
HB_FUNC( CESETMENU )
{
   HWND hWnd = ( HWND ) hb_parnl( 1 );

   static   SHMENUBARINFO mbi;

   memset( &mbi, 0, sizeof( SHMENUBARINFO ) );
   mbi.cbSize = sizeof( SHMENUBARINFO );
   mbi.hwndParent = hWnd;
   mbi.nToolBarId = hb_parnl( 2 );
   mbi.hInstRes   = GetModuleHandle( NULL );
   mbi.nBmpId     = hb_parnl( 3 );
   mbi.cBmpImages = hb_parnl( 4 );
   
   SHCreateMenuBar( &mbi );
   
   hb_retnl( SendMessage( mbi.hwndMB, SHCMBM_GETMENU, 0, 0 ) );
}
regards, saludos

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

Re: Menu doesn't work CE 6.0

Postby Antonio Linares » Mon Sep 10, 2018 11:27 am

You don't need to call SHCreateMenuBar() as FWPPC does it automatically.

It seems as something has changed in Windows CE 6. We are testing this now:

https://social.msdn.microsoft.com/Forums/expression/en-US/54f8233f-fc57-48eb-a7e1-3405ec4266dc/shcreatemenubar-fails-in-windows-mobile-6-project?forum=windowsmobiledev

mbi.dwFlags = SHCMBF_HMENU; // Adding this line should solve the problem
regards, saludos

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


Re: Menu doesn't work CE 6.0

Postby anas » Mon Sep 10, 2018 1:45 pm

Hi Antonio,

so we have just to wait for a solution.

Let us to know, because if there isn't we'll try another way

regards
anas
 
Posts: 8
Joined: Wed Sep 05, 2018 8:11 am

Re: Menu doesn't work CE 6.0

Postby Antonio Linares » Tue Sep 11, 2018 8:21 am

After reading this article:

https://www.codeproject.com/Articles/229498/An-alternative-way-to-create-the-menu-bar

I have tried this code:
Code: Select all  Expand view  RUN
#include "FWCE.ch"

#define MF_BYCOMMAND 0
#define MF_ENABLED   0
#define MF_STRING    0

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

function Main()

   local oWnd, hMenu

   DEFINE WINDOW oWnd TITLE "TestMenu" ;
      MENU BuildMenu()
     
   oWnd:oMenu:hMenu = CreateMenu()
   
   MyAppendMenu( oWnd:oMenu:hMenu, nOr( MF_BYCOMMAND, MF_ENABLED, MF_STRING ),;
                 110, "First" )  

   MyAppendMenu( oWnd:oMenu:hMenu, nOr( MF_BYCOMMAND, MF_ENABLED, MF_STRING ),;
                 120, "Second" )  
     
   MyAppendMenu( oWnd:oMenu:hMenu, nOr( MF_BYCOMMAND, MF_ENABLED, MF_STRING ),;
                 130, "Third" )  

   MsgInfo( MyCESetMenu( oWnd:hWnd, oWnd:oMenu:hMenu ) )  

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

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

function BuildMenu()

   local oMenu, oItem
   
   DEFINE MENU oMenu RESOURCE 102

   REDEFINE MENUITEM oItem ID 110 OF oMenu ACTION ( MsgInfo( "Clientes" ), oItem:SetCheck( .t. ) )

   REDEFINE MENUITEM ID 120 OF oMenu ACTION MsgInfo( "Proveedores" ) WHEN .F.
   
   REDEFINE MENUITEM ID 1310 OF oMenu ACTION MsgInfo( "Añadir" )

   REDEFINE MENUITEM ID 1320 OF oMenu ACTION MsgInfo( "Modificar" )

   REDEFINE MENUITEM ID 210 OF oMenu ACTION MsgInfo( "Albaranes" )

   REDEFINE MENUITEM ID 310 OF oMenu ACTION MsgInfo( "Manual" )

return oMenu

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

#pragma BEGINDUMP

typedef struct _CONTEXT CONTEXT, *PCONTEXT;

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

#include <fwppc.h>

HB_FUNC( CREATEMENU )
{
   hb_retnl( ( HB_LONG ) CreateMenu() );
}

HB_FUNC( MYAPPENDMENU )
{
   LPWSTR pW = ( LPWSTR ) AnsiToWide( ( char * ) hb_parc( 4 ) );
   
   hb_retl( AppendMenu( ( HMENU ) hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ), pW ) );
   hb_xfree( pW );
}

HB_FUNC( MYCESETMENU )
{
   static SHMENUBARINFO mbi;

   memset( &mbi, 0, sizeof( SHMENUBARINFO ) );
   mbi.cbSize = sizeof( SHMENUBARINFO );
   mbi.hwndParent = ( HWND ) hb_parnl( 1 );
   mbi.nToolBarId = hb_parnl( 2 );
   mbi.hInstRes   = GetModuleHandle( NULL );
   mbi.nBmpId     = hb_parnl( 3 );
   mbi.cBmpImages = hb_parnl( 4 );
   mbi.dwFlags    = SHCMBF_HMENU;
   
   SHCreateMenuBar( &mbi );
   
   hb_retnl( SendMessage( mbi.hwndMB, SHCMBM_GETMENU, 0, 0 ) );
}

#pragma ENDDUMP


But it is not working as expected. As described in these posts, SHCreateMenuBar() is broken in new Windows mobile versions:

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/52bef792-daa4-41ed-878b-bf22666609b2/shcreatemenubar-differences-in-windows-mobile-653?forum=vssmartdevicesnative

It is not a FWPPC issue. It is a Windows CE bug :-(
regards, saludos

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

Re: Menu doesn't work CE 6.0

Postby Antonio Linares » Tue Sep 11, 2018 8:31 am

You may simulate a menu using buttons:

Code: Select all  Expand view  RUN
#include "Fwce.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd

   @ 20,  0   BUTTON "First"  SIZE 70, 20 OF oWnd
   @ 20, 11.5 BUTTON "Second" SIZE 70, 20 OF oWnd
   @ 20, 23   BUTTON "Third"  SIZE 70, 20 OF oWnd

   ACTIVATE WINDOW oWnd

return nil
regards, saludos

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

Re: Menu doesn't work CE 6.0

Postby Antonio Linares » Wed Sep 12, 2018 11:46 am

// The format for menu RCDATA resource is:
//
//resourceId SHMENUBAR DISCARDABLE
//BEGIN
// referencedMenuId,
// buttonCount,
//
// /* button 0 */
// I_IMAGENONE /* iconId? */, commandId /* like IDC_something, received through WM_COMMAND */,
// buttonState /* TBSTATE_ENABLED */, buttonStyle /* TBSTYLE_BUTTON | TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE */,
// captionId /* string resource IDS_OK */, 0 /* no idea */, menuIndex /* starting from 0 - leftmost, or NOMENU if TBSTYLE_BUTTON */,
//
// /* button 1 */
// I_IMAGENONE, IDM_HELP, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
// IDS_HELP, 0, 0,
// ...
//END

https://github.com/kjk/moriarty-sm/blob/master/InfoManCommon.rc2
regards, saludos

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

Previous

Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 6 guests