first version of web control embedding:

Explorer tries to instantiate an IE web control, if that failes it tries
again using the CLASS-ID of Mozilla's Active-X web control.

svn path=/trunk/; revision=8075
This commit is contained in:
Martin Fuchs 2004-02-07 15:00:28 +00:00
parent 6c639db134
commit c414fe7978
31 changed files with 1873 additions and 95 deletions

View file

@ -24,6 +24,7 @@ exe explorer :
shell/ntobjfs.cpp
shell/regfs.cpp
shell/fatfs.cpp
shell/webchild.cpp
shell/startup.c
taskbar/desktopbar.cpp
taskbar/quicklaunch.cpp
@ -48,5 +49,6 @@ exe explorer :
<find-shared-library>comctl32
<find-shared-library>uuid
<find-shared-library>wsock32
<find-shared-library>oleaut32
;

View file

@ -83,6 +83,7 @@ OBJECTS = \
ntobjfs.o \
regfs.o \
fatfs.o \
webchild.o \
mainframe.o \
filechild.o \
pane.o \
@ -97,7 +98,7 @@ OBJECTS = \
settings.o \
i386-stub-win32.o
LIBS = gdi32 comctl32 ole32 uuid wsock32
LIBS = gdi32 comctl32 ole32 uuid wsock32 oleaut32
.PHONY: all depends implib clean install dist bootcd depends

View file

@ -57,6 +57,7 @@ OBJECTS = \
ntobjfs.o \
regfs.o \
fatfs.o \
webchild.o \
mainframe.o \
filechild.o \
pane.o \
@ -71,7 +72,7 @@ OBJECTS = \
settings.o \
i386-stub-win32.o
LIBS = gdi32 comctl32 ole32 uuid wsock32
LIBS = gdi32 comctl32 ole32 uuid wsock32 oleaut32
all: $(TARGET)

View file

@ -4,7 +4,7 @@ SRCDIR = .
MODULE = explorer.exe
APPMODE = gui
IMPORTS = shell32 comctl32 ole32 user32 gdi32 kernel32 advapi32
IMPORTS = shell32 comctl32 ole32 user32 gdi32 kernel32 advapi32 oleaut32
EXTRADEFS = -D__WINE__ -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -D__MINGW32__
#EXTRA_OBJS = explorer_intres.res
EXTRALIBS = $(LIBUUID)
@ -30,8 +30,9 @@ CPP_SRCS = \
shell/pane.cpp \
shell/shellbrowser.cpp \
shell/ntobjfs.cpp \
shell/fatfs.cpp \
shell/regfs.cpp \
shell/fatfs.cpp \
shell/webchild.cpp \
taskbar/desktopbar.cpp \
taskbar/taskbar.cpp \
taskbar/startmenu.cpp \

View file

@ -1,5 +1,5 @@
/*
* Copyright 2003 Martin Fuchs
* Copyright 2004 Martin Fuchs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,5 +1,5 @@
/*
* Copyright 2003 Martin Fuchs
* Copyright 2004 Martin Fuchs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -60,3 +60,4 @@ If you search for more information, look into the CVS repository.
31.01.2004 m. fuchs included NT Object namespace as virtual file system
31.01.2004 m. fuchs included Registry as virtual file system
02.02.2004 m. fuchs reading of FAT image files
07.02.2004 m. fuchs included IE/Mozilla as Active X control

View file

@ -3,7 +3,7 @@
<tr>
<td><address style="align: right;"><small>
ROS Explorer Source Code Documentation
<br>generated on 04.02.2004 by <a href="http://www.doxygen.org/index.html">
<br>generated on 05.02.2004 by <a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0>
</small></address>
</td>

View file

@ -429,8 +429,14 @@ ResBitmap::ResBitmap(UINT nid)
void explorer_show_frame(HWND hwndDesktop, int cmdshow, LPTSTR lpCmdLine)
{
if (g_Globals._hMainWnd)
if (g_Globals._hMainWnd) {
if (IsIconic(g_Globals._hMainWnd))
ShowWindow(g_Globals._hMainWnd, SW_RESTORE);
else
SetForegroundWindow(g_Globals._hMainWnd);
return;
}
g_Globals._prescan_nodes = false;

View file

@ -808,6 +808,14 @@ SOURCE=.\shell\unixfs.h
# End Source File
# Begin Source File
SOURCE=.\shell\webchild.cpp
# End Source File
# Begin Source File
SOURCE=.\shell\webchild.h
# End Source File
# Begin Source File
SOURCE=.\shell\winfs.cpp
# End Source File
# Begin Source File

View file

@ -37,9 +37,11 @@
#include "utility/window.h"
#define IDW_STATUSBAR 0x100
#define IDW_TOOLBAR 0x101
#define IDW_DRIVEBAR 0x102
#define IDW_STATUSBAR 0x100
#define IDW_TOOLBAR 0x101
#define IDW_DRIVEBAR 0x102
#define IDW_ADDRESSBAR 0x103
#define IDW_COMMANDBAR 0x104
#define IDW_FIRST_CHILD 0xC000 /*0x200*/
@ -52,10 +54,10 @@
#define PM_GET_WIDTH (WM_APP+0x18)
#define CLASSNAME_FRAME TEXT("CabinetWClass") // same class name for frame window as in MS Explorer
#define CLASSNAME_FRAME TEXT("CabinetWClass") // same class name for frame window as in MS Explorer
#define CLASSNAME_CHILDWND TEXT("WFS_Child")
#define CLASSNAME_WINEFILETREE TEXT("WFS_Tree")
#define CLASSNAME_CHILDWND TEXT("WFS_Child")
#define CLASSNAME_WINEFILETREE TEXT("WFS_Tree")
#include "shell/mainframe.h"

