Commit e859230e authored by Detlef Riekenberg's avatar Detlef Riekenberg Committed by Alexandre Julliard

inetcpl: Add general propsheet and allow to set the homepage.

parent 80545ef9
MODULE = inetcpl.cpl
IMPORTS = comctl32 user32
IMPORTS = comctl32 shlwapi user32 advapi32
DELAYIMPORTS = cryptui
C_SRCS = \
content.c \
general.c \
inetcpl.c
RC_SRCS = \
......
......@@ -29,6 +29,23 @@ BEGIN
IDS_CPL_INFO "Configure Wine Internet Browser and related settings"
END
/* "General" propsheet */
IDD_GENERAL DIALOG 0, 0, 320, 220
STYLE WS_CAPTION | WS_CHILD | WS_DISABLED
FONT 8, "MS Shell Dlg"
CAPTION "General"
BEGIN
GROUPBOX " Home page ", IDC_STATIC, 4, 4, 312, 52
LTEXT "You can choose the address that will be used as your home page.",
IDC_STATIC, 58, 10, 252, 10
EDITTEXT IDC_HOME_EDIT, 58, 22, 252, 12, WS_VISIBLE | ES_AUTOHSCROLL
PUSHBUTTON "&Current page", IDC_HOME_CURRENT, 58, 36, 80, 14
PUSHBUTTON "&Default page", IDC_HOME_DEFAULT, 144, 36, 80, 14
PUSHBUTTON "&Blank page", IDC_HOME_BLANK, 230, 36, 80, 14
END
/* "Content" propsheet */
IDD_CONTENT DIALOG 0, 0, 320, 220
STYLE WS_CAPTION | WS_CHILD | WS_DISABLED
......
/*
* Internet control panel applet: general propsheet
*
* Copyright 2010 Detlef Riekenberg
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#define NONAMELESSUNION
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <wininet.h>
#include <winreg.h>
#include <shlwapi.h>
#include <prsht.h>
#include "inetcpl.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(inetcpl);
static const WCHAR about_blank[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
static const WCHAR start_page[] = {'S','t','a','r','t',' ','P','a','g','e',0};
static const WCHAR reg_ie_main[] = {'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r','\\',
'M','a','i','n',0};
/* list of unimplemented buttons */
static DWORD disable_me[] = {IDC_HOME_CURRENT,
IDC_HOME_DEFAULT, 0};
/*********************************************************************
* parse_url_from_outside [internal]
*
* Filter an URL, add a usable scheme, when needed
*
*/
static DWORD parse_url_from_outside(LPCWSTR url, LPWSTR out, DWORD maxlen)
{
HMODULE hdll;
DWORD (WINAPI *pParseURLFromOutsideSourceW)(LPCWSTR, LPWSTR, LPDWORD, LPDWORD);
DWORD res;
hdll = LoadLibraryA("shdocvw.dll");
pParseURLFromOutsideSourceW = (void *) GetProcAddress(hdll, (LPSTR) 170);
if (pParseURLFromOutsideSourceW)
{
res = pParseURLFromOutsideSourceW(url, out, &maxlen, NULL);
FreeLibrary(hdll);
return res;
}
ERR("failed to get ordinal 170: %d\n", GetLastError());
FreeLibrary(hdll);
return 0;
}
/*********************************************************************
* general_on_command [internal]
*
* handle WM_COMMAND
*
*/
static INT_PTR general_on_command(HWND hwnd, WPARAM wparam)
{
switch (wparam)
{
case MAKEWPARAM(IDC_HOME_EDIT, EN_CHANGE):
/* enable apply button */
SendMessageW(GetParent(hwnd), PSM_CHANGED, (WPARAM)hwnd, 0);
break;
case MAKEWPARAM(IDC_HOME_BLANK, BN_CLICKED):
SetDlgItemTextW(hwnd, IDC_HOME_EDIT, about_blank);
break;
default:
TRACE("not implemented for command: %d/%d\n", HIWORD(wparam), LOWORD(wparam));
return FALSE;
}
return TRUE;
}
/*********************************************************************
* general_on_initdialog [internal]
*
* handle WM_INITDIALOG
*
*/
static VOID general_on_initdialog(HWND hwnd)
{
WCHAR buffer[INTERNET_MAX_URL_LENGTH];
DWORD len;
DWORD type;
LONG res;
DWORD *ptr = disable_me;
/* disable unimplemented buttons */
while (*ptr)
{
EnableWindow(GetDlgItem(hwnd, *ptr), FALSE);
ptr++;
}
/* read current homepage from the registry. Try HCU first, then HKLM */
*buffer = 0;
len = sizeof(buffer);
type = REG_SZ;
res = SHRegGetUSValueW(reg_ie_main, start_page, &type, buffer, &len, FALSE, (LPBYTE) about_blank, sizeof(about_blank));
if (!res && (type == REG_SZ))
{
SetDlgItemTextW(hwnd, IDC_HOME_EDIT, buffer);
}
}
/*********************************************************************
* general_on_notify [internal]
*
* handle WM_NOTIFY
*
*/
static INT_PTR general_on_notify(HWND hwnd, WPARAM wparam, LPARAM lparam)
{
PSHNOTIFY *psn;
WCHAR buffer[INTERNET_MAX_URL_LENGTH];
WCHAR parsed[INTERNET_MAX_URL_LENGTH];
LONG res;
psn = (PSHNOTIFY *) lparam;
TRACE("WM_NOTIFY (%p, 0x%lx, 0x%lx) from %p with code: %d\n", hwnd, wparam, lparam,
psn->hdr.hwndFrom, psn->hdr.code);
if (psn->hdr.code == PSN_APPLY)
{
*buffer = 0;
GetDlgItemTextW(hwnd, IDC_HOME_EDIT, buffer, sizeof(buffer)/sizeof(WCHAR));
TRACE("EDITTEXT has %s\n", debugstr_w(buffer));
res = parse_url_from_outside(buffer, parsed, sizeof(parsed)/sizeof(WCHAR));
TRACE("got %d with %s\n", res, debugstr_w(parsed));
if (res)
{
HKEY hkey;
/* update the dialog, when needed */
if (lstrcmpW(buffer, parsed))
SetDlgItemTextW(hwnd, IDC_HOME_EDIT, parsed);
/* update the registry */
res = RegOpenKeyW(HKEY_CURRENT_USER, reg_ie_main, &hkey);
if (!res)
{
res = RegSetValueExW(hkey, start_page, 0, REG_SZ, (const BYTE *)parsed,
(lstrlenW(parsed) + 1) * sizeof(WCHAR));
RegCloseKey(hkey);
return !res;
}
}
}
return FALSE;
}
/*********************************************************************
* general_dlgproc [internal]
*
*/
INT_PTR CALLBACK general_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_INITDIALOG:
general_on_initdialog(hwnd);
return TRUE;
case WM_COMMAND:
return general_on_command(hwnd, wparam);
case WM_NOTIFY:
return general_on_notify(hwnd, wparam, lparam);
default:
/* do not flood the log */
if ((msg == WM_SETCURSOR) || (msg == WM_NCHITTEST) || (msg == WM_MOUSEMOVE))
return FALSE;
TRACE("(%p, 0x%08x/%d, 0x%lx, 0x%lx)\n", hwnd, msg, msg, wparam, lparam);
}
return FALSE;
}
......@@ -27,7 +27,6 @@
#include <wingdi.h>
#include <winuser.h>
#include <commctrl.h>
#include <commdlg.h>
#include <cpl.h>
#include "wine/debug.h"
......@@ -93,6 +92,12 @@ static void display_cpl_sheets(HWND parent)
/* Fill out all PROPSHEETPAGE */
psp[id].dwSize = sizeof (PROPSHEETPAGEW);
psp[id].hInstance = hcpl;
psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_GENERAL);
psp[id].pfnDlgProc = general_dlgproc;
id++;
psp[id].dwSize = sizeof (PROPSHEETPAGEW);
psp[id].hInstance = hcpl;
psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_CONTENT);
psp[id].pfnDlgProc = content_dlgproc;
id++;
......
......@@ -19,12 +19,16 @@
*
*/
#ifndef __WINE_INETCPL__
#define __WINE_INETCPL__
#include <windef.h>
#include <winuser.h>
extern HMODULE hcpl;
INT_PTR CALLBACK content_dlgproc(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN;
INT_PTR CALLBACK general_dlgproc(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN;
#define NUM_PROPERTY_PAGES 8
......@@ -38,6 +42,14 @@ INT_PTR CALLBACK content_dlgproc(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN;
/* dialogs */
#define IDC_STATIC -1
#define IDD_GENERAL 1000
#define IDC_HOME_EDIT 1000
#define IDC_HOME_CURRENT 1001
#define IDC_HOME_DEFAULT 1002
#define IDC_HOME_BLANK 1003
#define IDD_CONTENT 4000
#define IDC_CERT 4100
#define IDC_CERT_PUBLISHER 4101
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment