]> git.saurik.com Git - wxWidgets.git/commitdiff
Smartphone menus.
authorWłodzimierz Skiba <abx@abx.art.pl>
Wed, 16 Jun 2004 06:37:55 +0000 (06:37 +0000)
committerWłodzimierz Skiba <abx@abx.art.pl>
Wed, 16 Jun 2004 06:37:55 +0000 (06:37 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27832 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

build/bakefiles/files.bkl
include/wx/msw/toplevel.h
include/wx/msw/wince/setup.h
include/wx/msw/wx.rc
samples/dialogs/dialogs.cpp
src/msw/frame.cpp
src/msw/msgdlg.cpp
src/msw/toplevel.cpp
src/msw/wince/menuce.cpp [new file with mode: 0644]

index 51a84b82be7cc0c2583db48a839ba82e9b957a09..137e033651b6aacd2bff08e4a6955b17718dbbaf 100644 (file)
@@ -1319,6 +1319,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     src/msw/wince/filedlgwce.cpp
     src/msw/wince/helpwce.cpp
     src/msw/wince/tbarwce.cpp
+    src/msw/wince/menuce.cpp
 </set>
 <set var="WINCE_HDR" hints="files">
     wx/generic/fdrepdlg.h
@@ -1327,6 +1328,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
     wx/msw/wince/libraries.h
     wx/msw/wince/missing.h
     wx/msw/wince/tbarwce.h
+    wx/msw/wince/resources.h
 </set>
 
 
index 86247ab774e3ce59000778e709aaf8677d12f5dc..8fa710f1fd1defec6ec0da627be1803a756964bb 100644 (file)
@@ -81,6 +81,12 @@ public:
     void SetLastFocus(wxWindow *win) { m_winLastFocused = win; }
     wxWindow *GetLastFocus() const { return m_winLastFocused; }
 
+#ifdef __SMARTPHONE__
+    void SetLeftMenu(int id = wxID_ANY, const wxString& label = wxEmptyString, wxMenu *subMenu = NULL);
+    void SetRightMenu(int id = wxID_ANY, const wxString& label = wxEmptyString, wxMenu *subMenu = NULL);
+    bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
+#endif // __SMARTPHONE__
+
 protected:
     // common part of all ctors
     void Init();
@@ -123,6 +129,41 @@ protected:
     // the last focused child: we restore focus to it on activation
     wxWindow             *m_winLastFocused;
 
+#ifdef __SMARTPHONE__
+    class ButtonMenu
+    {
+    public:
+        ButtonMenu();
+        ~ButtonMenu();
+
+        void SetButton(int id = wxID_ANY, 
+                       const wxString& label  = wxEmptyString, 
+                       wxMenu *subMenu = NULL);
+
+        bool IsAssigned() const {return m_assigned;}
+        bool IsMenu() const {return m_menu!=NULL;}
+
+        int GetId() const {return m_id;}
+        wxMenu* GetMenu() const {return m_menu;}
+        wxString GetLabel() {return m_label;}
+
+        static wxMenu *DuplicateMenu(wxMenu *menu);
+
+    protected:
+        int      m_id;
+        wxString m_label;
+        wxMenu  *m_menu;
+        bool     m_assigned;
+    };
+
+    ButtonMenu               m_LeftButton;
+    ButtonMenu               m_RightButton;
+    HWND                     m_MenuBarHWND;
+
+    void ReloadButton(ButtonMenu& button, UINT menuID);
+    void ReloadAllButtons();
+#endif // __SMARTPHONE__
+
     DECLARE_EVENT_TABLE()
     DECLARE_NO_COPY_CLASS(wxTopLevelWindowMSW)
 };
index 41b861028e2dd7cc1eeb3147bb21c8b75294289c..c6368109394b6741b6338ac85c1f63be44d35f8e 100644 (file)
 // Default is 1
 //
 // Recommended setting: 1
+#ifdef __SMARTPHONE__
+#define wxUSE_STATUSBAR    0
+#else
 #define wxUSE_STATUSBAR    1
+#endif
 
 // Two status bar implementations are available under Win32: the generic one
 // or the wrapper around native control. For native look and feel the native
index 9b30263ba5b006edd489299e97408fc1ede5ae7a..c558138d6091c0362b4c7b3ab9f740030a91b74c 100644 (file)
 /////////////////////////////////////////////////////////////////////////////
 
 #if (defined( __GNUWIN32__ ) && !defined(__TWIN32__)) || defined(__MWERKS__)