View file

@ -114,6 +114,7 @@
#define ID_ABOUT_WINEFILE 1705
#define IDC_FILETREE 10001
#define ID_EXPLORER_FAQ 10002
#define ID_WEB_WINDOW 10003
#define ID_WINDOW_AUTOSORT 0x8003
#define ID_VIEW_FULLSCREEN 0x8004
#define ID_PREFERED_SIZES 0x8005

View file

@ -69,7 +69,7 @@ CFG=make_explorer - Win32 bjam
# PROP Cmd_Line "msdevfilt -gcc -pipe "perl d:\tools\gSTLFilt.pl" make -f Makefile.MinGW UNICODE=0 DEBUG=1"
# PROP Rebuild_Opt "clean all"
# PROP Target_File "explorer.exe"
# PROP Bsc_Name ""
# PROP Bsc_Name "msdevfilt -gcc -pipe "perl d:\tools\gSTLFilt.pl" make -f Makefile.MinGW UNICODE=0 DEBUG=1"
# PROP Target_Dir ""
!ELSEIF "$(CFG)" == "make_explorer - Win32 Unicode Debug"

View file

@ -27,6 +27,7 @@
enum ENTRY_TYPE {
ET_UNKNOWN,
ET_WINDOWS,
#ifdef __WINE__
ET_UNIX,
@ -34,7 +35,8 @@ enum ENTRY_TYPE {
ET_SHELL,
ET_NTOBJS,
ET_REGISTRY,
ET_FAT
ET_FAT,
ET_WEB
};
enum SORT_ORDER {

View file

@ -1,5 +1,5 @@
/*
* Copyright 2003 Martin Fuchs
* Copyright 2004 Martin Fuchs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,5 +1,5 @@
/*
* Copyright 2003 Martin Fuchs
* Copyright 2004 Martin Fuchs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -37,14 +37,16 @@
#include "../explorer_intres.h"
FileChildWndInfo::FileChildWndInfo(LPCTSTR path)
FileChildWndInfo::FileChildWndInfo(LPCTSTR path, ENTRY_TYPE etype)
: _etype(etype)
{
if (etype == ET_UNKNOWN)
#ifdef __WINE__
if (*path == '/')
_etype = ET_UNIX;
else
if (*path == '/')
_etype = ET_UNIX;
else
#endif
_etype = ET_WINDOWS;
_etype = ET_WINDOWS;
_path = path;
@ -61,32 +63,34 @@ FileChildWndInfo::FileChildWndInfo(LPCTSTR path)
ShellChildWndInfo::ShellChildWndInfo(LPCTSTR path, const ShellPath& root_shell_path)
: FileChildWndInfo(path),
: FileChildWndInfo(path, ET_SHELL),
_shell_path(path&&*path? path: root_shell_path),
_root_shell_path(root_shell_path)
{
_etype = ET_SHELL;
}
NtObjChildWndInfo::NtObjChildWndInfo(LPCTSTR path)
: FileChildWndInfo(path)
: FileChildWndInfo(path, ET_NTOBJS)
{
_etype = ET_NTOBJS;
}
RegistryChildWndInfo::RegistryChildWndInfo(LPCTSTR path)
: FileChildWndInfo(path)
: FileChildWndInfo(path, ET_REGISTRY)
{
_etype = ET_REGISTRY;
}
FATChildWndInfo::FATChildWndInfo(LPCTSTR path)
: FileChildWndInfo(path)
: FileChildWndInfo(path, ET_FAT)
{
}
WebChildWndInfo::WebChildWndInfo(LPCTSTR url)
: FileChildWndInfo(url, ET_WEB)
{
_etype = ET_FAT;
}
@ -98,8 +102,8 @@ FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
TCHAR drv[_MAX_DRIVE+1];
Entry* entry;
if (info._etype == ET_SHELL) //@@ evtl. Aufteilung von FileChildWindow in ShellChildWindow, WinChildWindow, UnixChildWindow
{
switch(info._etype) {
case ET_SHELL: { //@@ evtl. Aufteilung von FileChildWindow in ShellChildWindow, WinChildWindow, UnixChildWindow
_root._drive_type = DRIVE_UNKNOWN;
lstrcpy(drv, TEXT("\\"));
lstrcpy(_root._volname, TEXT("Desktop"));
@ -109,11 +113,10 @@ FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
const ShellChildWndInfo& shell_info = static_cast<const ShellChildWndInfo&>(info);
_root._entry = new ShellDirectory(Desktop(), DesktopFolderPath(), hwnd);
entry = _root._entry->read_tree((LPCTSTR)&*shell_info._shell_path, SORT_NAME);
}
else
break;}
#ifdef __WINE__
if (info._etype == ET_UNIX)
{
case ET_UNIX: {
_root._drive_type = GetDriveType(info._path);
_tsplitpath(info._path, drv, NULL, NULL, NULL);
@ -124,11 +127,11 @@ FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
lstrcpy(_root._path, TEXT("/"));
_root._entry = new UnixDirectory(_root._path);
entry = _root._entry->read_tree(info._path, SORT_NAME);
}
else
break;}
#endif
if (info._etype == ET_NTOBJS)
{
case ET_NTOBJS:
_root._drive_type = DRIVE_UNKNOWN;
_tsplitpath(info._path, drv, NULL, NULL, NULL);
@ -138,9 +141,9 @@ FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
lstrcpy(_root._path, drv);
_root._entry = new NtObjDirectory(_root._path);
entry = _root._entry->read_tree(info._path, SORT_NAME);
}
else if (info._etype == ET_REGISTRY)
{
break;
case ET_REGISTRY:
_root._drive_type = DRIVE_UNKNOWN;
_tsplitpath(info._path, drv, NULL, NULL, NULL);
@ -150,9 +153,9 @@ FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
lstrcpy(_root._path, drv);
_root._entry = new RegistryRoot();
entry = _root._entry->read_tree(info._path, SORT_NONE);
}
else if (info._etype == ET_FAT)
{
break;
case ET_FAT:
_root._drive_type = DRIVE_UNKNOWN;
_tsplitpath(info._path, drv, NULL, NULL, NULL);
@ -162,9 +165,9 @@ FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info)
lstrcpy(_root._path, drv);
_root._entry = new FATDrive(TEXT("c:/reactos-bochs/cdrv.img")); //TEXT("\\\\.\\F:")); //@@
entry = _root._entry->read_tree(info._path, SORT_NONE);
}
else //if (info._etype == ET_WINDOWS)
{
break;
default: // ET_WINDOWS
_root._drive_type = GetDriveType(info._path);
_tsplitpath(info._path, drv, NULL, NULL, NULL);

View file

@ -29,7 +29,7 @@
/// information structure for creation of FileChildWindow
struct FileChildWndInfo
{
FileChildWndInfo(LPCTSTR path);
FileChildWndInfo(LPCTSTR path, ENTRY_TYPE etype=ET_UNKNOWN);
ENTRY_TYPE _etype;
LPCTSTR _path;
@ -59,12 +59,18 @@ struct RegistryChildWndInfo : public FileChildWndInfo
RegistryChildWndInfo(LPCTSTR path);
};
/// information structure for creation of FileChildWindow for the Registry
/// information structure for creation of FileChildWindow
struct FATChildWndInfo : public FileChildWndInfo
{
FATChildWndInfo(LPCTSTR path);
};
/// information structure for creation of WebChildWindow
struct WebChildWndInfo : public FileChildWndInfo
{
WebChildWndInfo(LPCTSTR url);
};
/// MDI child window displaying file lists
struct FileChildWindow : public ChildWindow

View file

@ -32,6 +32,11 @@
#include "../globals.h"
#include "../externals.h"
/* We can't include webchild.h here - otherwise MinGW produces errors like: "multiple definition of `QACONTAINERFLAGS'"
#include "webchild.h"
*/
extern HWND create_webchildwindow(HWND hmdiclient, const WebChildWndInfo& info);
#include "../explorer_intres.h"
@ -136,6 +141,13 @@ MainFrame::MainFrame(HWND hwnd)
drivebarBtn.idCommand = ID_DRIVE_FAT;
SendMessage(_hdrivebar, TB_INSERTBUTTON, btn++, (LPARAM)&drivebarBtn);
++drivebarBtn.iString;
// insert web control button
SendMessage(_hdrivebar, TB_ADDSTRING, 0, (LPARAM)TEXT("Web\0"));
drivebarBtn.idCommand = ID_WEB_WINDOW;
SendMessage(_hdrivebar, TB_INSERTBUTTON, btn++, (LPARAM)&drivebarBtn);
++drivebarBtn.iString;
// register windows drive root strings
@ -164,6 +176,20 @@ MainFrame::MainFrame(HWND hwnd)
}
// address & command bar
WindowCanvas canvas(hwnd);
RECT rect = {0, 0, 0, 0};
DrawText(canvas, TEXT("My"), -1, &rect, DT_SINGLELINE|DT_NOPREFIX|DT_CALCRECT);
HFONT hfont = GetStockFont(DEFAULT_GUI_FONT);
_haddressedit = CreateWindow(TEXT("EDIT"), TEXT("file://C:\\"), WS_CHILD|WS_VISIBLE, 0, 0, 0, rect.bottom,
hwnd, (HMENU)IDW_ADDRESSBAR, g_Globals._hInstance, 0);
SetWindowFont(_haddressedit, hfont, FALSE);
_hcommandedit = CreateWindow(TEXT("EDIT"), TEXT("> Command"), WS_CHILD|WS_VISIBLE, 0, 0, 0, rect.bottom,
hwnd, (HMENU)IDW_ADDRESSBAR, g_Globals._hInstance, 0);
SetWindowFont(_hcommandedit, hfont, FALSE);
/* CreateStatusWindow does not accept WS_BORDER
_hstatusbar = CreateWindowEx(WS_EX_NOPARENTNOTIFY, STATUSCLASSNAME, 0,
WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_BORDER|CCS_NODIVIDER, 0,0,0,0,
@ -521,6 +547,18 @@ int MainFrame::Command(int id, int code)
#endif
break;}
#endif
case ID_DRIVE_DESKTOP: {
TCHAR path[MAX_PATH];
if (activate_child_window(TEXT("Desktop")))
break;
GetCurrentDirectory(MAX_PATH, path);
ShellBrowserChild::create(_hmdiclient, ShellChildWndInfo(path,DesktopFolderPath()));
break;}
case ID_DRIVE_SHELL_NS: {
TCHAR path[MAX_PATH];
@ -572,16 +610,9 @@ int MainFrame::Command(int id, int code)
#endif
break;}
case ID_DRIVE_DESKTOP: {
TCHAR path[MAX_PATH];
if (activate_child_window(TEXT("Desktop")))
break;
GetCurrentDirectory(MAX_PATH, path);
ShellBrowserChild::create(_hmdiclient, ShellChildWndInfo(path,DesktopFolderPath()));
break;}
case ID_WEB_WINDOW:
create_webchildwindow(_hmdiclient, WebChildWndInfo(TEXT("http://www.reactos.com"))); //@@
break;
///@todo There are even more menu items!
@ -597,6 +628,11 @@ int MainFrame::Command(int id, int code)
launch_file(_hwnd, TEXT("http://www.sky.franken.de/explorer/"), SW_SHOWNORMAL);
break;
case IDW_ADDRESSBAR:
case IDW_COMMANDBAR:
//@@
break;
default:
/*@todo if (wParam >= PM_FIRST_LANGUAGE && wParam <= PM_LAST_LANGUAGE)
STRING_SelectLanguageByNumber(wParam - PM_FIRST_LANGUAGE);
@ -623,7 +659,7 @@ void MainFrame::resize_frame_rect(PRECT prect)
SendMessage(_htoolbar, WM_SIZE, 0, 0);
ClientRect rt(_htoolbar);
prect->top = rt.bottom+3;
prect->bottom -= rt.bottom+3;
// prect->bottom -= rt.bottom+3;
}
if (IsWindowVisible(_hdrivebar)) {
@ -632,7 +668,7 @@ void MainFrame::resize_frame_rect(PRECT prect)
new_top = --prect->top + rt.bottom+3;
MoveWindow(_hdrivebar, 0, prect->top, rt.right, new_top, TRUE);
prect->top = new_top;
prect->bottom -= rt.bottom+2;
// prect->bottom -= rt.bottom+2;
}
if (IsWindowVisible(_hstatusbar)) {
@ -644,8 +680,17 @@ void MainFrame::resize_frame_rect(PRECT prect)
prect->bottom -= rt.bottom;
}
if (IsWindowVisible(_haddressedit) || IsWindowVisible(_hcommandedit)) {
ClientRect rt(_haddressedit);
prect->bottom -= rt.bottom;
int mid = (prect->right-prect->left) / 2; ///@todo use split bar
SetWindowPos(_haddressedit, 0, 0, prect->bottom, mid, rt.bottom, SWP_NOACTIVATE|SWP_NOZORDER);
SetWindowPos(_hcommandedit, 0, mid+1, prect->bottom, prect->right-(mid+1), rt.bottom, SWP_NOACTIVATE|SWP_NOZORDER);
}
#ifndef _NO_MDI
MoveWindow(_hmdiclient, prect->left-1,prect->top-1,prect->right+2,prect->bottom+1, TRUE);
MoveWindow(_hmdiclient, prect->left-1,prect->top-1,prect->right-prect->left+2,prect->bottom-prect->top+1, TRUE);
#endif
}

View file

@ -56,6 +56,8 @@ protected:
WindowHandle _hstatusbar;
WindowHandle _htoolbar;
WindowHandle _hdrivebar;
WindowHandle _haddressedit;
WindowHandle _hcommandedit;
HMENU _hMenuFrame;
HMENU _hMenuWindow;

View file

@ -1,5 +1,5 @@
/*
* Copyright 2003 Martin Fuchs
* Copyright 2004 Martin Fuchs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,5 +1,5 @@
/*
* Copyright 2003 Martin Fuchs
* Copyright 2004 Martin Fuchs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,5 +1,5 @@
/*
* Copyright 2003 Martin Fuchs
* Copyright 2004 Martin Fuchs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -1,5 +1,5 @@
/*
* Copyright 2003 Martin Fuchs
* Copyright 2004 Martin Fuchs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public

View file

@ -0,0 +1,220 @@
/*
* Copyright 2004 Martin Fuchs
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//
// Explorer clone
//
// webchild.cpp
//
// Martin Fuchs, 08.02.2004
//
#include "../utility/utility.h"
#include "../explorer.h"
#include "webchild.h"
//#include <mshtml.h>
Variant::Variant(const VARIANT& var)
{
VariantInit(this);
CheckError(VariantCopy(this, const_cast<VARIANT*>(&var)));
}
Variant::Variant(const VARIANT* var)
{
VariantInit(this);
CheckError(VariantCopy(this, const_cast<VARIANT*>(var)));
}
Variant::~Variant()
{
VariantClear(this);
}
Variant::operator long() const
{
Variant v;
CheckError(VariantChangeType(&v, (VARIANT*)this, 0, VT_I4));
return V_I4(&v);
}
Variant::operator bool() const
{
Variant v;
CheckError(VariantChangeType(&v, (VARIANT*)this, 0, VT_BOOL));
return V_BOOL(&v)? true: false;
}
Variant::operator IDispatch*() const
{
Variant v;
CheckError(VariantChangeType(&v, (VARIANT*)this, 0, VT_DISPATCH));
return V_DISPATCH(&v);
}
Variant::operator VARIANT_BOOL() const
{
Variant v;
CheckError(VariantChangeType(&v, (VARIANT*)this, 0, VT_BOOL));
return V_BOOL(&v);
}
void BStr::assign(BSTR s)
{
if (!SysReAllocString(&_p, s))
THROW_EXCEPTION(E_OUTOFMEMORY);
}
void BStr::assign(const VARIANT& var)
{
if (V_VT(&var) == VT_BSTR)
assign(V_BSTR(&var));
else {
Variant v;
CheckError(VariantChangeType(&v, const_cast<VARIANT*>(&var), 0, VT_BSTR));
assign(V_BSTR(&v));
}
}
BrowserNavigator::BrowserNavigator(IWebBrowser* browser)
: _browser(browser),
_browser_initialized(false)
{
}
void BrowserNavigator::goto_url(LPCTSTR url)
{
if (_browser_initialized)
_browser->Navigate(BStr(url), NULL, NULL, NULL, NULL);
else {
_new_url = url;
_browser->Navigate(L"about:blank", NULL, NULL, NULL, NULL);
}
}
void BrowserNavigator::set_html_page(const String& html_txt)
{
_new_html_txt = html_txt;
goto_url(TEXT("about:blank"));
}
void T2nA_binary(LPCTSTR s, LPSTR d, int len)
{
while(len-- > 0)
*d++ = (unsigned char)*s++;
}
void BrowserNavigator::navigated(LPCTSTR url)
{
_browser_initialized = true;
bool nav = false;
if (!_new_url.empty()) {
if (!_tcscmp(url,TEXT("about:blank")) && _new_url!=TEXT("about:blank")) {
_browser->Navigate(BStr(_new_url), NULL, NULL, NULL, NULL);
++nav;
}
_new_url.erase();
}
if (!nav && !_new_html_txt.empty()) { ///@todo move this into DocumentComplete() ?
int len = _new_html_txt.length();
HGLOBAL hHtmlText = GlobalAlloc(GPTR, len);
if (!hHtmlText) {
T2nA_binary(_new_html_txt, (char*)hHtmlText, len);
_new_html_txt.erase();
SIfacePtr<IStream> pStream;
HRESULT hr = CreateStreamOnHGlobal(hHtmlText, TRUE, &pStream);
if (SUCCEEDED(hr)) {
SIfacePtr<IDispatch> pHtmlDoc;
CheckError(_browser->get_Document(&pHtmlDoc));
SIfacePtr<IPersistStreamInit> pPersistStreamInit;
pHtmlDoc.QueryInterface(IID_IPersistStreamInit, &pPersistStreamInit);
CheckError(pPersistStreamInit->InitNew());
CheckError(pPersistStreamInit->Load(pStream));
} else
GlobalFree(hHtmlText);
}
}
}
HWND create_webchildwindow(HWND hmdiclient, const WebChildWndInfo& info)
{
WebChildWindow* pWnd = WebChildWindow::create(hmdiclient, info);
if (!pWnd)
return 0;
return *pWnd;
}
static const CLSID CLSID_MozillaBrowser =
{0x1339B54C, 0x3453, 0x11D2, {0x93, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
WebChildWindow::WebChildWindow(HWND hwnd, const WebChildWndInfo& info)
: super(hwnd)
{
// first try to create MS IE web control
HRESULT hr = create_control(hwnd, CLSID_WebBrowser, IID_IWebBrowser2);
// If this failed, try to use Mozilla's web control
if (FAILED(hr))
hr = create_control(hwnd, CLSID_MozillaBrowser, IID_IWebBrowser2);
if (SUCCEEDED(hr)) {
// handling events using DWebBrowserEvents
_evt_demo1 = new DWebBrowserEventsHandler(_hwnd, _control);
// handling events using DWebBrowserEvents2
_evt_demo2 = new DWebBrowserEvents2Handler(_hwnd, _control);
}
SIfacePtr<IWebBrowser2> browser(get_browser());
#ifdef __MINGW32__ // MinGW is lacking vtMissing (as of 07.02.2004)
Variant vtMissing;
#endif
browser->Navigate(BStr(info._path), &vtMissing, &vtMissing, &vtMissing, &vtMissing);
//browser->Navigate2(&Variant(info._path), &vtMissing, &vtMissing, &vtMissing, &vtMissing);
}
WebChildWindow::~WebChildWindow()
{
delete _evt_demo2;
delete _evt_demo1;
}

File diff suppressed because it is too large Load diff

View file

@ -30,6 +30,8 @@
#include "../explorer.h"
#include "../globals.h"
#include "../externals.h"
#include "../explorer_intres.h"
#include "quicklaunch.h"
@ -116,7 +118,8 @@ void QuickLaunchBar::AddShortcuts()
COLORREF bk_color = GetSysColor(COLOR_BTNFACE);
HBRUSH bk_brush = GetSysColorBrush(COLOR_BTNFACE);
TBBUTTON btn = {0, 0, TBSTATE_ENABLED, BTNS_BUTTON|BTNS_NOPREFIX, {0, 0}, 0, 0};
AddButton(g_Globals._icon_cache.get_icon(ICID_LOGOFF/*@@*/).create_bitmap(bk_color, bk_brush, canvas), ResString(IDS_MINIMIZE_ALL), NULL);
AddButton(g_Globals._icon_cache.get_icon(ICID_EXPLORER).create_bitmap(bk_color, bk_brush, canvas), ResString(IDS_TITLE), NULL);
for(Entry*entry=_dir->_down; entry; entry=entry->_next) {
// hide files like "desktop.ini"
@ -127,24 +130,7 @@ void QuickLaunchBar::AddShortcuts()
if (!(entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
HBITMAP hbmp = g_Globals._icon_cache.get_icon(entry->_icon_id).create_bitmap(bk_color, bk_brush, canvas);
TBADDBITMAP ab = {0, (UINT_PTR)hbmp};
int bmp_idx = SendMessage(_hwnd, TB_ADDBITMAP, 1, (LPARAM)&ab);
QuickLaunchEntry qle;
int id = ++_next_id;
qle._hbmp = hbmp;
qle._title = entry->_display_name; //entry->_etype==ET_SHELL? desktop_folder.get_name(static_cast<ShellEntry*>(entry)->_pidl): entry->_display_name
qle._entry = entry;
_entries[id] = qle;
btn.idCommand = id;
btn.iBitmap = bmp_idx;
int idx = SendMessage(_hwnd, TB_BUTTONCOUNT, 0, 0);
SendMessage(_hwnd, TB_INSERTBUTTON, idx, (LPARAM)&btn);
AddButton(hbmp, entry->_display_name, entry); //entry->_etype==ET_SHELL? desktop_folder.get_name(static_cast<ShellEntry*>(entry)->_pidl): entry->_display_name);
}
}
@ -152,6 +138,30 @@ void QuickLaunchBar::AddShortcuts()
SendMessage(GetParent(_hwnd), PM_RESIZE_CHILDREN, 0, 0);
}
void QuickLaunchBar::AddButton(HBITMAP hbmp, LPCTSTR name, Entry* entry)
{
TBADDBITMAP ab = {0, (UINT_PTR)hbmp};
int bmp_idx = SendMessage(_hwnd, TB_ADDBITMAP, 1, (LPARAM)&ab);
QuickLaunchEntry qle;
int id = _next_id++;
qle._hbmp = hbmp;
qle._title = name;
qle._entry = entry;
_entries[id] = qle;
TBBUTTON btn = {0, 0, TBSTATE_ENABLED, BTNS_BUTTON|BTNS_NOPREFIX, {0, 0}, 0, 0};
btn.idCommand = id;
btn.iBitmap = bmp_idx;
int idx = SendMessage(_hwnd, TB_BUTTONCOUNT, 0, 0);
SendMessage(_hwnd, TB_INSERTBUTTON, idx, (LPARAM)&btn);
}
LRESULT QuickLaunchBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
{
switch(nmsg) {
@ -173,7 +183,14 @@ int QuickLaunchBar::Command(int id, int code)
{
CONTEXT("QuickLaunchBar::Command()");
_entries[id]._entry->launch_entry(_hwnd);
QuickLaunchEntry& qle = _entries[id];
if (qle._entry)
qle._entry->launch_entry(_hwnd);
else if (id == IDC_FIRST_QUICK_ID)
; ///@todo minimize/restore all windows
else if (id == IDC_FIRST_QUICK_ID+1)
explorer_show_frame(_hwnd, SW_SHOWNORMAL);
return 0;
}

View file

@ -78,4 +78,5 @@ protected:
int _btn_dist;
void AddShortcuts();
void AddButton(HBITMAP hbmp, LPCTSTR name, Entry* entry);
};

View file

@ -144,7 +144,7 @@ struct COMException : public COMExceptionBase
int _line;
};
#define THROW_EXCEPTION(e) throw COMException(e, __FILE__, __LINE__)
#define THROW_EXCEPTION(hr) throw COMException(hr, __FILE__, __LINE__)
#define CHECKERROR(hr) ((void)(FAILED(hr)? THROW_EXCEPTION(hr): 0))
@ -329,6 +329,12 @@ template<typename T> struct SIfacePtr
p->AddRef();
}
SIfacePtr(IUnknown* unknown, REFIID riid)
{
CHECKERROR(unknown->QueryInterface(riid, (LPVOID*)&_p));
//@@ _p->AddRef();
}
~SIfacePtr()
{
Free();
@ -360,7 +366,7 @@ template<typename T> struct SIfacePtr
return &_p;
}
bool empty() const //NOTE: GCC seems not to work correctly when defining operator bool() AND operator T*()
bool empty() const //NOTE: GCC seems not to work correctly when defining operator bool() AND operator T*() at one time
{
return !_p;
}
@ -368,8 +374,11 @@ template<typename T> struct SIfacePtr
SIfacePtr& operator=(T* p)
{
Free();
p->AddRef();
_p = p;
if (p) {
p->AddRef();
_p = p;
}
return *this;
}
@ -387,6 +396,16 @@ template<typename T> struct SIfacePtr
h->Release();
}
HRESULT CreateInstance(REFIID clsid, REFIID riid)
{
return CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, riid, (LPVOID*)&_p);
}
template<typename I> HRESULT QueryInterface(REFIID riid, I* p)
{
return _p->QueryInterface(riid, (LPVOID*)p);
}
void Free()
{
T* h = _p;
@ -728,7 +747,7 @@ struct ShellPath : public SShellPtr<ITEMIDLIST>
};
#ifdef __GCC__ // Wine doesn't know of unnamed union members and uses some macros instead.
#ifdef __WINE__ // Wine doesn't know of unnamed union members and uses some macros instead.
#define UNION_MEMBER(x) DUMMYUNIONNAME.##x
#else
#define UNION_MEMBER(x) x

