Context menu is now created from a resource. Exit olsrd before shutting
authorThomas Lopatic <thomas@lopatic.de>
Mon, 14 Feb 2005 20:39:30 +0000 (20:39 +0000)
committerThomas Lopatic <thomas@lopatic.de>
Mon, 14 Feb 2005 20:39:30 +0000 (20:39 +0000)
down the GUI via the context menu.

gui/win32/Frontend.ncb
gui/win32/Frontend.opt
gui/win32/Inst/installer.nsi
gui/win32/Main/Frontend.clw
gui/win32/Main/Frontend.dsp
gui/win32/Main/Frontend.rc
gui/win32/Main/MyTabCtrl.h
gui/win32/Main/TrayIcon.cpp
gui/win32/Main/resource.h

index 90aa940..b5e5134 100644 (file)
Binary files a/gui/win32/Frontend.ncb and b/gui/win32/Frontend.ncb differ
index 3834301..162c49c 100644 (file)
Binary files a/gui/win32/Frontend.opt and b/gui/win32/Frontend.opt differ
index 1b4c736..645bb9b 100644 (file)
@@ -36,7 +36,7 @@
 ;  to the project. For more information see the website or contact
 ;  the copyright holders.
 ;
-;  $Id: installer.nsi,v 1.10 2004/12/06 12:20:53 tlopatic Exp $
+;  $Id: installer.nsi,v 1.11 2005/02/14 20:39:29 tlopatic Exp $
 ;
 
 Name olsr.org
@@ -55,7 +55,7 @@ UninstPage uninstConfirm
 UninstPage instfiles
 
 Function .onInit
-        MessageBox MB_YESNO "This will install olsr.org 0.4.8 on your computer. Continue?" IDYES NoAbort
+        MessageBox MB_YESNO "This will install olsr.org 0.4.9 on your computer. Continue?" IDYES NoAbort
         Abort
 NoAbort:
 FunctionEnd
index 0e8fec3..3214bcd 100644 (file)
@@ -18,12 +18,13 @@ Class6=MyDialog4
 Class7=MyEdit\r
 Class8=MyTabCtrl\r
 \r
-ResourceCount=5\r
-Resource1=IDD_DIALOG1\r
-Resource2=IDD_DIALOG2\r
-Resource3=IDD_DIALOG3\r
-Resource4=IDD_FRONTEND_DIALOG\r
-Resource5=IDD_DIALOG4\r
+ResourceCount=6\r
+Resource1=IDD_DIALOG3\r
+Resource2=IDD_DIALOG4\r
+Resource3=IDD_FRONTEND_DIALOG\r
+Resource4=IDD_DIALOG2\r
+Resource5=IDD_DIALOG1\r
+Resource6=IDR_TRAYMENU\r
 \r
 [CLS:CFrontendApp]\r
 Type=0\r
@@ -174,3 +175,14 @@ ControlCount=2
 Control1=IDC_LIST1,SysListView32,1350631425\r
 Control2=IDC_STATIC,static,1342308352\r
 \r
+[MNU:IDR_TRAYMENU]\r
+Type=1\r
+Class=?\r
+Command1=IDM_START\r
+Command2=IDM_STOP\r
+Command3=IDM_WINDOW\r
+Command4=IDM_SETTINGS\r
+Command5=IDM_OUTPUT\r
+Command6=IDM_EXIT\r
+CommandCount=6\r
+\r
index 89f04f7..493df1a 100644 (file)
@@ -235,6 +235,14 @@ SOURCE=.\res\Frontend.ico
 \r
 SOURCE=.\res\Frontend.rc2\r
 # End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\res\Tray1.ico\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\res\Tray2.ico\r
+# End Source File\r
 # End Group\r
 # Begin Source File\r
 \r
index 37dc3a3..4da688b 100644 (file)
@@ -1,4 +1,4 @@
-// Microsoft Visual C++ generated resource script.\r
+//Microsoft Developer Studio generated resource script.\r
 //\r
 #include "resource.h"\r
 \r
@@ -13,7 +13,7 @@
 #undef APSTUDIO_READONLY_SYMBOLS\r
 \r
 /////////////////////////////////////////////////////////////////////////////\r
-// Englisch (USA) resources\r
+// English (U.S.) resources\r
 \r
 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r
 #ifdef _WIN32\r
@@ -27,18 +27,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
 // TEXTINCLUDE\r
 //\r
 \r
