regedit: Fix some references to TCHARs.
[wine] / programs / winecfg / main.c
index d1eb36a..e363bb7 100644 (file)
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  *
  */
 
-#include "config.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+#define WIN32_LEAN_AND_MEAN
 
 #define NONAMELESSUNION
 #define NONAMELESSSTRUCT
 
-#include <windef.h>
-#include <winbase.h>
-#include <winuser.h>
+#include <windows.h>
 #include <commctrl.h>
+#include <objbase.h>
 #include <wine/debug.h>
 
-#include "properties.h"
 #include "resource.h"
 #include "winecfg.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
 
-void CALLBACK
+static INT CALLBACK
 PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
 {
     switch (uMsg)
@@ -62,49 +53,89 @@ PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
     default:
        break;
     }
+    return 0;
 }
 
-INT_PTR CALLBACK
+static INT_PTR CALLBACK
 AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
+    char *owner, *org;
+
     switch (uMsg) {
 
        case WM_NOTIFY:
-           if (((LPNMHDR)lParam)->code != PSN_SETACTIVE) break;
-           /* otherwise fall through, we want to refresh the page as well */
-       case WM_INITDIALOG:
-           break;
+           switch(((LPNMHDR)lParam)->code)
+           {
+            case PSN_APPLY:
+                /*save registration info to registry */
+                owner = get_text(hDlg, IDC_ABT_OWNER);
+                org   = get_text(hDlg, IDC_ABT_ORG);
+
+                set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
+                            "RegisteredOwner", owner ? owner : "");
+                set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
+                            "RegisteredOrganization", org ? org : "");
+                set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
+                            "RegisteredOwner", owner ? owner : "");
+                set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
+                            "RegisteredOrganization", org ? org : "");
+                apply();
+
+                HeapFree(GetProcessHeap(), 0, owner);
+                HeapFree(GetProcessHeap(), 0, org);
+                break;
+            }
+            break;
+
+        case WM_INITDIALOG:
+            /* read owner and organization info from registry, load it into text box */
+            owner = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
+                                "RegisteredOwner", "");
+            org =   get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
+                                "RegisteredOrganization", "");
+
+            SetDlgItemText(hDlg, IDC_ABT_OWNER, owner);
+            SetDlgItemText(hDlg, IDC_ABT_ORG, org);
+
+            SendMessage(GetParent(hDlg), PSM_UNCHANGED, 0, 0);
+
+            HeapFree(GetProcessHeap(), 0, owner);
+            HeapFree(GetProcessHeap(), 0, org);
+            break;
 
        case WM_COMMAND:
-           break;
-           
-       default:
-           break;
-           
+            switch(HIWORD(wParam))
+            {
+            case EN_CHANGE:
+               /* enable apply button */
+                SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
+                break;
+            }
+            break;
     }
     return FALSE;
 }
 
-#define NUM_PROPERTY_PAGES 6
+#define NUM_PROPERTY_PAGES 7
 
-INT_PTR
+static INT_PTR
 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
 {
-    PROPSHEETPAGE psp[NUM_PROPERTY_PAGES];
-    PROPSHEETHEADER psh;
+    PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES];
+    PROPSHEETHEADERW psh;
     int pg = 0; /* start with page 0 */
 
     /*
      * Fill out the (Applications) PROPSHEETPAGE data structure 
      * for the property sheet
      */
-    psp[pg].dwSize = sizeof (PROPSHEETPAGE);
+    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
     psp[pg].dwFlags = PSP_USETITLE;
     psp[pg].hInstance = hInstance;
-    psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_APPCFG);
+    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_APPCFG);
     psp[pg].u2.pszIcon = NULL;
     psp[pg].pfnDlgProc = AppDlgProc;
-    psp[pg].pszTitle = "Applications";
+    psp[pg].pszTitle = load_string (IDS_TAB_APPLICATIONS);
     psp[pg].lParam = 0;
     pg++;
 
@@ -112,13 +143,13 @@ doPropertySheet (HINSTANCE hInstance, HWND hOwner)
      * Fill out the (Libraries) PROPSHEETPAGE data structure 
      * for the property sheet
      */
-    psp[pg].dwSize = sizeof (PROPSHEETPAGE);
+    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
     psp[pg].dwFlags = PSP_USETITLE;
     psp[pg].hInstance = hInstance;
-    psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_DLLCFG);
+    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DLLCFG);
     psp[pg].u2.pszIcon = NULL;
     psp[pg].pfnDlgProc = LibrariesDlgProc;
-    psp[pg].pszTitle = "Libraries";
+    psp[pg].pszTitle = load_string (IDS_TAB_DLLS);
     psp[pg].lParam = 0;
     pg++;
     
@@ -126,33 +157,43 @@ doPropertySheet (HINSTANCE hInstance, HWND hOwner)
      * Fill out the (X11Drv) PROPSHEETPAGE data structure 
      * for the property sheet
      */
-    psp[pg].dwSize = sizeof (PROPSHEETPAGE);
+    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
     psp[pg].dwFlags = PSP_USETITLE;
     psp[pg].hInstance = hInstance;
-    psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_GRAPHCFG);
+    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_GRAPHCFG);
     psp[pg].u2.pszIcon = NULL;
     psp[pg].pfnDlgProc = GraphDlgProc;
