Page 2 of 2
Re: Menu doesn't work CE 6.0
Posted: Mon Sep 10, 2018 10:03 am
by anas
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
Re: Menu doesn't work CE 6.0
Posted: Mon Sep 10, 2018 10:58 am
by Antonio Linares
SHCreateMenuBar() is already provided in FWPPC with function CESetMenu():
Code: Select all | Expand
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 ) );
}
Re: Menu doesn't work CE 6.0
Posted: Mon Sep 10, 2018 11:27 am
by Antonio Linares
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=windowsmobiledevmbi.dwFlags = SHCMBF_HMENU; // Adding this line should solve the problem
Re: Menu doesn't work CE 6.0
Posted: Mon Sep 10, 2018 11:57 am
by Antonio Linares
Re: Menu doesn't work CE 6.0
Posted: Mon Sep 10, 2018 1:45 pm
by anas
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
Re: Menu doesn't work CE 6.0
Posted: Tue Sep 11, 2018 8:21 am
by Antonio Linares
After reading this article:
https://www.codeproject.com/Articles/229498/An-alternative-way-to-create-the-menu-barI have tried this code:
Code: Select all | Expand
#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=vssmartdevicesnativeIt is not a FWPPC issue. It is a Windows CE bug

Re: Menu doesn't work CE 6.0
Posted: Tue Sep 11, 2018 8:31 am
by Antonio Linares
You may simulate a menu using buttons:
Code: Select all | Expand
#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
Re: Menu doesn't work CE 6.0
Posted: Wed Sep 12, 2018 11:46 am
by Antonio Linares
// 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