-1 TEXTINCLUDE \r
+1 TEXTINCLUDE MOVEABLE PURE \r
 BEGIN\r
     "resource.h\0"\r
 END\r
 \r
-2 TEXTINCLUDE \r
+2 TEXTINCLUDE MOVEABLE PURE \r
 BEGIN\r
     "#include ""afxres.h""\r\n"\r
     "\0"\r
 END\r
 \r
-3 TEXTINCLUDE \r
+3 TEXTINCLUDE MOVEABLE PURE \r
 BEGIN\r
     "#define _AFX_NO_SPLITTER_RESOURCES\r\n"\r
     "#define _AFX_NO_OLE_RESOURCES\r\n"\r
@@ -65,10 +65,10 @@ END
 //\r
 \r
 IDD_FRONTEND_DIALOG DIALOGEX 0, 0, 399, 289\r
-STYLE DS_SETFONT | DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | \r
-    WS_CAPTION | WS_SYSMENU\r
+STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | \r
+    WS_SYSMENU\r
 EXSTYLE WS_EX_APPWINDOW\r
-CAPTION "olsr.org Switch 0.4.8"\r
+CAPTION "olsr.org Switch 0.4.9"\r
 FONT 8, "MS Sans Serif", 0, 0, 0x1\r
 BEGIN\r
     CONTROL         "Tab1",IDC_TAB1,"SysTabControl32",0x0,7,7,383,256\r
@@ -77,8 +77,8 @@ BEGIN
     PUSHBUTTON      "Exit",IDC_BUTTON3,340,268,50,14\r
 END\r
 \r
-IDD_DIALOG1 DIALOG  0, 0, 377, 240\r
-STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE\r
+IDD_DIALOG1 DIALOG DISCARDABLE  0, 0, 377, 240\r
+STYLE WS_CHILD | WS_VISIBLE\r
 FONT 8, "MS Sans Serif"\r
 BEGIN\r
     EDITTEXT        IDC_EDIT1,7,25,363,208,ES_MULTILINE | ES_READONLY | \r
@@ -89,8 +89,8 @@ BEGIN
     PUSHBUTTON      "Clear",IDC_BUTTON1,320,7,50,14\r
 END\r
 \r
-IDD_DIALOG2 DIALOG  0, 0, 377, 240\r
-STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE\r
+IDD_DIALOG2 DIALOG DISCARDABLE  0, 0, 377, 240\r
+STYLE WS_CHILD | WS_VISIBLE\r
 FONT 8, "MS Sans Serif"\r
 BEGIN\r
     CONTROL         "List1",IDC_LIST1,"SysListView32",LVS_LIST | WS_BORDER | \r
@@ -153,8 +153,8 @@ BEGIN
     RTEXT           "Window size:",IDC_STATIC,251,171,43,8\r
 END\r
 \r
-IDD_DIALOG3 DIALOG  0, 0, 377, 240\r
-STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE\r
+IDD_DIALOG3 DIALOG DISCARDABLE  0, 0, 377, 240\r
+STYLE WS_CHILD | WS_VISIBLE\r
 FONT 8, "MS Sans Serif"\r
 BEGIN\r
     CONTROL         "List1",IDC_LIST1,"SysListView32",LVS_REPORT | \r
@@ -169,8 +169,8 @@ BEGIN
     LTEXT           "Node information",IDC_STATIC,257,7,59,8\r
 END\r
 \r
-IDD_DIALOG4 DIALOG  0, 0, 377, 240\r
-STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE\r
+IDD_DIALOG4 DIALOG DISCARDABLE  0, 0, 377, 240\r
+STYLE WS_CHILD | WS_VISIBLE\r
 FONT 8, "MS Sans Serif"\r
 BEGIN\r
     CONTROL         "List1",IDC_LIST1,"SysListView32",LVS_REPORT | WS_BORDER | \r
@@ -185,7 +185,7 @@ END
 //\r
 \r
 #ifdef APSTUDIO_INVOKED\r
-GUIDELINES DESIGNINFO \r
+GUIDELINES DESIGNINFO MOVEABLE PURE \r
 BEGIN\r
     IDD_FRONTEND_DIALOG, DIALOG\r
     BEGIN\r
@@ -237,17 +237,39 @@ END
 \r
 // Icon with lowest ID value placed first to ensure application icon\r
 // remains consistent on all systems.\r
