]> git.sesse.net Git - vlc/commitdiff
* modules/gui/wince: fixed bunch of bugs and memory leaks.
authorGildas Bazin <gbazin@videolan.org>
Mon, 7 Mar 2005 14:37:39 +0000 (14:37 +0000)
committerGildas Bazin <gbazin@videolan.org>
Mon, 7 Mar 2005 14:37:39 +0000 (14:37 +0000)
modules/gui/wince/interface.cpp
modules/gui/wince/menus.cpp
modules/gui/wince/open.cpp
modules/gui/wince/playlist.cpp
modules/gui/wince/preferences.cpp
modules/gui/wince/wince.cpp
modules/gui/wince/wince.h
modules/gui/wince/wince_rc.rc

index d53a912d85cd9234f5d95bb74a0690158742d910..dea844a5c1abeee27bb1a3e1c725b0f2f69bbca5 100644 (file)
@@ -104,11 +104,24 @@ TCHAR * szToolTips[] =
 /*****************************************************************************
  * Constructor.
  *****************************************************************************/
+Interface::Interface()
+  : hwndMain(0), hwndCB(0), hwndTB(0), hwndSlider(0), hwndLabel(0),
+    hwndVol(0), hwndSB(0),
+    fileinfo(0), messages(0), preferences(0), playlist(0),
+    timer(0), open(0), video(0)
+{
+}
+
+Interface::~Interface()
+{
+    if( timer ) delete timer;
+    if( video ) delete video;
+}
+
 BOOL Interface::InitInstance( HINSTANCE hInstance, intf_thread_t *_p_intf )
 {
     /* Initializations */
     p_intf = _p_intf;
-    hwndMain = hwndCB = hwndTB = hwndSlider = hwndLabel = hwndVol = hwndSB = 0;
     i_old_playing_status = PAUSE_S;
 
     hInst = hInstance; // Store instance handle in our global variable
@@ -154,8 +167,10 @@ FUNCTION:
 PURPOSE: 
   Creates a menu bar.
 ***********************************************************************/
-static HWND CreateMenuBar( HWND hwnd, HINSTANCE hInst )
+HWND Interface::CreateMenuBar( HWND hwnd, HINSTANCE hInst )
 {
+    HMENU menu_file, menu_view;
+
 #ifdef UNDER_CE
     SHMENUBARINFO mbi;
     memset( &mbi, 0, sizeof(SHMENUBARINFO) );
@@ -175,44 +190,50 @@ static HWND CreateMenuBar( HWND hwnd, HINSTANCE hInst )
     tbbi.dwMask = TBIF_LPARAM;
 
     SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_FILE, (LPARAM)&tbbi );
-    HMENU hmenu_file = (HMENU)tbbi.lParam;
+    menu_file = (HMENU)tbbi.lParam;
     RemoveMenu( hmenu_file, 0, MF_BYPOSITION );
     SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_VIEW, (LPARAM)&tbbi );
-    HMENU hmenu_view = (HMENU)tbbi.lParam;
+    menu_view = (HMENU)tbbi.lParam;
     RemoveMenu( hmenu_view, 0, MF_BYPOSITION );
     SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_SETTINGS, (LPARAM)&tbbi );
-    HMENU hmenu_settings = (HMENU)tbbi.lParam;
+    menu_settings = (HMENU)tbbi.lParam;
+    SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_VIDEO, (LPARAM)&tbbi );
+    menu_video = (HMENU)tbbi.lParam;
+    SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_AUDIO, (LPARAM)&tbbi );
+    menu_audio = (HMENU)tbbi.lParam;
+    SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_NAVIGATION, (LPARAM)&tbbi );
+    menu_navigation = (HMENU)tbbi.lParam;
 
 #else
-    HMENU hmenu_file = CreatePopupMenu();
-    HMENU hmenu_view = CreatePopupMenu();
-    HMENU hmenu_settings = CreatePopupMenu();
-    HMENU hmenu_audio = CreatePopupMenu();
-    HMENU hmenu_video = CreatePopupMenu();
-    HMENU hmenu_navigation = CreatePopupMenu();
+    menu_file = CreatePopupMenu();
+    menu_view = CreatePopupMenu();
+    menu_settings = CreatePopupMenu();
+    menu_audio = CreatePopupMenu();
+    menu_video = CreatePopupMenu();
+    menu_navigation = CreatePopupMenu();
 #endif
 