-       #include <wx/msw/gnuwin32/winresrc.h>
+    #include <wx/msw/gnuwin32/winresrc.h>
 #else
-       #include <windows.h>
+    #include <windows.h>
 #endif
 
 #if defined(_WIN32_WCE)
-        #include <commctrl.h>
+    #include "wx\msw\wince\wince.rc"
 #endif
 
 //////////////////////////////////////////////////////////////////////////////
@@ -57,95 +57,6 @@ BEGIN
     END
 END
 
-#ifdef _WIN32_WCE
-
-// Dummy menubar/toolbar for WinCE
-
-5000 RCDATA DISCARDABLE
-BEGIN
-  // Popup menu name
-  5000,
-  // Count of items to put on the menu
-  0
-END
-
-5000 MENU DISCARDABLE
-BEGIN
-    POPUP "Dummy"
-    BEGIN
-    MENUITEM "Dummy" 99
-    END
-END
-
-// A menubar for Smartphone, which can only have 1 or 2 menu buttons.
-
-#define IDR_SMARTPHONE_MENUBAR          5002
-#define ID_FIRST_BUTTON                 40001
-#define ID_SECOND_BUTTON                40002
-#define IDS_CAP_MENU                    40003
-#define ID_MENU_TEST                    40004
-#define IDS_DONE                        40006
-
-STRINGTABLE DISCARDABLE
-BEGIN
-    5001      "Dummy menu"
-    IDS_DONE            "Done"
-    IDS_CAP_MENU        "Menu"
-END
-
-#ifndef I_IMAGENONE
-        #define I_IMAGENONE            (-2)
-#endif
-#ifndef NOMENU
-        #define NOMENU                 0xFFFF
-#endif
-
-#ifndef wxID_EXIT
-#define wxID_EXIT 5006
-#endif
-
-// A resource for a one-button menubar
-/*
-IDR_SMARTPHONE_MENUBAR MENU DISCARDABLE
-BEGIN
-    MENUITEM "Done",                          wxID_EXIT
-END
-
-STRINGTABLE DISCARDABLE
-BEGIN
-    IDS_DONE            "Done"
-    IDS_CAP_MENU        "Menu"
-END
-
-IDR_SMARTPHONE_MENUBAR RCDATA DISCARDABLE
-BEGIN
-    IDR_SMARTPHONE_MENUBAR, 1,
-    I_IMAGENONE, wxID_EXIT, TBSTATE_ENABLED, TBSTYLE_AUTOSIZE, IDS_DONE, 0, NOMENU,
-END
-*/
-
-// A resource for a two-button menubar
-
-IDR_SMARTPHONE_MENUBAR MENU DISCARDABLE
-BEGIN
-    MENUITEM "Done",                          wxID_EXIT
-    POPUP "Menu"
-    BEGIN
-        MENUITEM "OK",                          wxID_EXIT
-    END
-END
-
-IDR_SMARTPHONE_MENUBAR RCDATA DISCARDABLE
-BEGIN
-    IDR_SMARTPHONE_MENUBAR, 2,
-    I_IMAGENONE, wxID_EXIT, TBSTATE_ENABLED, TBSTYLE_AUTOSIZE, IDS_DONE, 0, NOMENU,
-    I_IMAGENONE, ID_SECOND_BUTTON, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_CAP_MENU, 0, 1,
-END
-
-
-#endif
-
-
 //////////////////////////////////////////////////////////////////////////////
 //
 // Standard wxWindows Cursors
index ccda7099f344e95bba020fac4fd5daa5a7a69c11..f2508efb3df242fc61ccc98bd81d6042125a0e1b 100644 (file)
@@ -25,6 +25,7 @@
 #include "wx/wx.h"
 #endif
 
+#include "wx/datetime.h"
 #include "wx/image.h"
 
 #if wxUSE_COLOURDLG
@@ -256,7 +257,7 @@ bool MyApp::OnInit()
 
         file_menu->Append(wxID_ANY,_T("Entry dialogs"),entry_menu);
 
-    #endif
+    #endif // wxUSE_TEXTDLG || wxUSE_NUMBERDLG
 
 
     #if wxUSE_FILEDLG
@@ -327,9 +328,13 @@ bool MyApp::OnInit()
     file_menu->AppendSeparator();
     file_menu->Append(wxID_EXIT, _T("E&xit\tAlt-X"));
 
+#if !defined( __SMARTPHONE__ )
     wxMenuBar *menu_bar = new wxMenuBar;
     menu_bar->Append(file_menu, _T("&File"));
     frame->SetMenuBar(menu_bar);
+#else
+    frame->SetRightMenu(wxID_ANY, _T("Menu"), file_menu);
+#endif // __SMARTPHONE__
 
     myCanvas = new MyCanvas(frame);
     myCanvas->SetBackgroundColour(*wxWHITE);
@@ -366,7 +371,9 @@ MyFrame::MyFrame(wxWindow *parent,
     }
 #endif // wxUSE_COLOURDLG
 
+#if wxUSE_STATUSBAR
     CreateStatusBar();
+#endif // wxUSE_STATUSBAR
 }
 
 #if wxUSE_COLOURDLG
index d7e2f909301ce6517718d27c6475b6ba8b052154..fd160920d6644d43240bb8c506fee7fe1516e0bf 100644 (file)
@@ -131,7 +131,7 @@ wxEND_FLAGS( wxFrameStyle )
 IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame, wxTopLevelWindow,"wx/frame.h")
 
 wxBEGIN_PROPERTIES_TABLE(wxFrame)
-       wxEVENT_PROPERTY( Menu , wxEVT_COMMAND_MENU_SELECTED , wxCommandEvent)
+    wxEVENT_PROPERTY( Menu , wxEVT_COMMAND_MENU_SELECTED , wxCommandEvent)
 
     wxPROPERTY( Title,wxString, SetTitle, GetTitle, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
     wxPROPERTY_FLAGS( WindowStyle , wxFrameStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
@@ -318,7 +318,19 @@ void wxFrame::PositionStatusBar()
 
 void wxFrame::AttachMenuBar(wxMenuBar *menubar)
 {
-#if defined(WINCE_WITHOUT_COMMANDBAR)
+#if defined(__SMARTPHONE__)
+    wxMenu *autoMenu = new wxMenu;
+
+    for( size_t n = 0; n < menubar->GetMenuCount(); n++ )
+    {
+        wxMenu *item = menubar->GetMenu(n);
+        wxString label = menubar->GetLabelTop(n);
+        wxMenu *new_item = wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(item);
+        autoMenu->Append(wxID_ANY, label, new_item);
+    }
+
+    SetRightMenu(wxID_ANY, _("Menu"), autoMenu);
+#elif defined(WINCE_WITHOUT_COMMANDBAR)
     if (!GetToolBar())
     {
         wxToolBar* toolBar = new wxToolBar(this, -1,
@@ -328,20 +340,20 @@ void wxFrame::AttachMenuBar(wxMenuBar *menubar)
         SetToolBar(toolBar);
         menubar->SetToolBar(toolBar);
     }
-       // Now adjust size for menu bar
-       int menuHeight = 26;
-       
-       //When the main window is created using CW_USEDEFAULT the height of the
-       // is created is not taken into account). So we resize the window after
-       // if a menubar is present
-       {
-               RECT rc;
-               ::GetWindowRect((HWND) GetHWND(), &rc);
-               // adjust for menu / titlebar height
-               rc.bottom -= (2*menuHeight-1);
-               
-               MoveWindow((HWND) GetHWND(), rc.left, rc.top, rc.right, rc.bottom, FALSE);
-       }
+    // Now adjust size for menu bar
+    int menuHeight = 26;
+
+    //When the main window is created using CW_USEDEFAULT the height of the
+    // is created is not taken into account). So we resize the window after
+    // if a menubar is present
+    {
+        RECT rc;
+        ::GetWindowRect((HWND) GetHWND(), &rc);
+        // adjust for menu / titlebar height
+        rc.bottom -= (2*menuHeight-1);
+
+        MoveWindow((HWND) GetHWND(), rc.left, rc.top, rc.right, rc.bottom, FALSE);
+    }
 #endif
 
     wxFrameBase::AttachMenuBar(menubar);
@@ -546,16 +558,16 @@ void wxFrame::PositionToolBar()
         }
 #endif // wxUSE_STATUSBAR
 
-               int x = 0;
-               int y = 0;
+        int x = 0;
+        int y = 0;
 #if defined(WINCE_WITH_COMMANDBAR)
-               // We're using a commandbar - so we have to allow for it.
-               if (GetMenuBar() && GetMenuBar()->GetCommandBar())
-               {
-                       RECT rect;
-                       ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect);
-                       y = rect.bottom - rect.top;
-               }
+        // We're using a commandbar - so we have to allow for it.
+        if (GetMenuBar() && GetMenuBar()->GetCommandBar())
+        {
+            RECT rect;
+            ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect);
+            y = rect.bottom - rect.top;
+        }
 #endif
 
         int tx, ty;
@@ -807,19 +819,19 @@ bool wxFrame::HandleSize(int x, int y, WXUINT id)
 #endif // wxUSE_TOOLBAR
 
 #if defined(WINCE_WITH_COMMANDBAR)
-               // Position the menu command bar
-               if (GetMenuBar() && GetMenuBar()->GetCommandBar())
-               {
-                       RECT rect;
-                       ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect);
-                       wxSize clientSz = GetClientSize();
-
-                       if ( !::MoveWindow((HWND) GetMenuBar()->GetCommandBar(), 0, 0, clientSz.x, rect.bottom - rect.top, true ) )
-                       {
-                               wxLogLastError(wxT("MoveWindow"));
-                       }
-                       
-               }
+        // Position the menu command bar
+        if (GetMenuBar() && GetMenuBar()->GetCommandBar())
+        {
+            RECT rect;
+            ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect);
+            wxSize clientSz = GetClientSize();
+
+            if ( !::MoveWindow((HWND) GetMenuBar()->GetCommandBar(), 0, 0, clientSz.x, rect.bottom - rect.top, true ) )
+            {
+                wxLogLastError(wxT("MoveWindow"));
+            }
+
+        }
 #endif
 
 
@@ -852,6 +864,14 @@ bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
         }
 #endif // wxUSE_MENUS_NATIVE
 
+#ifdef __SMARTPHONE__
+        // handle here commands from Smartphone menu bar
+        if ( wxTopLevelWindow::HandleCommand(id, cmd, control ) )
+        {
+            return true;
+        }
+#endif // __SMARTPHONE__
+
         if ( ProcessCommand(id) )
         {
             return TRUE;
@@ -1029,12 +1049,12 @@ wxPoint wxFrame::GetClientAreaOrigin() const
 #endif // wxUSE_TOOLBAR
 
 #if defined(WINCE_WITH_COMMANDBAR)
-       if (GetMenuBar() && GetMenuBar()->GetCommandBar())
-       {
-               RECT rect;
-               ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect);
-               pt.y += (rect.bottom - rect.top);
-       }
+    if (GetMenuBar() && GetMenuBar()->GetCommandBar())
+    {
+        RECT rect;
+        ::GetWindowRect((HWND) GetMenuBar()->GetCommandBar(), &rect);
+        pt.y += (rect.bottom - rect.top);
+    }
 #endif
 
     return pt;
index 6ea59bcfddb6699e697080d8250d9294882e49b2..5ea5ece2aec1ba0c4c68d012714197549c7e222a 100644 (file)
@@ -79,9 +79,11 @@ int wxMessageDialog::ShowModal()
     unsigned int msStyle = MB_OK;
     if (m_dialogStyle & wxYES_NO)
     {
+#if !defined(__SMARTPHONE__)
         if (m_dialogStyle & wxCANCEL)
             msStyle = MB_YESNOCANCEL;
         else
+#endif // __SMARTPHONE__
             msStyle = MB_YESNO;
 
         if (m_dialogStyle & wxNO_DEFAULT)
index 2f50475dcd606e21d4f03c77d1fcfe2119f35d2d..f42510697ae58f9080700b19d330f7f9bc6e4899 100644 (file)
@@ -143,6 +143,10 @@ void wxTopLevelWindowMSW::Init()
     m_fsIsShowing = FALSE;
 
     m_winLastFocused = (wxWindow *)NULL;
+
+#ifdef __SMARTPHONE__
+    m_MenuBarHWND = 0;
+#endif
 }
 
 WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const
@@ -523,6 +527,11 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent,
        }
 #endif
 
+#ifdef __SMARTPHONE__
+    SetLeftMenu(wxID_EXIT, _("Done"));
+    SetRightMenu(); // to nothing for initialization
+#endif
+
     return ret;
 }
 