View file

@ -40,6 +40,11 @@
#include <windowsx.h> // for SelectBrush(), ListBox_SetSel(), SubclassWindow(), ...
#include <commctrl.h>
#ifndef _MSC_VER
#include <objbase.h>
#include <oleauto.h> // for VARIANT
#endif
#include <malloc.h> // for alloca()
#include <assert.h>
#include <stdlib.h> // for _MAX_DIR, ...
@ -640,6 +645,76 @@ protected:
};
struct Variant : public VARIANT
{
Variant() {VariantInit(this);}
Variant(const VARIANT& var);
Variant(const VARIANT* var);
~Variant();
operator long() const;
operator bool() const;
operator VARIANT_BOOL() const;
operator IDispatch*() const;
};
struct BStr
{
BStr()
{
_p = NULL;
}
BStr(const BSTR s)
{
_p = SysAllocString(s);
}
BStr(LPCSTR s)
{
WCHAR b[BUFFER_LEN];
if (s)
_p = SysAllocStringLen(b, MultiByteToWideChar(CP_ACP, 0, s, -1, b, BUFFER_LEN));
else
_p = NULL;
}
BStr(LPCWSTR s)
{
_p = SysAllocString(s);
}
BStr(const VARIANT& var)
: _p(NULL)
{
assign(var);
}
~BStr()
{
SysFreeString(_p);
}
void assign(BSTR s);
void assign(const VARIANT& var);
operator BSTR() const
{
return _p? _p: (BSTR)L"";
}
int length() const
{
return _p? wcslen(_p): 0;
}
protected:
BSTR _p;
};
/// string class for convenience
struct String
#ifdef UNICODE
@ -667,6 +742,7 @@ struct String
String& operator=(LPCSTR s) {assign(s); return *this;}
void assign(LPCSTR s) {if (s) {TCHAR b[BUFFER_LEN]; super::assign(b, MultiByteToWideChar(CP_ACP, 0, s, -1, b, BUFFER_LEN));} else erase();}
void assign(LPCSTR s, int l) {if (s) {TCHAR b[BUFFER_LEN]; super::assign(b, MultiByteToWideChar(CP_ACP, 0, s, l, b, BUFFER_LEN));} else erase();}
void assign(const BStr& s) {int l = s.length(); super::assign(s, l);}
#else
String(LPCWSTR s) {assign(s);}
String(LPCWSTR s, int l) {assign(s, l);}
@ -674,7 +750,10 @@ struct String
String& operator=(LPCWSTR s) {assign(s); return *this;}
void assign(LPCWSTR s) {if (s) {char b[BUFFER_LEN]; super::assign(b, WideCharToMultiByte(CP_ACP, 0, s, -1, b, BUFFER_LEN, 0, 0));} else erase();}
void assign(LPCWSTR s, int l) {if (s) {char b[BUFFER_LEN]; super::assign(b, WideCharToMultiByte(CP_ACP, 0, s, l, b, BUFFER_LEN, 0, 0));} else erase();}
void assign(const BStr& s) {int l = s.length(); if (l) {char b[BUFFER_LEN]; super::assign(b, WideCharToMultiByte(CP_ACP, 0, s, l, b, BUFFER_LEN, 0, 0));} else erase();}
#endif
String(const BStr& s) {assign(s);}
String& operator=(const BStr& s) {assign(s); return *this;}
String& operator=(LPCTSTR s) {if (s) super::assign(s); else erase(); return *this;}
String& operator=(const super& s) {super::assign(s); return *this;}

View file

@ -238,7 +238,7 @@ Window* Window::create_controller(HWND hwnd)
}
LRESULT Window::Init(LPCREATESTRUCT pcs)
LRESULT Window::Init(LPCREATESTRUCT pcs)
{
return 0;
}