-IDI_ICON1               ICON                    "res\\Frontend.ico"\r
-IDI_ICON3               ICON                    "res\\Tray2.ico"\r
-IDI_ICON2               ICON                    "res\\Tray1.ico"\r
+IDI_ICON1               ICON    DISCARDABLE     "res\\Frontend.ico"\r
+IDI_ICON3               ICON    DISCARDABLE     "res\\Tray2.ico"\r
+IDI_ICON2               ICON    DISCARDABLE     "res\\Tray1.ico"\r
 \r
 /////////////////////////////////////////////////////////////////////////////\r
 //\r
 // RT_MANIFEST\r
 //\r
 \r
-IDR_241                 RT_MANIFEST             "Switch.exe.manifest"\r
-#endif    // Englisch (USA) resources\r
+IDR_241                 RT_MANIFEST MOVEABLE PURE "Switch.exe.manifest"\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Menu\r
+//\r
+\r
+IDR_TRAYMENU MENU DISCARDABLE \r
+BEGIN\r
+    POPUP "IDR_TRAYMENU"\r
+    BEGIN\r
+        MENUITEM "Start",                       IDM_START\r
+        MENUITEM "Stop",                        IDM_STOP\r
+        POPUP "Show"\r
+        BEGIN\r
+            MENUITEM "Window",                      IDM_WINDOW\r
+            MENUITEM "Settings",                    IDM_SETTINGS\r
+            MENUITEM "Output",                      IDM_OUTPUT\r
+        END\r
+        MENUITEM "Exit",                        IDM_EXIT\r
+    END\r
+END\r
+\r
+#endif    // English (U.S.) resources\r
 /////////////////////////////////////////////////////////////////////////////\r
 \r
 \r
index d45d348..5105851 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact\r
  * the copyright holders.\r
  *\r
- * $Id: MyTabCtrl.h,v 1.4 2004/11/21 01:21:10 tlopatic Exp $\r
+ * $Id: MyTabCtrl.h,v 1.5 2005/02/14 20:39:30 tlopatic Exp $\r
  */\r
 \r
 #if !defined(AFX_MYTABCTRL_H__D443FF52_C52D_4C89_AB4B_19B09687EBAE__INCLUDED_)\r
@@ -71,6 +71,7 @@ public:
 \r
 protected:\r
        CDialog *Dialogs[4];\r
+\r
        int Sel;\r
 \r
        //{{AFX_MSG(MyTabCtrl)\r
index 149a808..5f36ced 100755 (executable)
@@ -17,76 +17,67 @@ LRESULT CALLBACK TrayIconProc( HWND, UINT, WPARAM, LPARAM lParam )
 {\r
        switch (lParam)\r
        {\r
-               case WM_LBUTTONDOWN:\r
-               case WM_RBUTTONDOWN:\r
-                       TrayIcon::instance->displayPopup();\r
-                       break;\r
+       case WM_LBUTTONDOWN:\r
+       case WM_RBUTTONDOWN:\r
+               TrayIcon::instance->displayPopup();\r
+               break;\r
        }\r
-\r
+       \r
        return 1;\r
 }\r
 \r
 void TrayIcon::displayPopup()\r
 {\r
        HMENU hMenu = CreatePopupMenu();\r
-\r
-       MENUITEMINFO item;\r
-       memset(&item, 0, sizeof(MENUITEMINFO));\r
-       item.cbSize = sizeof(MENUITEMINFO);\r
-       item.fMask = MIIM_TYPE | MIIM_ID;\r
-       item.fType = MFT_STRING;\r
-\r
-       item.wID = 1;\r
-       item.dwTypeData = "&Start";\r
-       InsertMenuItem(hMenu, 1, TRUE, &item);\r
-\r
-       item.wID = 2;\r
-       item.dwTypeData = "&Stop";\r
-       InsertMenuItem(hMenu, 2, TRUE, &item);\r
-\r
-       item.wID = 3;\r
-       item.dwTypeData = "&Configure";\r
-       InsertMenuItem(hMenu, 3, TRUE, &item);\r
-\r
-       item.wID = 4;\r
-       item.dwTypeData = "&Exit";\r
-       InsertMenuItem(hMenu, 4, TRUE, &item);\r
-\r
+       hMenu = LoadMenu(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_TRAYMENU));\r
+       \r
        POINT pt;\r
-\r
+       \r
        GetCursorPos(&pt);\r
-\r
+       \r
        SetForegroundWindow( s_hWnd );\r
-\r
-       int cmd = TrackPopupMenu(hMenu, \r
-                       TPM_RIGHTBUTTON | TPM_RETURNCMD, \r
-                       pt.x, \r
-                       pt.y, \r
-                       0, \r
-                       s_hWnd, \r
-                       NULL);\r
-\r
-   PostMessage(s_hWnd, WM_NULL, 0, 0); \r
-\r
+       \r
+       int cmd = TrackPopupMenu(GetSubMenu(hMenu, 0),\r
+               TPM_RIGHTBUTTON | TPM_RETURNCMD, \r
+               pt.x, \r
+               pt.y, \r
+               0, \r
+               s_hWnd, \r
+               NULL);\r
+       \r
+       PostMessage(s_hWnd, WM_NULL, 0, 0); \r
+       \r
        switch(cmd)\r
        {\r
-               case 4:\r
-                       PostQuitMessage(0);\r
-                       break;\r
-       \r
-               case 3:\r
-                       main_dlg.OpenIcon();\r
-                       break;\r
-\r
-               case 2:\r
-                       main_dlg.OnStopButton();\r
-                       break;\r
-\r
-               case 1:\r
-                       main_dlg.OnStartButton();\r
-                       break;\r
+       case IDM_EXIT:\r
+               main_dlg.OnExitButton();\r
+               break;\r
+               \r
+       case IDM_WINDOW:\r
+               main_dlg.OpenIcon();\r
+               break;\r
+\r
+       case IDM_SETTINGS:\r
+               main_dlg.m_TabCtrl.SetCurSel(0);\r
+               main_dlg.m_TabCtrl.DisplayTabDialog();\r
+               main_dlg.OpenIcon();\r
+               break;\r
+               \r
+       case IDM_OUTPUT:\r
+               main_dlg.m_TabCtrl.SetCurSel(1);\r
+               main_dlg.m_TabCtrl.DisplayTabDialog();\r
+               main_dlg.OpenIcon();\r
+               break;\r
+               \r
+       case IDM_STOP:\r
+               main_dlg.OnStopButton();\r
+               break;\r
+               \r
+       case IDM_START:\r
+               main_dlg.OnStartButton();\r
+               break;\r
        }\r
-\r
+       \r
        DestroyMenu(hMenu);\r
 }\r
 \r