diff --git a/src/msw/wince/menuce.cpp b/src/msw/wince/menuce.cpp
new file mode 100644 (file)
index 0000000..c9905e4
--- /dev/null
@@ -0,0 +1,261 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        src/msw/wince/menuce.cpp
+// Purpose:     Smartphone menus implementation
+// Author:      Wlodzimierz ABX Skiba
+// Modified by:
+// Created:     28.05.2004
+// RCS-ID:      $Id$
+// Copyright:   (c) Wlodzimierz Skiba
+// License:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
+    #pragma implementation "menuce"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+    #include "wx/wx.h"
+#endif
+
+#ifndef WX_PRECOMP
+    #include "wx/app.h"
+    #include "wx/toplevel.h"
+    #include "wx/menu.h"
+#endif //WX_PRECOMP
+
+#ifdef __SMARTPHONE__
+
+#include <windows.h>
+#include <ole2.h>
+#include <shellapi.h>
+#include <aygshell.h>
+#include "wx/msw/wince/missing.h"
+
+#include "wx/msw/wince/resources.h"
+
+wxTopLevelWindowMSW::ButtonMenu::ButtonMenu()
+{
+    m_id = wxID_ANY;
+    m_label = wxEmptyString;
+    m_menu = NULL;
+    m_assigned = false;
+}
+
+wxTopLevelWindowMSW::ButtonMenu::~ButtonMenu()
+{
+    if(m_menu)
+    {
+        delete m_menu;
+        m_menu = NULL;
+    };
+}
+
+void wxTopLevelWindowMSW::SetLeftMenu(int id, const wxString& label, wxMenu *subMenu)
+{
+    m_LeftButton.SetButton(id, label, subMenu);
+    ReloadAllButtons();
+}
+
+void wxTopLevelWindowMSW::SetRightMenu(int id, const wxString& label, wxMenu *subMenu)
+{
+    m_RightButton.SetButton(id, label, subMenu);
+    ReloadAllButtons();
+}
+
+void wxTopLevelWindowMSW::ButtonMenu::SetButton(int id, const wxString& label, wxMenu *subMenu)
+{
+    m_assigned = true;
+    m_id = id;
+    m_label = label;
+    m_menu = subMenu;
+}
+
+wxMenu *wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(wxMenu *menu)
+{
+       // This is required in case of converting wxMenuBar to wxMenu in wxFrame::SetMenuBar.
+       // All submenus has to be recreated because of new owner.
+
+       wxMenu *duplication = new wxMenu;
+
+       if (menu)
+       {
+        wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetFirst();
+        while (node)
+               {
+                       wxMenuItem *item = node->GetData();
+                       if (item)
+                       {
+                               wxMenu *submenu = NULL;
+
+                               if(item->IsSubMenu())
+                                   submenu = DuplicateMenu( item->GetSubMenu() );
+                               else
+                                       submenu = NULL;
+
+                               wxMenuItem *new_item = wxMenuItem::New(duplication, item->GetId(), item->GetLabel(), item->GetHelp(), item->GetKind(), submenu);
+
+                               if( item->IsCheckable() )
+                                   new_item->Check(item->IsChecked());
+
+                               new_item->Enable( item->IsEnabled() );
+
+                               duplication->Append(new_item);
+                       }
+            node = node->GetNext();
+               }
+               
+       }
+
+       return duplication;
+}
+
+void wxMenuToHMenu(wxMenu* in, HMENU hMenu)
+{
+    if(!in) return;
+
+    wxChar buf[256];
+
+    wxMenuItemList::compatibility_iterator node = in->GetMenuItems().GetFirst();
+    while ( node )
+    {
+        wxMenuItem *item = node->GetData();
+
+        UINT uFlags = 0;
+        UINT uIDNewItem;
+        LPCTSTR lpNewItem;
+
+        if( item->IsSeparator() )
+        {
+            uFlags |= MF_SEPARATOR;
+            uIDNewItem = (unsigned)wxID_ANY;
+            lpNewItem = NULL;
+        }
+        else
+        {
+            // label
+            uFlags |= MF_STRING;
+            wxStrcpy(buf, item->GetLabel().c_str());
+            lpNewItem = buf;
+
+            // state
+            uFlags |= ( item->IsEnabled() ? MF_ENABLED : MF_GRAYED );
+
+            // checked
+            uFlags |= ( item->IsChecked() ? MF_CHECKED : MF_UNCHECKED );
+
+            if( item->IsSubMenu() )
+            {
+                uFlags |= MF_POPUP;
+                HMENU hSubMenu = CreatePopupMenu();
+                wxMenuToHMenu(item->GetSubMenu(), hSubMenu);
+                uIDNewItem = (UINT) hSubMenu;
+            }
+            else
+            {
+                uIDNewItem = item->GetId();
+            }
+        }
+
+        AppendMenu(hMenu, uFlags, uIDNewItem, lpNewItem);
+
+        node = node->GetNext();
+    }
+}
+
+void wxTopLevelWindowMSW::ReloadButton(ButtonMenu& button, UINT menuID)
+{
+    TBBUTTONINFO  button_info;
+    wxChar        buf[256];
+
+    // set button name
+    memset (&button_info, 0, sizeof (TBBUTTONINFO));
+    button_info.cbSize = sizeof(TBBUTTONINFO);
+    button_info.dwMask = TBIF_TEXT | TBIF_STATE;
+    button_info.fsState = TBSTATE_ENABLED;
+    wxStrcpy(buf, button.GetLabel().c_str());
+    button_info.pszText = buf;
+    SendMessage(m_MenuBarHWND, TB_SETBUTTONINFO, menuID, (LPARAM) &button_info);
+
+    if(button.IsMenu())
+    {
+        HMENU hPopupMenu = (HMENU) SendMessage(m_MenuBarHWND, SHCMBM_GETSUBMENU, 0, menuID);
+        RemoveMenu(hPopupMenu, 0, MF_BYPOSITION);
+        wxMenuToHMenu(button.GetMenu(), hPopupMenu);
+    }
+}
+
+void wxTopLevelWindowMSW::ReloadAllButtons()
+{
+    // first reaload only after initialization of both buttons
+    // it should is done at the end of Create() of wxTLW
+    if(!m_LeftButton.IsAssigned() || !m_RightButton.IsAssigned())
+        return;
+
+    SHMENUBARINFO menu_bar;
+    wxString      label;
+
+    memset (&menu_bar,    0, sizeof (SHMENUBARINFO));
+    menu_bar.cbSize     = sizeof (SHMENUBARINFO);
+    menu_bar.hwndParent = (HWND) GetHWND();
+
+    if(m_LeftButton.IsMenu() && m_RightButton.IsMenu())
+        menu_bar.nToolBarId = IDR_MENUBAR_BOTH_MENUS;
+    else if(m_LeftButton.IsMenu())
+        menu_bar.nToolBarId = IDR_MENUBAR_LEFT_MENU;
+    else if(m_RightButton.IsMenu())
+        menu_bar.nToolBarId = IDR_MENUBAR_RIGHT_MENU;
+    else
+        menu_bar.nToolBarId = IDR_MENUBAR_ONE_BUTTON;
+
+    menu_bar.hInstRes = wxGetInstance();
+
+    if (!SHCreateMenuBar(&menu_bar))
+    {
+        wxFAIL_MSG( _T("SHCreateMenuBar failed") );
+        return;
+    }
+
+    HWND prev_MenuBar = m_MenuBarHWND;
+    m_MenuBarHWND = menu_bar.hwndMB;
+
+    ReloadButton(m_LeftButton, IDM_LEFT);
+    ReloadButton(m_RightButton, IDM_RIGHT);
+
+    // hide previous and show new menubar
+    if ( prev_MenuBar )
+        ::ShowWindow( prev_MenuBar, SW_HIDE );
+    ::ShowWindow( m_MenuBarHWND, SW_SHOW );
+
+}
+
+bool wxTopLevelWindowMSW::HandleCommand(WXWORD id, WXWORD WXUNUSED(cmd), WXHWND WXUNUSED(control))
+{
+    // handle here commands from Smartphone menu bar
+    if ( id == IDM_LEFT || id == IDM_RIGHT )
+    {
+        int menuId = id == IDM_LEFT ? m_LeftButton.GetId() : m_RightButton.GetId() ;
+        wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, menuId);
+        commandEvent.SetEventObject(this);
+        GetEventHandler()->ProcessEvent(commandEvent);
+        return true;
+    }
+    return false;
+}
+
+#endif // __SMARTPHONE__
+