2 * Internet control panel applet: general propsheet
4 * Copyright 2010 Detlef Riekenberg
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define NONAMELESSUNION
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(inetcpl);
38 static const WCHAR about_blank[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
39 static const WCHAR start_page[] = {'S','t','a','r','t',' ','P','a','g','e',0};
40 static const WCHAR reg_ie_main[] = {'S','o','f','t','w','a','r','e','\\',
41 'M','i','c','r','o','s','o','f','t','\\',
42 'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\',
45 /* list of unimplemented buttons */
46 static DWORD disable_me[] = {IDC_HOME_CURRENT,
49 /*********************************************************************
50 * parse_url_from_outside [internal]
52 * Filter an URL, add a usable scheme, when needed
55 static DWORD parse_url_from_outside(LPCWSTR url, LPWSTR out, DWORD maxlen)
58 DWORD (WINAPI *pParseURLFromOutsideSourceW)(LPCWSTR, LPWSTR, LPDWORD, LPDWORD);
61 hdll = LoadLibraryA("shdocvw.dll");
62 pParseURLFromOutsideSourceW = (void *) GetProcAddress(hdll, (LPSTR) 170);
64 if (pParseURLFromOutsideSourceW)
66 res = pParseURLFromOutsideSourceW(url, out, &maxlen, NULL);
71 ERR("failed to get ordinal 170: %d\n", GetLastError());
76 /*********************************************************************
77 * general_on_command [internal]
82 static INT_PTR general_on_command(HWND hwnd, WPARAM wparam)
87 case MAKEWPARAM(IDC_HOME_EDIT, EN_CHANGE):
88 /* enable apply button */
89 SendMessageW(GetParent(hwnd), PSM_CHANGED, (WPARAM)hwnd, 0);
92 case MAKEWPARAM(IDC_HOME_BLANK, BN_CLICKED):
93 SetDlgItemTextW(hwnd, IDC_HOME_EDIT, about_blank);
97 TRACE("not implemented for command: %d/%d\n", HIWORD(wparam), LOWORD(wparam));
103 /*********************************************************************
104 * general_on_initdialog [internal]
106 * handle WM_INITDIALOG
109 static VOID general_on_initdialog(HWND hwnd)
111 WCHAR buffer[INTERNET_MAX_URL_LENGTH];
115 DWORD *ptr = disable_me;
117 /* disable unimplemented buttons */
120 EnableWindow(GetDlgItem(hwnd, *ptr), FALSE);
124 /* read current homepage from the registry. Try HCU first, then HKLM */
126 len = sizeof(buffer);
128 res = SHRegGetUSValueW(reg_ie_main, start_page, &type, buffer, &len, FALSE, (LPBYTE) about_blank, sizeof(about_blank));
130 if (!res && (type == REG_SZ))
132 SetDlgItemTextW(hwnd, IDC_HOME_EDIT, buffer);
136 /*********************************************************************
137 * general_on_notify [internal]
142 static INT_PTR general_on_notify(HWND hwnd, WPARAM wparam, LPARAM lparam)
145 WCHAR buffer[INTERNET_MAX_URL_LENGTH];
146 WCHAR parsed[INTERNET_MAX_URL_LENGTH];
149 psn = (PSHNOTIFY *) lparam;
150 TRACE("WM_NOTIFY (%p, 0x%lx, 0x%lx) from %p with code: %d\n", hwnd, wparam, lparam,
151 psn->hdr.hwndFrom, psn->hdr.code);
153 if (psn->hdr.code == PSN_APPLY)
156 GetDlgItemTextW(hwnd, IDC_HOME_EDIT, buffer, sizeof(buffer)/sizeof(WCHAR));
157 TRACE("EDITTEXT has %s\n", debugstr_w(buffer));
159 res = parse_url_from_outside(buffer, parsed, sizeof(parsed)/sizeof(WCHAR));
160 TRACE("got %d with %s\n", res, debugstr_w(parsed));
166 /* update the dialog, when needed */
167 if (lstrcmpW(buffer, parsed))
168 SetDlgItemTextW(hwnd, IDC_HOME_EDIT, parsed);
170 /* update the registry */
171 res = RegOpenKeyW(HKEY_CURRENT_USER, reg_ie_main, &hkey);
174 res = RegSetValueExW(hkey, start_page, 0, REG_SZ, (const BYTE *)parsed,
175 (lstrlenW(parsed) + 1) * sizeof(WCHAR));
184 /*********************************************************************
185 * general_dlgproc [internal]
188 INT_PTR CALLBACK general_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
194 general_on_initdialog(hwnd);
198 return general_on_command(hwnd, wparam);
201 return general_on_notify(hwnd, wparam, lparam);
204 /* do not flood the log */
205 if ((msg == WM_SETCURSOR) || (msg == WM_NCHITTEST) || (msg == WM_MOUSEMOVE))
208 TRACE("(%p, 0x%08x/%d, 0x%lx, 0x%lx)\n", hwnd, msg, msg, wparam, lparam);