@@ -94,33 +85,33 @@ void TrayIcon::setStatus( status con_stat, const char* message )
 {\r
        switch( con_stat )\r
        {\r
-               case CONNECTED:\r
-                       setTrayAppearance( false, IDI_ICON2, message );\r
-                       break;\r
-\r
-               case OFF:\r
-                       setTrayAppearance( false, IDI_ICON3, message );\r
-                       break;\r
-\r
-               case ON:\r
-                       setTrayAppearance( false, IDI_ICON1, message );\r
-                       break;\r
+       case CONNECTED:\r
+               setTrayAppearance( false, IDI_ICON2, message );\r
+               break;\r
+               \r
+       case OFF:\r
+               setTrayAppearance( false, IDI_ICON3, message );\r
+               break;\r
+               \r
+       case ON:\r
+               setTrayAppearance( false, IDI_ICON1, message );\r
+               break;\r
        }\r
 }\r
 \r
 void TrayIcon::setTrayAppearance( bool start, unsigned int res_id, const char* message )\r
 {\r
        NOTIFYICONDATA notifyIconData;\r
-\r
+       \r
        notifyIconData.cbSize = sizeof(notifyIconData);\r
        notifyIconData.hWnd = s_hWnd;\r
-\r
+       \r
        notifyIconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;\r
        notifyIconData.uCallbackMessage = 123456;\r
        notifyIconData.uID = TRAYICONID; \r
        notifyIconData.hIcon = (HICON)LoadIcon( hInst, MAKEINTRESOURCE( res_id ) );  \r
        strcpy( notifyIconData.szTip, message ); \r
-\r
+       \r
        if( start )\r
                Shell_NotifyIcon( NIM_ADD, &notifyIconData );\r
        else\r
@@ -131,7 +122,7 @@ TrayIcon::TrayIcon( CFrontendDlg& dlg, HINSTANCE hInst ) : main_dlg( dlg ), hIns
 {\r
        instance = this;\r
        WNDCLASS wndClass;\r
-\r
+       \r
        wndClass.style = 0; \r
        wndClass.lpfnWndProc = TrayIconProc;\r
        wndClass.cbClsExtra = 0;\r
@@ -142,44 +133,44 @@ TrayIcon::TrayIcon( CFrontendDlg& dlg, HINSTANCE hInst ) : main_dlg( dlg ), hIns
        wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);\r
        wndClass.lpszMenuName = NULL;\r
        wndClass.lpszClassName = "OLSRdTrayIcon";\r
-\r
-   if (0 != RegisterClass(&wndClass))\r
-   {\r
-      s_hWnd = CreateWindow( \r
-                "OLSRdTrayIcon", \r
-         "Invisible Message Window", \r
-         WS_OVERLAPPEDWINDOW,\r
-         CW_USEDEFAULT,\r
-         CW_USEDEFAULT,\r
-         CW_USEDEFAULT,\r
-         CW_USEDEFAULT,\r
-         NULL,\r
-         NULL,\r
-         hInst,\r
-         NULL);\r
-\r
-      if (s_hWnd)\r
-      {\r
-         ShowWindow(s_hWnd, SW_HIDE);\r
-         \r
-         UpdateWindow(s_hWnd);\r
-      }\r
-   }\r
-\r
-   setTrayAppearance( true, IDI_ICON3, "Starting..." );\r
+       \r
+       if (0 != RegisterClass(&wndClass))\r
+       {\r
+               s_hWnd = CreateWindow( \r
+                       "OLSRdTrayIcon", \r
+                       "Invisible Message Window", \r
+                       WS_OVERLAPPEDWINDOW,\r
+                       CW_USEDEFAULT,\r
+                       CW_USEDEFAULT,\r
+                       CW_USEDEFAULT,\r
+                       CW_USEDEFAULT,\r
+                       NULL,\r
+                       NULL,\r
+                       hInst,\r
+                       NULL);\r
+               \r
+               if (s_hWnd)\r
+               {\r
+                       ShowWindow(s_hWnd, SW_HIDE);\r
+                       \r
+                       UpdateWindow(s_hWnd);\r
+               }\r
+       }\r
+       \r
+       setTrayAppearance( true, IDI_ICON3, "Starting..." );\r
 }\r
 \r
 TrayIcon::~TrayIcon()\r
 {\r
        NOTIFYICONDATA notifyIconData;\r
-\r
+       \r
        notifyIconData.cbSize = sizeof(notifyIconData);\r
        notifyIconData.hWnd = s_hWnd;\r
-\r
+       \r
        notifyIconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;\r
        notifyIconData.uCallbackMessage = 123456;\r
        notifyIconData.uID = TRAYICONID; \r
        notifyIconData.hIcon = NULL;\r
-\r
+       \r
        Shell_NotifyIcon( NIM_DELETE, &notifyIconData );\r
 }\r
index 0ef9b2b..6729fa2 100644 (file)
@@ -1,5 +1,5 @@
 //{{NO_DEPENDENCIES}}\r
-// Microsoft Visual C++ generated include file.\r
+// Microsoft Developer Studio generated include file.\r
 // Used by Frontend.rc\r
 //\r
 #define IDD_FRONTEND_DIALOG             102\r
@@ -12,6 +12,7 @@
 #define IDI_ICON1                       132\r
 #define IDR_241                         138\r
 #define IDI_ICON3                       141\r
+#define IDR_TRAYMENU                    141\r
 #define IDI_ICON2                       142\r
 #define IDC_TAB1                        1000\r
 #define IDC_BUTTON1                     1001\r
 #define IDC_LIST6                       1027\r
 #define IDC_RADIO1                      1029\r
 #define IDC_RADIO2                      1030\r
+#define IDM_START                       32773\r
+#define IDM_STOP                        32774\r
+#define IDM_WINDOW                      32775\r
+#define IDM_SETTINGS                    32776\r
+#define IDM_OUTPUT                      32777\r
+#define IDM_EXIT                        32778\r
 \r
 // Next default values for new objects\r
 // \r
 #ifdef APSTUDIO_INVOKED\r
 #ifndef APSTUDIO_READONLY_SYMBOLS\r
-#define _APS_NEXT_RESOURCE_VALUE        141\r
-#define _APS_NEXT_COMMAND_VALUE         32771\r
+#define _APS_NEXT_RESOURCE_VALUE        142\r
+#define _APS_NEXT_COMMAND_VALUE         32779\r
 #define _APS_NEXT_CONTROL_VALUE         1030\r
 #define _APS_NEXT_SYMED_VALUE           101\r
 #endif\r