-    AppendMenu( hmenu_file, MF_STRING, ID_FILE_QUICKOPEN,
+    AppendMenu( menu_file, MF_STRING, ID_FILE_QUICKOPEN,
                 _T("Quick &Open File...") );
-    AppendMenu( hmenu_file, MF_SEPARATOR, 0, 0 );
-    AppendMenu( hmenu_file, MF_STRING, ID_FILE_OPENFILE,
+    AppendMenu( menu_file, MF_SEPARATOR, 0, 0 );
+    AppendMenu( menu_file, MF_STRING, ID_FILE_OPENFILE,
                 _T("Open &File...") );
-    AppendMenu( hmenu_file, MF_STRING, ID_FILE_OPENNET,
+    AppendMenu( menu_file, MF_STRING, ID_FILE_OPENNET,
                 _T("Open &Network Stream...") );
-    AppendMenu( hmenu_file, MF_SEPARATOR, 0, 0 );
-    AppendMenu( hmenu_file, MF_STRING, ID_FILE_ABOUT,
+    AppendMenu( menu_file, MF_SEPARATOR, 0, 0 );
+    AppendMenu( menu_file, MF_STRING, ID_FILE_ABOUT,
                 _T("About VLC") );
-    AppendMenu( hmenu_file, MF_STRING, ID_FILE_EXIT,
+    AppendMenu( menu_file, MF_STRING, ID_FILE_EXIT,
                 _T("E&xit") );
 
-    AppendMenu( hmenu_view, MF_STRING, ID_VIEW_PLAYLIST,
+    AppendMenu( menu_view, MF_STRING, ID_VIEW_PLAYLIST,
                 _T("&Playlist...") );
-    AppendMenu( hmenu_view, MF_STRING, ID_VIEW_MESSAGES,
+    AppendMenu( menu_view, MF_STRING, ID_VIEW_MESSAGES,
                 _T("&Messages...") );
-    AppendMenu( hmenu_view, MF_STRING, ID_VIEW_STREAMINFO,
+    AppendMenu( menu_view, MF_STRING, ID_VIEW_STREAMINFO,
                 _T("Stream and Media &info...") );
 
-    AppendMenu( hmenu_settings, MF_STRING, ID_PREFERENCES,
+    AppendMenu( menu_settings, MF_STRING, ID_PREFERENCES,
                 _T("&Preferences...") );
 
 
@@ -222,17 +243,16 @@ static HWND CreateMenuBar( HWND hwnd, HINSTANCE hInst )
 #else
     HMENU hmenu = CreateMenu();
 
-    AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)hmenu_file, _T("File") );
-    AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)hmenu_view, _T("View") );
-    AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)hmenu_settings,
+    AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_file, _T("File") );
+    AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_view, _T("View") );
+    AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_settings,
                 _T("Settings") );
-    AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)hmenu_audio, _T("Audio") );
-    AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)hmenu_video, _T("Video") );
-    AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)hmenu_navigation,
-                _T("Nav.") );
+    AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_audio, _T("Audio") );
+    AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_video, _T("Video") );
+    AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_navigation, _T("Nav") );
 
     SetMenu( hwnd, hmenu );
-    return hwnd;
+    return 0;
 
 #endif
 }
@@ -506,8 +526,7 @@ FUNCTION:
 PURPOSE: 
   Processes messages sent to the main window.
 ***********************************************************************/
-LRESULT CALLBACK Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp,
-                                     LPARAM lp )
+LRESULT Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
 {
     switch( msg )
     {
@@ -525,7 +544,7 @@ LRESULT CALLBACK Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp,
         if( config_GetInt( p_intf, "wince-embed" ) )
             video = CreateVideoWindow( p_intf, hwnd );
 
-        ti = new Timer(p_intf, hwnd, this);
+        timer = new Timer( p_intf, hwnd, this );
 
         // Hide the SIP button (WINCE only)
         SetForegroundWindow( hwnd );
@@ -595,27 +614,27 @@ LRESULT CALLBACK Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp,
             break;
 
         case ID_VIEW_STREAMINFO:
-            fi = new FileInfo( p_intf, hInst );
-            CreateDialogBox( hwnd, fi );
-            delete fi;
+            fileinfo = new FileInfo( p_intf, hInst );
+            CreateDialogBox( hwnd, fileinfo );
+            delete fileinfo;
             break;
 
         case ID_VIEW_MESSAGES:
-            hmsg = new Messages( p_intf, hInst );
-            CreateDialogBox( hwnd, hmsg );
-            delete hmsg;
+            messages = new Messages( p_intf, hInst );
+            CreateDialogBox( hwnd, messages );
+            delete messages;
             break;
 
         case ID_VIEW_PLAYLIST:
-            pl = new Playlist( p_intf, hInst );
-            CreateDialogBox( hwnd, pl );
-            delete pl;
+            playlist = new Playlist( p_intf, hInst );
+            CreateDialogBox( hwnd, playlist );
+            delete playlist;
             break;
 
         case ID_PREFERENCES:
-            pref = new PrefsDialog( p_intf, hInst );
-            CreateDialogBox( hwnd, pref );
-            delete pref;
+            preferences = new PrefsDialog( p_intf, hInst );
+            CreateDialogBox( hwnd, preferences );
+            delete preferences;
             break;
                   
         default:
@@ -625,7 +644,7 @@ LRESULT CALLBACK Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp,
         break;
   
     case WM_TIMER:
-        ti->Notify();
+        timer->Notify();
         break;
 
     case WM_CTLCOLORSTATIC: 
@@ -649,18 +668,22 @@ LRESULT CALLBACK Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp,
         break;
 
     case WM_INITMENUPOPUP:
-        RefreshSettingsMenu( p_intf,
-            (HMENU)SendMessage( hwndCB, SHCMBM_GETSUBMENU, (WPARAM)0,
-                                (LPARAM)IDM_SETTINGS ) );
-        RefreshAudioMenu( p_intf,
-            (HMENU)SendMessage( hwndCB, SHCMBM_GETSUBMENU, (WPARAM)0,
-                                (LPARAM)IDM_AUDIO ) );
-        RefreshVideoMenu( p_intf,
-            (HMENU)SendMessage( hwndCB, SHCMBM_GETSUBMENU, (WPARAM)0,
-                                (LPARAM)IDM_VIDEO ) );
-        RefreshNavigMenu( p_intf,
-            (HMENU)SendMessage( hwndCB, SHCMBM_GETSUBMENU, (WPARAM)0,
-                                (LPARAM)IDM_NAVIGATION ) );
+        RefreshSettingsMenu( p_intf, menu_settings );
+        RefreshAudioMenu( p_intf, menu_audio );
+        RefreshVideoMenu( p_intf, menu_video );
+        RefreshNavigMenu( p_intf, menu_navigation );
+        /* Fall through */
+
+    case WM_ENTERMENULOOP:
+    case WM_KILLFOCUS:
+        if( video && video->hWnd )
+            SendMessage( video->hWnd, WM_KILLFOCUS, 0, 0 );
+        break;
+
+    case WM_EXITMENULOOP:
+    case WM_SETFOCUS:
+        if( video && video->hWnd )
+            SendMessage( video->hWnd, WM_SETFOCUS, 0, 0 );
         break;
 
     case WM_LBUTTONDOWN:
@@ -677,27 +700,24 @@ LRESULT CALLBACK Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp,
         }
         break;
 
+   case WM_RBUTTONUP:
+        {
+            POINT point;
+            point.x = LOWORD(lp);
+            point.y = HIWORD(lp);
+            PopupMenu( p_intf, hwnd, point );
+        }
+        break;
+
     case WM_HELP:
         MessageBox (hwnd, _T("Help"), _T("Help"), MB_OK);
         break;
 
     case WM_CLOSE:
-        DestroyWindow( hwndCB );
+        if( hwndCB ) DestroyWindow( hwndCB );
         DestroyWindow( hwnd );
         break;
 
-    case WM_ENTERMENULOOP:
-    case WM_KILLFOCUS:
-        if( video && video->hWnd )
-            SendMessage( video->hWnd, WM_KILLFOCUS, 0, 0 );
-        break;
-
-    case WM_EXITMENULOOP:
-    case WM_SETFOCUS:
-        if( video && video->hWnd )
-            SendMessage( video->hWnd, WM_SETFOCUS, 0, 0 );
-        break;
-
     case WM_DESTROY:
         PostQuitMessage( 0 );
         break;
index 1a20607bea5635adb3cfe1d3800b552a76638602..bf35516489142653cad4bd82665a68f734413225 100644 (file)
@@ -82,7 +82,6 @@ void PopupMenu( intf_thread_t *p_intf, HWND p_parent, POINT point )
     vlc_object_t *p_object, *p_input;
     char *ppsz_varnames[MAX_POPUP_ITEMS];
     int pi_objects[MAX_POPUP_ITEMS];
-    vector<MenuItemExt*>::iterator iter;
     int i = 0, i_last_separator = 0;
 
     /* Initializations */
@@ -199,6 +198,8 @@ void PopupMenu( intf_thread_t *p_intf, HWND p_parent, POINT point )
     HMENU hmenu = CreatePopupMenu();
     RefreshMenu( p_intf, &popup_menu, hmenu, i,
                  ppsz_varnames, pi_objects, PopupMenu_Events );
+    MenuItemExt::ClearList( &popup_menu );
+
 
     /* Add static entries */
     if( p_input != NULL )
@@ -247,22 +248,17 @@ void RefreshAudioMenu( intf_thread_t *p_intf, HMENU hMenu )
     vlc_object_t *p_object;
     char *ppsz_varnames[MAX_AUDIO_ITEMS];
     int pi_objects[MAX_AUDIO_ITEMS];
-    vector<MenuItemExt*>::iterator iter;
     int i;
 
     /* Delete old menu */
     int count = wce_GetMenuItemCount( hMenu );
     for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
-        
+
     if( p_intf->p_sys->p_audio_menu )
-    {
-        for( iter = p_intf->p_sys->p_audio_menu->begin();
-             iter != p_intf->p_sys->p_audio_menu->end(); iter++ )
-            delete *iter;
-        p_intf->p_sys->p_audio_menu->clear();
-    }
+        MenuItemExt::ClearList( p_intf->p_sys->p_audio_menu );
     else p_intf->p_sys->p_audio_menu = new vector<MenuItemExt*>;
 
+
     /* Initializations */
     memset( pi_objects, 0, MAX_AUDIO_ITEMS * sizeof(int) );
     i = 0;
@@ -301,7 +297,6 @@ void RefreshVideoMenu( intf_thread_t *p_intf, HMENU hMenu )
     vlc_object_t *p_object;
     char *ppsz_varnames[MAX_VIDEO_ITEMS];
     int pi_objects[MAX_VIDEO_ITEMS];
-    vector<MenuItemExt*>::iterator iter;
     int i;
 
     /* Delete old menu */
@@ -309,12 +304,7 @@ void RefreshVideoMenu( intf_thread_t *p_intf, HMENU hMenu )
     for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
 
     if( p_intf->p_sys->p_video_menu )
-    {
-        for( iter = p_intf->p_sys->p_video_menu->begin();
-             iter != p_intf->p_sys->p_video_menu->end(); iter++ )
-            delete *iter;
-        p_intf->p_sys->p_video_menu->clear();
-    }
+        MenuItemExt::ClearList( p_intf->p_sys->p_video_menu );
     else p_intf->p_sys->p_video_menu = new vector<MenuItemExt*>;
 
     /* Initializations */
@@ -379,7 +369,6 @@ void RefreshNavigMenu( intf_thread_t *p_intf, HMENU hMenu )
     vlc_object_t *p_object;
     char *ppsz_varnames[MAX_NAVIG_ITEMS];
     int pi_objects[MAX_NAVIG_ITEMS];
-    vector<MenuItemExt*>::iterator iter;
     int i;
 
     /* Delete old menu */
@@ -387,12 +376,7 @@ void RefreshNavigMenu( intf_thread_t *p_intf, HMENU hMenu )
     for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
         
     if( p_intf->p_sys->p_navig_menu )
-    {
-        for( iter = p_intf->p_sys->p_navig_menu->begin();
-             iter != p_intf->p_sys->p_navig_menu->end(); iter++ )
-            delete *iter;
-        p_intf->p_sys->p_navig_menu->clear();
-    }
+        MenuItemExt::ClearList( p_intf->p_sys->p_navig_menu );
     else p_intf->p_sys->p_navig_menu = new vector<MenuItemExt*>;
 
     /* Initializations */
@@ -438,7 +422,6 @@ void RefreshSettingsMenu( intf_thread_t *p_intf, HMENU hMenu )
     vlc_object_t *p_object;
     char *ppsz_varnames[MAX_SETTINGS_ITEMS];
     int pi_objects[MAX_SETTINGS_ITEMS];
-    vector<MenuItemExt*>::iterator iter;
     int i;
 
     /* Delete old menu */
@@ -446,12 +429,7 @@ void RefreshSettingsMenu( intf_thread_t *p_intf, HMENU hMenu )
     for( i = 0; i <= count; i++ ) RemoveMenu( hMenu, 0, MF_BYPOSITION );
 
     if( p_intf->p_sys->p_settings_menu )
-    {
-        for( iter = p_intf->p_sys->p_settings_menu->begin();
-             iter != p_intf->p_sys->p_settings_menu->end(); iter++ )
-            delete(*iter);
-        p_intf->p_sys->p_settings_menu->clear();
-    }
+        MenuItemExt::ClearList( p_intf->p_sys->p_settings_menu );
     else p_intf->p_sys->p_settings_menu = new vector<MenuItemExt*>;
 
     /* Initializations */
@@ -479,7 +457,7 @@ void RefreshSettingsMenu( intf_thread_t *p_intf, HMENU hMenu )
 /*****************************************************************************
  * Refresh the menu.
  *****************************************************************************/
-void RefreshMenu( intf_thread_t *p_intf, vector<MenuItemExt*> *_p_menuList,
+void RefreshMenu( intf_thread_t *p_intf, vector<MenuItemExt*> *p_menu_list,
                   HMENU hMenu , int i_count, char **ppsz_varnames, 
                   int *pi_objects, int i_start_id )
 {
@@ -518,7 +496,7 @@ void RefreshMenu( intf_thread_t *p_intf, vector<MenuItemExt*> *_p_menuList,
         if( p_object == NULL ) continue;
 
         b_section_empty = VLC_FALSE;
-        CreateMenuItem( p_intf, _p_menuList, hMenu, ppsz_varnames[i],
+        CreateMenuItem( p_intf, p_menu_list, hMenu, ppsz_varnames[i],
                         p_object, &i_item_id );
         vlc_object_release( p_object );
     }
@@ -534,7 +512,7 @@ void RefreshMenu( intf_thread_t *p_intf, vector<MenuItemExt*> *_p_menuList,
 /*****************************************************************************
  * Private methods.
  *****************************************************************************/
-void CreateMenuItem( intf_thread_t *p_intf, vector<MenuItemExt*> *_p_menuList,
+void CreateMenuItem( intf_thread_t *p_intf, vector<MenuItemExt*> *p_menu_list,
                      HMENU hMenu, char *psz_var, vlc_object_t *p_object,
                      int *pi_item_id )
 {
@@ -576,10 +554,11 @@ void CreateMenuItem( intf_thread_t *p_intf, vector<MenuItemExt*> *_p_menuList,
 
     if( i_type & VLC_VAR_HASCHOICE )
     {
-        hMenuItem = CreateChoicesMenu( p_intf, _p_menuList, psz_var,
+        hMenuItem = CreateChoicesMenu( p_intf, p_menu_list, psz_var,
                                        p_object, pi_item_id );
         AppendMenu( hMenu, MF_STRING | MF_POPUP, (UINT)hMenuItem,
                     _FROMMB(text.psz_string ? text.psz_string : psz_var) );
+        if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
         if( text.psz_string ) free( text.psz_string );
         return;
     }
@@ -591,7 +570,7 @@ void CreateMenuItem( intf_thread_t *p_intf, vector<MenuItemExt*> *_p_menuList,
                     _FROMMB(text.psz_string ? text.psz_string : psz_var) );
         pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
                                         p_object->i_object_id, val, i_type );
-        _p_menuList->push_back( pMenuItemExt );
+        p_menu_list->push_back( pMenuItemExt );
         break;
 
     case VLC_VAR_BOOL:
@@ -600,7 +579,7 @@ void CreateMenuItem( intf_thread_t *p_intf, vector<MenuItemExt*> *_p_menuList,
                     _FROMMB(text.psz_string ? text.psz_string : psz_var) );
         pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
                                         p_object->i_object_id, val, i_type );
-        _p_menuList->push_back( pMenuItemExt );
+        p_menu_list->push_back( pMenuItemExt );
         CheckMenuItem( hMenu, *pi_item_id ,
                        ( val.b_bool ? MF_UNCHECKED : MF_CHECKED ) |
                        MF_BYCOMMAND ); 
@@ -616,7 +595,7 @@ void CreateMenuItem( intf_thread_t *p_intf, vector<MenuItemExt*> *_p_menuList,
 }
 
 HMENU CreateChoicesMenu( intf_thread_t *p_intf,
-                         vector<MenuItemExt*> *_p_menuList, char *psz_var, 
+                         vector<MenuItemExt*> *p_menu_list, char *psz_var, 
                          vlc_object_t *p_object, int *pi_item_id )
 {
     MenuItemExt *pMenuItemExt;
@@ -671,7 +650,7 @@ HMENU CreateChoicesMenu( intf_thread_t *p_intf,
         switch( i_type & VLC_VAR_TYPE )
         {
         case VLC_VAR_VARIABLE:
-            hMenuItem = CreateChoicesMenu( p_intf, _p_menuList,
+            hMenuItem = CreateChoicesMenu( p_intf, p_menu_list,
               val_list.p_list->p_values[i].psz_string, p_object, pi_item_id );
             AppendMenu( hSubMenu, MF_STRING | MF_POPUP, (UINT)hMenuItem,
                         _FROMMB(text_list.p_list->p_values[i].psz_string ?
@@ -688,7 +667,7 @@ HMENU CreateChoicesMenu( intf_thread_t *p_intf,
                           val_list.p_list->p_values[i].psz_string) );
             pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
                           p_object->i_object_id, another_val, i_type );
-            _p_menuList->push_back( pMenuItemExt );
+            p_menu_list->push_back( pMenuItemExt );
 
             if( !(i_type & VLC_VAR_ISCOMMAND) && val.psz_string &&
                 !strcmp( val.psz_string,
@@ -703,7 +682,7 @@ HMENU CreateChoicesMenu( intf_thread_t *p_intf,
                           text_list.p_list->p_values[i].psz_string : psz_tmp));
             pMenuItemExt = new MenuItemExt( p_intf, *pi_item_id, psz_var,
                 p_object->i_object_id, val_list.p_list->p_values[i], i_type );
-            _p_menuList->push_back( pMenuItemExt );
+            p_menu_list->push_back( pMenuItemExt );
 
             if( val_list.p_list->p_values[i].i_int == val.i_int )
               CheckMenuItem( hSubMenu, *pi_item_id, MF_CHECKED | MF_BYCOMMAND);
@@ -821,3 +800,15 @@ MenuItemExt::~MenuItemExt()
     if( ((i_val_type & VLC_VAR_TYPE) == VLC_VAR_STRING)
         && val.psz_string ) free( val.psz_string );
 };
+
+void MenuItemExt::ClearList( vector<MenuItemExt*> *p_menu_list )
+{
+    vector<MenuItemExt*>::iterator iter;
+
+    if( !p_menu_list ) return;
+    for( iter = p_menu_list->begin(); iter != p_menu_list->end(); iter++ )
+    {
+        delete *iter;
+    }
+    p_menu_list->clear();
+}
index 796b7fd4cda119ec05380ec5db9a188a907e5bc7..9437bba8e5558fcd603e9d2bb59fd23b8956c4b5 100644 (file)
@@ -82,6 +82,18 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf, HINSTANCE _hInst,
     i_current_access_method = _i_access_method;
     i_open_arg = _i_arg;
     i_method = _i_method;
+
+    for( int i = 0; i < 4; i++ )
+    {
+        net_radios[i] = 0;
+        net_label[i] = 0;
+        net_port_label[i] = 0;
+        net_ports[i] = 0;
+        hUpdown[i] = 0;
+        i_net_ports[i] = 0;
+        net_addrs_label[i] = 0;
+        net_addrs[i] = 0;
+    }
 }
 
 /***********************************************************************
index fe1b970d8ae5a0a775bce05a1471fec636ae145f..75c6473a49040cd86199d5f66d7594cb4da71d1e 100644 (file)
@@ -279,7 +279,7 @@ LRESULT Playlist::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
                                   BUTTONWIDTH, BUTTONHEIGHT,
                                   IMAGEWIDTH, IMAGEHEIGHT, sizeof(TBBUTTON) );
         if( !hwndTB ) break;
-
+  
         // Add ToolTips to the toolbar.
         SendMessage( hwndTB, TB_SETTOOLTIPS, (WPARAM) NUMIMAGES,
                      (LPARAM)szToolTips2 );
@@ -368,14 +368,14 @@ LRESULT Playlist::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
 
         case ID_MANAGE_ADDFILE:
             SHFullScreen( GetForegroundWindow(), SHFS_SHOWSIPBUTTON );
-            OnAddFile( VLC_FALSE );
+            OnAddFile();
             SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
             b_need_update = VLC_TRUE;
             break;
 
         case ID_MANAGE_ADDDIRECTORY:
             SHFullScreen( GetForegroundWindow(), SHFS_SHOWSIPBUTTON );
-            OnAddFile( VLC_TRUE );
+            OnAddFile();
             SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
             b_need_update = VLC_TRUE;
             break;
@@ -735,7 +735,7 @@ void Playlist::OnOpen()
     ofn.lpfnHook = NULL;
     ofn.lpTemplateName = NULL;
 
-    if( GetOpenFile( &ofn ) )
+    if( GetOpenFileName((LPOPENFILENAME)&ofn) )
     {
         playlist_Import( p_playlist, _TOMB(ofn.lpstrFile) );
     }
@@ -797,7 +797,7 @@ void Playlist::OnSave()
     }
 }
 
-void Playlist::OnAddFile( vlc_bool_t b_directory )
+void Playlist::OnAddFile()
 {
     // Same code as in Interface
     OPENFILENAME ofn;
@@ -828,7 +828,7 @@ void Playlist::OnAddFile( vlc_bool_t b_directory )
 
     SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
 
-    if( GetOpenFile&ofn ) )
+    if( GetOpenFileName( (LPOPENFILENAME)&ofn ) )
     {
         playlist_t *p_playlist = (playlist_t *)
            vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
index 708c2253665a583bb6b1e3e2b7676df5494f7b0d..048ae2fe2dfc7b5bc7fabb05126de25baf6eeafa 100644 (file)
@@ -87,7 +87,6 @@ private:
     PrefsDialog *p_prefs_dialog;
     vlc_bool_t b_advanced;
 
-    HTREEITEM root_item;
     HTREEITEM general_item;
     HTREEITEM plugins_item;
 };
@@ -251,10 +250,13 @@ LRESULT PrefsDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
         TVITEM tvi = {0};
         tvi.mask = TVIF_PARAM;
         tvi.hItem = TreeView_GetSelection( prefs_tree->hwndTV );
-        TreeView_GetItem( prefs_tree->hwndTV, &tvi );
+       if( !tvi.hItem ) break;
+
+        if( !TreeView_GetItem( prefs_tree->hwndTV, &tvi ) ) break;
+
         ConfigTreeData *config_data =
             prefs_tree->FindModuleConfig( (ConfigTreeData *)tvi.lParam );
-        if ( hwnd == config_data->panel->config_window ) 
+        if( config_data && hwnd == config_data->panel->config_window ) 
         {
             int dy;
             RECT rc;
@@ -349,17 +351,7 @@ PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
         5, 10 + 2*(15 + 10) + 105 + 5, rcClient.right - 5 - 5, 6*15,
         hwnd, NULL, hInst, NULL );
 
-    tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; 
-    tvi.pszText = _T("root");
-    tvi.cchTextMax = lstrlen(_T("root"));
-    tvi.lParam = (LPARAM) 1; // root level
-    tvins.item = tvi;
-    tvins.hInsertAfter = TVI_FIRST; 
-    tvins.hParent = TVI_ROOT; 
-
-    // Add the item to the tree-view control. 
-    hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins );
-    root_item = hPrev;
+    tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
 
     /* List the plugins */
     p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
@@ -374,10 +366,10 @@ PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
     config_data->psz_section = strdup( GENERAL_TITLE );
     tvi.pszText = _T("General settings");
     tvi.cchTextMax = lstrlen(_T("General settings"));
-    tvi.lParam = (long) config_data;
+    tvi.lParam = (long)config_data;
     tvins.item = tvi;
-    tvins.hInsertAfter = hPrev;
-    tvins.hParent = root_item; //level 2
+    tvins.hInsertAfter = TVI_FIRST;
+    tvins.hParent = TVI_ROOT;
 
     // Add the item to the tree-view control.
     hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);
@@ -444,10 +436,10 @@ PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
     config_data->psz_section = strdup("nothing");//strdup( PLUGIN_TITLE );
     tvi.pszText = _T("Modules");
     tvi.cchTextMax = lstrlen(_T("Modules"));
-    tvi.lParam = (long) config_data;
+    tvi.lParam = (long)config_data;
     tvins.item = tvi;
-    tvins.hInsertAfter = hPrev;
-    tvins.hParent = root_item;// level 2
+    tvins.hInsertAfter = TVI_LAST;
+    tvins.hParent = TVI_ROOT;
 
     // Add the item to the tree-view control.
     hPrev = (HTREEITEM) TreeView_InsertItem( hwndTV, &tvins);
@@ -513,7 +505,7 @@ PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
             config_data->i_object_id = CAPABILITY_ID;
             tvi.pszText = _FROMMB(p_module->psz_capability);
             tvi.cchTextMax = _tcslen(tvi.pszText);
-            tvi.lParam = (long) config_data;
+            tvi.lParam = (long)config_data;
             tvins.item = tvi;
             tvins.hInsertAfter = plugins_item; 
             tvins.hParent = plugins_item;// level 3
@@ -533,7 +525,7 @@ PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
         config_data->psz_help = NULL;
         tvi.pszText = _FROMMB(p_module->psz_object_name);
         tvi.cchTextMax = _tcslen(tvi.pszText);
-        tvi.lParam = (long) config_data;
+        tvi.lParam = (long)config_data;
         tvins.item = tvi;
         tvins.hInsertAfter = capability_item; 
         tvins.hParent = capability_item;// level 4
@@ -555,7 +547,6 @@ PrefsTreeCtrl::PrefsTreeCtrl( intf_thread_t *_p_intf,
     /* Clean-up everything */
     vlc_list_release( p_list );
 
-    TreeView_Expand( hwndTV, root_item, TVE_EXPANDPARTIAL |TVE_EXPAND );
     TreeView_Expand( hwndTV, general_item, TVE_EXPANDPARTIAL |TVE_EXPAND );
 }
 
@@ -727,11 +718,10 @@ PrefsPanel::PrefsPanel( HWND parent, HINSTANCE hInst, intf_thread_t *_p_intf,
         /* Find the category if it has been specified */
         if( psz_section && p_item->i_type == CONFIG_HINT_CATEGORY )
         {
-            while( !p_item->i_type == CONFIG_HINT_CATEGORY ||
+            while( !(p_item->i_type == CONFIG_HINT_CATEGORY) ||
                    strcmp( psz_section, p_item->psz_text ) )
             {
-                if( p_item->i_type == CONFIG_HINT_END )
-                    break;
+                if( p_item->i_type == CONFIG_HINT_END ) break;
                 p_item++;
             }
         }
index 730bb777983fd5bf9edc1bc493b8d10fd19db9a6..a0ac4ca72dec49b176948fefa6168801877cc226 100644 (file)
@@ -146,6 +146,15 @@ static void Close( vlc_object_t *p_this )
         vlc_object_release( p_intf->p_sys->p_input );
     }
 
+    MenuItemExt::ClearList( p_intf->p_sys->p_video_menu );
+    delete p_intf->p_sys->p_video_menu;
+    MenuItemExt::ClearList( p_intf->p_sys->p_audio_menu );
+    delete p_intf->p_sys->p_audio_menu;
+    MenuItemExt::ClearList( p_intf->p_sys->p_settings_menu );
+    delete p_intf->p_sys->p_settings_menu;
+    MenuItemExt::ClearList( p_intf->p_sys->p_navig_menu );
+    delete p_intf->p_sys->p_navig_menu;
+
     // Unsuscribe to messages bank
     msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
 
@@ -162,12 +171,12 @@ static void Close( vlc_object_t *p_this )
 static void Run( intf_thread_t *p_intf )
 {
     MSG msg;
-    Interface *pInterface = new Interface();
-    p_intf->p_sys->p_main_window = pInterface;
+    Interface interface;
 
+    p_intf->p_sys->p_main_window = &interface;
     if( !hInstance ) hInstance = GetModuleHandle(NULL);
 
-    if( !pInterface->InitInstance( hInstance, p_intf ) ) return;
+    if( !interface.InitInstance( hInstance, p_intf ) ) return;
 
     // Main message loop
     while( GetMessage( &msg, NULL, 0, 0 ) > 0 )
index 2e54cfd9a62cdc5d1a5ff7548b8c4e84e2f30747..098e7be0ed1d0588be7143f9d792488d3621d2bf 100644 (file)
@@ -134,11 +134,12 @@ class Interface : public CBaseWindow
 {
 public:
     /* Constructor */
-    Interface(){}
-    ~Interface(){}
+    Interface();
+    ~Interface();
 
     BOOL InitInstance( HINSTANCE, intf_thread_t * );
 
+    HWND CreateMenuBar( HWND, HINSTANCE );
     void TogglePlayButton( int i_playing_status );
 
     HWND hwndMain;      // Handle to the main window.
@@ -151,11 +152,12 @@ public:
     HWND hwndSB;        // Handle to the status bar.
     HMENU hPopUpMenu;
     HMENU hMenu;
-    FileInfo *fi; // pas besoin de la plupart de ses attributs
-    Messages *hmsg;
-    PrefsDialog *pref;
-    Playlist *pl;
-    Timer *ti;
+
+    FileInfo *fileinfo;
+    Messages *messages;
+    PrefsDialog *preferences;
+    Playlist *playlist;
+    Timer *timer;
     OpenDialog *open;
     CBaseWindow *video;
 
@@ -177,6 +179,12 @@ protected:
     void OnFastStream( void );
 
     int i_old_playing_status;
+
+private:
+    HMENU menu_settings;
+    HMENU menu_video;
+    HMENU menu_audio;
+    HMENU menu_navigation;
 };
 
 /* File Info */
@@ -384,7 +392,7 @@ protected:
 
     void OnOpen();
     void OnSave();
-    void OnAddFile( vlc_bool_t );
+    void OnAddFile();
     void OnAddMRL();
 
     void OnDeleteSelection();
@@ -457,6 +465,8 @@ public:
 
     virtual ~MenuItemExt();
 
+    static void ClearList( vector<MenuItemExt*> * );
+
     int id;
     intf_thread_t *p_intf;
     char *psz_var;
index 9d4189a73a0e29e451613a77c05fb04c15347fd1..b8262b16accbdc9d46f06ac8e3582f57855a68a8 100644 (file)
 #define _WIN32_WCE UNDER_CE\r
 #endif\r
 \r
-#if defined(_WIN32_WCE)\r
-    #define _WIN32_IE 0x0500\r
-    #include <commctrl.h>\r
-#endif // _WIN32_WCE\r
+#define _WIN32_IE 0x0501\r
+#include <commctrl.h>\r
 \r
 #ifdef RC_INVOKED\r
 #ifndef _INC_WINDOWS\r
@@ -28,6 +26,7 @@
 // Menubar\r
 //\r
 \r
+#if defined(UNDER_CE) // Menus are dynamically built on Win32\r
 IDR_MENUBAR MENU DISCARDABLE \r
 BEGIN\r
     POPUP "File"\r
@@ -71,7 +70,7 @@ BEGIN
         MENUITEM "Empty",                       ID_EMPTY, GRAYED\r
     END\r
 END\r
-\r
+#endif\r
 \r
 /////////////////////////////////////////////////////////////////////////////\r
 //\r