-    psp[pg].pszTitle = "Graphics";
+    psp[pg].pszTitle =  load_string (IDS_TAB_GRAPHICS);
     psp[pg].lParam = 0;
     pg++;
 
-    psp[pg].dwSize = sizeof (PROPSHEETPAGE);
+    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
     psp[pg].dwFlags = PSP_USETITLE;
     psp[pg].hInstance = hInstance;
-    psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_DRIVECFG);
+    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DESKTOP_INTEGRATION);
+    psp[pg].u2.pszIcon = NULL;
+    psp[pg].pfnDlgProc = ThemeDlgProc;
+    psp[pg].pszTitle =  load_string (IDS_TAB_DESKTOP_INTEGRATION);
+    psp[pg].lParam = 0;
+    pg++;
+
+    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
+    psp[pg].dwFlags = PSP_USETITLE;
+    psp[pg].hInstance = hInstance;
+    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DRIVECFG);
     psp[pg].u2.pszIcon = NULL;
     psp[pg].pfnDlgProc = DriveDlgProc;
-    psp[pg].pszTitle = "Drives";
+    psp[pg].pszTitle =  load_string (IDS_TAB_DRIVES);
     psp[pg].lParam = 0;
     pg++;
 
-    psp[pg].dwSize = sizeof (PROPSHEETPAGE);
+    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
     psp[pg].dwFlags = PSP_USETITLE;
     psp[pg].hInstance = hInstance;
-    psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_AUDIOCFG);
+    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_AUDIOCFG);
     psp[pg].u2.pszIcon = NULL;
     psp[pg].pfnDlgProc = AudioDlgProc;
-    psp[pg].pszTitle = "Audio";
+    psp[pg].pszTitle =  load_string (IDS_TAB_AUDIO);
     psp[pg].lParam = 0;
     pg++;
 
@@ -160,34 +201,34 @@ doPropertySheet (HINSTANCE hInstance, HWND hOwner)
      * Fill out the (General) PROPSHEETPAGE data structure 
      * for the property sheet
      */
-    psp[pg].dwSize = sizeof (PROPSHEETPAGE);
+    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
     psp[pg].dwFlags = PSP_USETITLE;
     psp[pg].hInstance = hInstance;
-    psp[pg].u.pszTemplate = MAKEINTRESOURCE (IDD_ABOUTCFG);
+    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_ABOUTCFG);
     psp[pg].u2.pszIcon = NULL;
     psp[pg].pfnDlgProc = AboutDlgProc;
-    psp[pg].pszTitle = "About";
+    psp[pg].pszTitle =  load_string (IDS_TAB_ABOUT);
     psp[pg].lParam = 0;
     pg++;
 
     /*
      * Fill out the PROPSHEETHEADER
      */
-    psh.dwSize = sizeof (PROPSHEETHEADER);
+    psh.dwSize = sizeof (PROPSHEETHEADERW);
     psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
     psh.hwndParent = hOwner;
     psh.hInstance = hInstance;
     psh.u.pszIcon = NULL;
-    psh.pszCaption = "Wine Configuration";
+    psh.pszCaption =  load_string (IDS_WINECFG_TITLE);
     psh.nPages = NUM_PROPERTY_PAGES;
-    psh.u3.ppsp = (LPCPROPSHEETPAGE) & psp;
-    psh.pfnCallback = (PFNPROPSHEETCALLBACK) PropSheetCallback;
+    psh.u3.ppsp = psp;
+    psh.pfnCallback = PropSheetCallback;
     psh.u2.nStartPage = 0;
 
     /*
      * Display the modal property sheet
      */
-    return PropertySheet (&psh);
+    return PropertySheetW (&psh);
 }
 
 /******************************************************************************
@@ -201,7 +242,7 @@ doPropertySheet (HINSTANCE hInstance, HWND hOwner)
  *              no option at all. Has to be reworked, if more options are to
  *              be supported.
  */
-BOOL
+static BOOL
 ProcessCmdLine(LPSTR lpCmdLine)
 {
     if ((lpCmdLine[0] == '/' || lpCmdLine[0] == '-') && 
@@ -232,32 +273,24 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
     if (ProcessCmdLine(szCmdLine)) {
         return 0;
     }
-        
-    /* Until winecfg is fully functional, warn users that it is incomplete and doesn't do anything */
-    if (!getenv("WINECFG_NOWARN")) {
-        WINE_FIXME("The winecfg tool is not yet complete, and does not actually alter your configuration.\n");
-        WINE_FIXME("If you want to alter the way Wine works, look in the ~/.wine/config file for more information.\n");
-        MessageBoxA(NULL, "The winecfg tool is not yet complete, and does not actually alter your configuration\n\n"
-                    "If you want to alter the way Wine works, look in the ~/.wine/config file for more information.",
-                    "", MB_OK | MB_ICONEXCLAMATION);
-    }
 
-    if (initialize() != 0) {
+    if (initialize(hInstance) != 0) {
        WINE_ERR("initialization failed, aborting\n");
        ExitProcess(1);
     }
     
     /*
-     * The next 3 lines should be all that is needed
+     * The next 9 lines should be all that is needed
      * for the Wine Configuration property sheet
      */
     InitCommonControls ();
+    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
     if (doPropertySheet (hInstance, NULL) > 0) {
        WINE_TRACE("OK\n");
     } else {
        WINE_TRACE("Cancel\n");
     }
-    
+    CoUninitialize(); 
     ExitProcess (0);
 
     return 0;