diff --git a/reactos/subsys/system/explorer/Jamfile b/reactos/subsys/system/explorer/Jamfile index e8f2fcf9b28..96bbdf01abd 100644 --- a/reactos/subsys/system/explorer/Jamfile +++ b/reactos/subsys/system/explorer/Jamfile @@ -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 : comctl32 uuid wsock32 + oleaut32 ; diff --git a/reactos/subsys/system/explorer/Makefile b/reactos/subsys/system/explorer/Makefile index 990cf3a35e1..556fece2251 100644 --- a/reactos/subsys/system/explorer/Makefile +++ b/reactos/subsys/system/explorer/Makefile @@ -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 diff --git a/reactos/subsys/system/explorer/Makefile.MinGW b/reactos/subsys/system/explorer/Makefile.MinGW index 5d35b4edc43..02753e85d55 100644 --- a/reactos/subsys/system/explorer/Makefile.MinGW +++ b/reactos/subsys/system/explorer/Makefile.MinGW @@ -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) diff --git a/reactos/subsys/system/explorer/Makefile.Wine b/reactos/subsys/system/explorer/Makefile.Wine index f84158f92aa..1b484f0816e 100644 --- a/reactos/subsys/system/explorer/Makefile.Wine +++ b/reactos/subsys/system/explorer/Makefile.Wine @@ -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 \ diff --git a/reactos/subsys/system/explorer/dialogs/settings.cpp b/reactos/subsys/system/explorer/dialogs/settings.cpp index 39d6d86a40f..b4d3a3c338a 100644 --- a/reactos/subsys/system/explorer/dialogs/settings.cpp +++ b/reactos/subsys/system/explorer/dialogs/settings.cpp @@ -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 diff --git a/reactos/subsys/system/explorer/dialogs/settings.h b/reactos/subsys/system/explorer/dialogs/settings.h index 73480fc976a..a95ba887b37 100644 --- a/reactos/subsys/system/explorer/dialogs/settings.h +++ b/reactos/subsys/system/explorer/dialogs/settings.h @@ -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 diff --git a/reactos/subsys/system/explorer/doc/changes.txt b/reactos/subsys/system/explorer/doc/changes.txt index c8573e4a55d..07635553a04 100644 --- a/reactos/subsys/system/explorer/doc/changes.txt +++ b/reactos/subsys/system/explorer/doc/changes.txt @@ -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 diff --git a/reactos/subsys/system/explorer/doxy-footer.html b/reactos/subsys/system/explorer/doxy-footer.html index 4adc2b59dc0..c0e4d311677 100644 --- a/reactos/subsys/system/explorer/doxy-footer.html +++ b/reactos/subsys/system/explorer/doxy-footer.html @@ -3,7 +3,7 @@
ROS Explorer Source Code Documentation -
generated on 04.02.2004 by +
generated on 05.02.2004 by
doxygen
diff --git a/reactos/subsys/system/explorer/explorer.cpp b/reactos/subsys/system/explorer/explorer.cpp index 8cce5a40ad9..1f75783c82f 100644 --- a/reactos/subsys/system/explorer/explorer.cpp +++ b/reactos/subsys/system/explorer/explorer.cpp @@ -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; diff --git a/reactos/subsys/system/explorer/explorer.dsp b/reactos/subsys/system/explorer/explorer.dsp index dce316f994b..7f962bda815 100644 --- a/reactos/subsys/system/explorer/explorer.dsp +++ b/reactos/subsys/system/explorer/explorer.dsp @@ -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 diff --git a/reactos/subsys/system/explorer/explorer.h b/reactos/subsys/system/explorer/explorer.h index 8370d489e75..6148f265787 100644 --- a/reactos/subsys/system/explorer/explorer.h +++ b/reactos/subsys/system/explorer/explorer.h @@ -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" diff --git a/reactos/subsys/system/explorer/explorer_intres.h b/reactos/subsys/system/explorer/explorer_intres.h index 29091647f44..a3b9a289873 100644 --- a/reactos/subsys/system/explorer/explorer_intres.h +++ b/reactos/subsys/system/explorer/explorer_intres.h @@ -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 diff --git a/reactos/subsys/system/explorer/make_explorer.dsp b/reactos/subsys/system/explorer/make_explorer.dsp index 80883c506b3..07d7f7f4814 100644 --- a/reactos/subsys/system/explorer/make_explorer.dsp +++ b/reactos/subsys/system/explorer/make_explorer.dsp @@ -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" diff --git a/reactos/subsys/system/explorer/shell/entries.h b/reactos/subsys/system/explorer/shell/entries.h index 7050c55828b..92b0457f370 100644 --- a/reactos/subsys/system/explorer/shell/entries.h +++ b/reactos/subsys/system/explorer/shell/entries.h @@ -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 { diff --git a/reactos/subsys/system/explorer/shell/fatfs.cpp b/reactos/subsys/system/explorer/shell/fatfs.cpp index 1dbe4c8bd1b..75d9128b10b 100644 --- a/reactos/subsys/system/explorer/shell/fatfs.cpp +++ b/reactos/subsys/system/explorer/shell/fatfs.cpp @@ -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 diff --git a/reactos/subsys/system/explorer/shell/fatfs.h b/reactos/subsys/system/explorer/shell/fatfs.h index ea9fac60a13..cdc7125fced 100644 --- a/reactos/subsys/system/explorer/shell/fatfs.h +++ b/reactos/subsys/system/explorer/shell/fatfs.h @@ -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 diff --git a/reactos/subsys/system/explorer/shell/filechild.cpp b/reactos/subsys/system/explorer/shell/filechild.cpp index 15a77149052..0d515827a88 100644 --- a/reactos/subsys/system/explorer/shell/filechild.cpp +++ b/reactos/subsys/system/explorer/shell/filechild.cpp @@ -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(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); diff --git a/reactos/subsys/system/explorer/shell/filechild.h b/reactos/subsys/system/explorer/shell/filechild.h index 9375a2340a9..3497b1fb856 100644 --- a/reactos/subsys/system/explorer/shell/filechild.h +++ b/reactos/subsys/system/explorer/shell/filechild.h @@ -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 diff --git a/reactos/subsys/system/explorer/shell/mainframe.cpp b/reactos/subsys/system/explorer/shell/mainframe.cpp index 2a99eb5cb01..41522813717 100644 --- a/reactos/subsys/system/explorer/shell/mainframe.cpp +++ b/reactos/subsys/system/explorer/shell/mainframe.cpp @@ -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 } diff --git a/reactos/subsys/system/explorer/shell/mainframe.h b/reactos/subsys/system/explorer/shell/mainframe.h index f8ef668b5d0..3a58759aa79 100644 --- a/reactos/subsys/system/explorer/shell/mainframe.h +++ b/reactos/subsys/system/explorer/shell/mainframe.h @@ -56,6 +56,8 @@ protected: WindowHandle _hstatusbar; WindowHandle _htoolbar; WindowHandle _hdrivebar; + WindowHandle _haddressedit; + WindowHandle _hcommandedit; HMENU _hMenuFrame; HMENU _hMenuWindow; diff --git a/reactos/subsys/system/explorer/shell/ntobjfs.cpp b/reactos/subsys/system/explorer/shell/ntobjfs.cpp index 5b8336cc54e..ea912af4fa5 100644 --- a/reactos/subsys/system/explorer/shell/ntobjfs.cpp +++ b/reactos/subsys/system/explorer/shell/ntobjfs.cpp @@ -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 diff --git a/reactos/subsys/system/explorer/shell/ntobjfs.h b/reactos/subsys/system/explorer/shell/ntobjfs.h index 833516980ad..99eb051b5a0 100644 --- a/reactos/subsys/system/explorer/shell/ntobjfs.h +++ b/reactos/subsys/system/explorer/shell/ntobjfs.h @@ -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 diff --git a/reactos/subsys/system/explorer/shell/regfs.cpp b/reactos/subsys/system/explorer/shell/regfs.cpp index f54414b53cd..9e55f1772d9 100644 --- a/reactos/subsys/system/explorer/shell/regfs.cpp +++ b/reactos/subsys/system/explorer/shell/regfs.cpp @@ -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 diff --git a/reactos/subsys/system/explorer/shell/regfs.h b/reactos/subsys/system/explorer/shell/regfs.h index 0cafd7d1f24..026e4ddf1b6 100644 --- a/reactos/subsys/system/explorer/shell/regfs.h +++ b/reactos/subsys/system/explorer/shell/regfs.h @@ -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 diff --git a/reactos/subsys/system/explorer/shell/webchild.cpp b/reactos/subsys/system/explorer/shell/webchild.cpp new file mode 100644 index 00000000000..4abe70db7ec --- /dev/null +++ b/reactos/subsys/system/explorer/shell/webchild.cpp @@ -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 + + +Variant::Variant(const VARIANT& var) +{ + VariantInit(this); + CheckError(VariantCopy(this, const_cast(&var))); +} + +Variant::Variant(const VARIANT* var) +{ + VariantInit(this); + CheckError(VariantCopy(this, const_cast(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(&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 pStream; + HRESULT hr = CreateStreamOnHGlobal(hHtmlText, TRUE, &pStream); + + if (SUCCEEDED(hr)) { + SIfacePtr pHtmlDoc; + CheckError(_browser->get_Document(&pHtmlDoc)); + + SIfacePtr 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 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; +} diff --git a/reactos/subsys/system/explorer/shell/webchild.h b/reactos/subsys/system/explorer/shell/webchild.h new file mode 100644 index 00000000000..e33ff7fff5e --- /dev/null +++ b/reactos/subsys/system/explorer/shell/webchild.h @@ -0,0 +1,1361 @@ +/* + * 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.h + // + // Martin Fuchs, 08.02.2004 + // + + +#ifndef _MSC_VER +#include // for IConnectionPointContainer +#include // for DWebBrowserEvents IDs +#endif + +#ifndef DISPID_BEFORENAVIGATE // missing in MinGW (as of 07.02.2004) +#define DISPID_BEFORENAVIGATE 100 +#define DISPID_NAVIGATECOMPLETE 101 +#define DISPID_STATUSTEXTCHANGE 102 +#define DISPID_QUIT 103 +#define DISPID_DOWNLOADCOMPLETE 104 +#define DISPID_COMMANDSTATECHANGE 105 +#define DISPID_DOWNLOADBEGIN 106 +#define DISPID_NEWWINDOW 107 +#define DISPID_PROGRESSCHANGE 108 +#define DISPID_WINDOWMOVE 109 +#define DISPID_WINDOWRESIZE 110 +#define DISPID_WINDOWACTIVATE 111 +#define DISPID_PROPERTYCHANGE 112 +#define DISPID_TITLECHANGE 113 +#define DISPID_TITLEICONCHANGE 114 +#define DISPID_FRAMEBEFORENAVIGATE 200 +#define DISPID_FRAMENAVIGATECOMPLETE 201 +#define DISPID_FRAMENEWWINDOW 204 + +#define DISPID_NAVIGATECOMPLETE2 252 +#define DISPID_ONQUIT 253 +#define DISPID_ONVISIBLE 254 +#define DISPID_ONTOOLBAR 255 +#define DISPID_ONMENUBAR 256 +#define DISPID_ONSTATUSBAR 257 +#define DISPID_ONFULLSCREEN 258 +#define DISPID_DOCUMENTCOMPLETE 259 +#define DISPID_ONTHEATERMODE 260 +#define DISPID_ONADDRESSBAR 261 +#define DISPID_WINDOWSETRESIZABLE 262 +#define DISPID_WINDOWCLOSING 263 +#define DISPID_WINDOWSETLEFT 264 +#define DISPID_WINDOWSETTOP 265 +#define DISPID_WINDOWSETWIDTH 266 +#define DISPID_WINDOWSETHEIGHT 267 +#define DISPID_CLIENTTOHOSTWINDOW 268 +#define DISPID_SETSECURELOCKICON 269 +#define DISPID_FILEDOWNLOAD 270 +#define DISPID_NAVIGATEERROR 271 +#define DISPID_PRIVACYIMPACTEDSTATECHANGE 272 +#endif + +#ifndef V_INT // missing in MinGW (as of 07.02.2004) +#define V_INT(x) V_UNION(x, intVal) +#endif + +#ifdef _MSC_VER +#define NOVTABLE __declspec(novtable) +#else +#define NOVTABLE +#endif +#define ANSUNC + +#ifdef _MSC_VER +#pragma warning(disable: 4355) // use of 'this' for initialization of _connector +#endif + + +struct NOVTABLE ComSrvObject // NOVTABLE erlaubt, da protected Destruktor +{ +protected: + ComSrvObject() : _ref(1) {} + virtual ~ComSrvObject() {} + + ULONG _ref; +}; + +struct SimpleComObject : public ComSrvObject +{ + ULONG IncRef() {return ++_ref;} + ULONG DecRef() {ULONG ref=--_ref; if (!ref) {_ref++; delete this;} return ref;} +}; + + + // server object interfaces + +template struct IComSrvQI : public BASE +{ + IComSrvQI(REFIID uuid_base) + : _uuid_base(uuid_base) + { + } + + STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppv) {*ppv=0; + if (IsEqualIID(riid, _uuid_base) || + IsEqualIID(riid, IID_IUnknown)) {*ppv=static_cast(this); AddRef(); return S_OK;} + return E_NOINTERFACE;} + +protected: + IComSrvQI() {} + + REFIID _uuid_base; +}; + +template<> struct IComSrvQI : public IUnknown +{ + STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppv) {*ppv=0; + if (IsEqualIID(riid, IID_IUnknown)) {*ppv=this; AddRef(); return S_OK;} + return E_NOINTERFACE;} + +protected: + IComSrvQI() {} +}; + + +template + class IComSrvBase : public IComSrvQI +{ + typedef IComSrvQI super; + +protected: + IComSrvBase(REFIID uuid_base) + : super(uuid_base) + { + } + +public: + STDMETHODIMP_(ULONG) AddRef() {return static_cast(this)->IncRef();} + STDMETHODIMP_(ULONG) Release() {return static_cast(this)->DecRef();} +}; + + +template struct ConnectionPoint : public SIfacePtr +{ + ConnectionPoint(IConnectionPointContainer* pCPC, REFIID riid) + { + CheckError(pCPC->FindConnectionPoint(riid, &_p)); + } +}; + +struct EventConnection +{ + EventConnection(IConnectionPoint* connectionpoint, IUnknown* sink) + { + CheckError(connectionpoint->Advise(sink, &_cookie)); + _connectionpoint = connectionpoint; + } + + template EventConnection(T& connectionpoint, IUnknown* sink) + { + CheckError(connectionpoint->Advise(sink, &_cookie)); + _connectionpoint = connectionpoint; + } + +/* template EventConnection(SIfacePtr& connectionpoint, IUnknown* sink) + { + CheckError(connectionpoint->Advise(sink, &_cookie)); + _connectionpoint = connectionpoint.GetPtr(); + } */ + +/* template EventConnection(T& connectionpoint, IUnknown* sink) + { + CheckError(connectionpoint->Advise(sink, &_cookie)); + _connectionpoint = connectionpoint; + } */ + + ~EventConnection() + { + if (_connectionpoint) + _connectionpoint->Unadvise(_cookie); + } + +protected: + SIfacePtr _connectionpoint; + DWORD _cookie; +}; + +struct EventConnector : public EventConnection +{ + EventConnector(IUnknown* unknown, REFIID riid, IUnknown* sink) + : EventConnection(ConnectionPoint( + SIfacePtr(unknown, IID_IConnectionPointContainer), riid), sink) + { + } +}; + + +struct OleInPlaceClient : public SimpleComObject, + public IOleClientSite, + public IOleInPlaceSite +{ +protected: + HWND _hwnd; + +public: + OleInPlaceClient(HWND hwnd=0) + : _hwnd(hwnd) + { + } + + void attach(HWND hwnd) + { + _hwnd = hwnd; + } + + HRESULT attach_control(IOleObject* ole_obj, LONG iVerb=OLEIVERB_INPLACEACTIVATE, HWND hwndParent=0, LPCRECT pRect=NULL) + { + HRESULT hr = ole_obj->SetClientSite(this); + if (FAILED(hr)) + return hr; + +// hr = ole_obj->SetHostNames(app, doc)); + + hr = ole_obj->DoVerb(iVerb, NULL, this, 0, 0/*hwnd*/, NULL/*&rcPos*/); + + return hr; + } + + HRESULT detach(IOleObject* ole_obj, DWORD dwSaveOption=OLECLOSE_SAVEIFDIRTY) + { + HRESULT hr = ole_obj->Close(dwSaveOption); + + _hwnd = 0; + + return hr; + } + + STDMETHODIMP QueryInterface(REFIID riid, LPVOID* ppv) + { + if (IsEqualIID(riid, IID_IOleClientSite)) + {*ppv=static_cast(this); IncRef(); return S_OK;} + + if (IsEqualIID(riid, IID_IOleInPlaceSite)) + {*ppv=static_cast(this); IncRef(); return S_OK;} + + if (IsEqualIID(riid, IID_IUnknown)) + {*ppv=static_cast(this); IncRef(); return S_OK;} + + return E_NOINTERFACE; + } + + STDMETHODIMP_(ULONG) AddRef() {return IncRef();} + STDMETHODIMP_(ULONG) Release() {return DecRef();} + + + // IOleWindow: + + virtual /* [input_sync] */ HRESULT STDMETHODCALLTYPE GetWindow(/* [out] */ HWND __RPC_FAR *phwnd) + { + *phwnd = _hwnd; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(/* [in] */ BOOL fEnterMode) + { + return E_NOTIMPL; + } + + + // IOleClientSite: + + virtual HRESULT STDMETHODCALLTYPE SaveObject() + { + return E_NOTIMPL; + } + + virtual HRESULT STDMETHODCALLTYPE GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker __RPC_FAR *__RPC_FAR *ppmk) + { + return E_NOTIMPL; + } + + virtual HRESULT STDMETHODCALLTYPE GetContainer(IOleContainer __RPC_FAR *__RPC_FAR *ppContainer) + { + ppContainer = 0; + return E_NOINTERFACE; + } + + virtual HRESULT STDMETHODCALLTYPE ShowObject() + { + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE OnShowWindow(BOOL fShow) + { + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE RequestNewObjectLayout() + { + return S_OK; + } + + + // IOleInPlaceSite: + + virtual HRESULT STDMETHODCALLTYPE CanInPlaceActivate() + { + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE OnInPlaceActivate() + { + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE OnUIActivate() + { + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE GetWindowContext( + /* [out] */ IOleInPlaceFrame __RPC_FAR *__RPC_FAR *ppFrame, + /* [out] */ IOleInPlaceUIWindow __RPC_FAR *__RPC_FAR *ppDoc, + /* [out] */ LPRECT lprcPosRect, + /* [out] */ LPRECT lprcClipRect, + /* [out][in] */ LPOLEINPLACEFRAMEINFO lpFrameInfo) + { + ClientRect rect(_hwnd); + + ppFrame = 0; + ppDoc = 0; + *lprcPosRect = rect; + *lprcClipRect = rect; + + assert(lpFrameInfo->cb>=sizeof(OLEINPLACEFRAMEINFO)); + lpFrameInfo->fMDIApp = FALSE; + lpFrameInfo->hwndFrame = 0; + lpFrameInfo->haccel = 0; + lpFrameInfo->cAccelEntries = 0; + + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE Scroll(/* [in] */ SIZE scrollExtant) + { + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE OnUIDeactivate(/* [in] */ BOOL fUndoable) + { + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE OnInPlaceDeactivate() + { + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE DiscardUndoState() + { + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE DeactivateAndUndo() + { + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE OnPosRectChange(/* [in] */ LPCRECT lprcPosRect) + { + return S_OK; + } +}; + + + // window with in place activates Active-X Control + +template struct IPCtrlWindow : public BASE +{ + typedef BASE super; + + IPCtrlWindow(HWND hwnd) + : super(hwnd) + { + } + + HRESULT create_control(HWND hwnd, REFIID clsid, REFIID riid) + { + // Erzeugen einer Instanz des Controls + HRESULT hr = _control.CreateInstance(clsid, riid); + if (FAILED(hr)) + return hr; + + _client_side.attach(hwnd); + + hr = _client_side.attach_control(SIfacePtr(_control, IID_IOleObject)/*, OLEIVERB_INPLACEACTIVATE, + hwnd, &Rect(10, 10, 500, 500)*/); + if (FAILED(hr)) + return hr; + + // try to get a IOleInPlaceObject interface for window resizing + return _control.QueryInterface(IID_IOleInPlaceObject, &_in_place_object); // _in_place_object = _control + } + +protected: + LRESULT WndProc(UINT message, WPARAM wparam, LPARAM lparam) + { + if (message == WM_SIZE) { + if (_in_place_object) { + RECT rect = {0, 0, LOWORD(lparam), HIWORD(lparam)}; + + _in_place_object->SetObjectRects(&rect, &rect); + } + } else if (message == WM_CLOSE) { + _in_place_object = NULL; + _client_side.detach(SIfacePtr(_control, IID_IOleObject), OLECLOSE_NOSAVE); + _control = NULL; + } + + return super::WndProc(message, wparam, lparam); + } + + ComInit _usingCOM; + SMARTPTR _control; + OleInPlaceClient _client_side; + SIfacePtr _in_place_object; +}; + + + +#include "exdispid.h" + + +struct DWebBrowserEventsIF +{ + virtual HRESULT BeforeNavigate(const String& url, long flags, const String& targetFrameName, VARIANT* postData, const String& headers, VARIANT_BOOL* cancel) + {return S_OK;} + + virtual HRESULT NavigateComplete(const String& url) + {return S_OK;} + + virtual HRESULT StatusTextChange(const String& text) + {return S_OK;} + + virtual HRESULT ProgressChange(long Progress, long progressMax) + {return S_OK;} + + virtual HRESULT DownloadComplete() + {return S_OK;} + + virtual HRESULT CommandStateChange(long command/*CSC_NAVIGATEFORWARD, CSC_NAVIGATEBACK*/, VARIANT_BOOL enable) + {return S_OK;} + + virtual HRESULT DownloadBegin() + {return S_OK;} + + virtual HRESULT NewWindow(const String& url, long flags, const String& targetFrameName, VARIANT* postData, const String& headers, VARIANT_BOOL* processed) + {return S_OK;} + + virtual HRESULT TitleChange(const String& text) + {return S_OK;} + + virtual HRESULT TitleIconChange(const String& text) + {return S_OK;} + + virtual HRESULT FrameBeforeNavigate(const String& url, long flags, const String& targetFrameName, VARIANT* postData, const String& headers, VARIANT_BOOL* cancel) + {return S_OK;} + + virtual HRESULT FrameNavigateComplete(const String& url) + {return S_OK;} + + virtual HRESULT FrameNewWindow(const String& url, long flags, const String& targetFrameName, VARIANT* postData, const String& headers, VARIANT_BOOL* processed) + {return S_OK;} + + virtual HRESULT Quit(VARIANT_BOOL* cancel) + {return S_OK;} + + virtual HRESULT WindowMove() + {return S_OK;} + + virtual HRESULT WindowResize() + {return S_OK;} + + virtual HRESULT WindowActivate() + {return S_OK;} + + virtual HRESULT PropertyChange(const BStr& property) + {return S_OK;} +}; + + +#ifndef __DWebBrowserEvents_DISPINTERFACE_DEFINED__ // missing in MinGW (as of 07.02.2004) +interface DWebBrowserEvents : public IDispatch +{ +}; +#endif + + +struct ANSUNC DWebBrowserEventsImpl : public SimpleComObject, + public IComSrvBase, + public DWebBrowserEventsIF +{ + typedef IComSrvBase super; + + + DWebBrowserEventsIF* _callback; + + + DWebBrowserEventsImpl() + : super(DIID_DWebBrowserEvents) + { + _callback = this; + } + +/* // IUnknown + STDMETHOD(QueryInterface)(REFIID riid, LPVOID* ppv) + { + *ppv = NULL; + + if (SUCCEEDED(super::QueryInterface(riid, ppv))) + return S_OK; + + return E_NOINTERFACE; + } */ + + + // IDispatch + STDMETHOD(GetTypeInfoCount)(UINT* pctinfo) + {return E_NOTIMPL;} + + STDMETHOD(GetTypeInfo)(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo) + {return E_NOTIMPL;} + + STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId) + {return E_NOTIMPL;} + + STDMETHOD(Invoke)(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, + DISPPARAMS __RPC_FAR *pDispParams, VARIANT __RPC_FAR *pVarResult, EXCEPINFO __RPC_FAR *pExcepInfo, UINT __RPC_FAR *puArgErr) + { + switch(dispIdMember) { + case DISPID_BEFORENAVIGATE: { + if (pDispParams->cArgs != 6) + return E_INVALIDARG; + + BSTR s5 = V_BSTR(&pDispParams->rgvarg[5]); + BSTR s3 = V_BSTR(&pDispParams->rgvarg[3]); // Mozilla's Active X control gives us NULL in bstrVal. + BSTR s1 = V_BSTR(&pDispParams->rgvarg[1]); + + return _callback->BeforeNavigate(s5? s5: L"", V_I4(&pDispParams->rgvarg[4]), + s3? s3: L"", &pDispParams->rgvarg[2], + s1? s1: L"", V_BOOLREF(&pDispParams->rgvarg[0]));} + + case DISPID_NAVIGATECOMPLETE: // in async, this is sent when we have enough to show + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + return _callback->NavigateComplete(V_BSTR(&pDispParams->rgvarg[0])); + + case DISPID_STATUSTEXTCHANGE: + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + return _callback->StatusTextChange(V_BSTR(&pDispParams->rgvarg[0])); + + case DISPID_QUIT: + return _callback->Quit(NULL); + + case DISPID_DOWNLOADCOMPLETE: + return _callback->DownloadComplete(); + + case DISPID_COMMANDSTATECHANGE: + if (pDispParams->cArgs != 2) + return E_INVALIDARG; + return _callback->CommandStateChange(V_I4(&pDispParams->rgvarg[1]), pDispParams->rgvarg[0].boolVal); + + case DISPID_DOWNLOADBEGIN: + return _callback->DownloadBegin(); + + case DISPID_NEWWINDOW: // sent when a new window should be created + if (pDispParams->cArgs != 6) + return E_INVALIDARG; + return _callback->NewWindow(V_BSTR(&pDispParams->rgvarg[5]), V_I4(&pDispParams->rgvarg[4]), + V_BSTR(&pDispParams->rgvarg[3]), &pDispParams->rgvarg[2], + V_BSTR(&pDispParams->rgvarg[1]), V_BOOLREF(&pDispParams->rgvarg[0])); + + case DISPID_PROGRESSCHANGE: // sent when download progress is updated + if (pDispParams->cArgs != 2) + return E_INVALIDARG; + return _callback->ProgressChange(V_I4(&pDispParams->rgvarg[1]), V_I4(&pDispParams->rgvarg[0])); + + case DISPID_WINDOWMOVE: // sent when main window has been moved + return _callback->WindowMove(); + + case DISPID_WINDOWRESIZE: // sent when main window has been sized + return _callback->WindowResize(); + + case DISPID_WINDOWACTIVATE: // sent when main window has been activated + return _callback->WindowActivate(); + + case DISPID_PROPERTYCHANGE: // sent when the PutProperty method is called + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + return _callback->PropertyChange(V_BSTR(&pDispParams->rgvarg[0])); + + case DISPID_TITLECHANGE: // sent when the document title changes + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + return _callback->TitleChange(V_BSTR(&pDispParams->rgvarg[0])); + + case DISPID_TITLEICONCHANGE: // sent when the top level window icon may have changed. + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + return _callback->TitleIconChange(V_BSTR(&pDispParams->rgvarg[0])); + + default: + return NOERROR; + } + } +}; + + +struct DWebBrowserEvents2IF +{ + virtual void StatusTextChange(const BStr& text) + {} + + virtual void ProgressChange(long progress, long progressMax) + {} + + virtual void WindowMove() + {} + + virtual void WindowResize() + {} + + virtual void WindowActivate() + {} + + virtual void PropertyChange(const BStr& property) + {} + + virtual void DownloadComplete() + {} + + virtual void CommandStateChange(long command, bool enable) + {} + + virtual void DownloadBegin() + {} + + virtual void NewWindow2(IDispatch** ppDisp, VARIANT_BOOL& cancel) + {} + + virtual void TitleChange(const BStr& text) + {} + + virtual void TitleIconChange(const BStr& text) + {} + + virtual void FrameBeforeNavigate(const BStr& url, long flags, const BStr& targetFrameName, VARIANT* postData, const BStr& headers, VARIANT_BOOL& cancel) + {} + + virtual void FrameNavigateComplete(const BStr& url) + {} + + virtual void FrameNewWindow(const BStr&url, long flags, const BStr& targetFrameName, VARIANT* postData, const BStr& headers, VARIANT_BOOL& processed) + {} + + virtual void BeforeNavigate2(IDispatch* pDisp, const Variant& url, const Variant& flags, + const Variant& targetFrameName, const Variant& postData, + const Variant& headers, VARIANT_BOOL& cancel) + {} + + virtual void NavigateComplete2(IDispatch* pDisp, const Variant& url) + {} + + virtual void OnQuit() + {} + + virtual void OnVisible(bool Visible) + {} + + virtual void OnToolbar(bool Visible) + {} + + virtual void OnMenubar(bool Visible) + {} + + virtual void OnStatusbar(bool Visible) + {} + + virtual void OnFullscreen(bool Visible) + {} + + virtual void DocumentComplete() + {} + + virtual void OnTheatermode(bool Visible) + {} + + virtual void OnAddressbar(bool Visible) + {} + + virtual void WindowSetResizable(bool Visible) + {} + + virtual void WindowClosing(VARIANT_BOOL IsChildWindow, VARIANT_BOOL& cancel) + {} + + virtual void WindowSetLeft(long Left) + {} + + virtual void WindowSetTop(long Top) + {} + + virtual void WindowSetWidth(long Width) + {} + + virtual void WindowSetHeight(long Height) + {} + + virtual void ClientToHostWindow(long& CX, long& CY) + {} + + virtual void SetSecureLockIcon(long SecureLockIcon) + {} + + virtual void FileDownload(Variant& cancel) + {} + + virtual void NavigateError(IDispatch* pDisp, const Variant& url, const Variant& Frame, const Variant& StatusCode, VARIANT_BOOL& cancel) + {} + + virtual void PrivacyImpactedStateChange(bool bImpacted) + {} +}; + + + // Das Webbrowser-Control muß zunächst komplett initialisiert sein, bevor eine Seite, + // die nicht auf das Internet zugreift (z.B. addcom/./index.html) dargestellt werden kann. +struct ANSUNC BrowserNavigator +{ + BrowserNavigator(IWebBrowser* browser); + + void goto_url(LPCTSTR url); + void set_html_page(const String& html_txt); + void navigated(LPCTSTR url); + +protected: + SIfacePtr _browser; + String _new_url; + String _new_html_txt; + bool _browser_initialized; +}; + + + // MinGW defines a wrong FixedDWebBrowserEvents2 interface with virtual functions for DISPID calls, so we use our own, corrected version: +interface FixedDWebBrowserEvents2 : public IDispatch +{ +}; + +struct ANSUNC DWebBrowserEvents2Impl : public SimpleComObject, + public IComSrvBase, + public DWebBrowserEvents2IF +{ + typedef IComSrvBase super; + + + DWebBrowserEvents2IF* _callback; + + + DWebBrowserEvents2Impl(BrowserNavigator& navigator) + : super(DIID_DWebBrowserEvents2), + _navigator(navigator) + { + _callback = this; + } + + +/* // IUnknown + STDMETHOD(QueryInterface)(REFIID riid, LPVOID* ppv) + { + *ppv = NULL; + + if (SUCCEEDED(super::QueryInterface(riid, ppv))) + return S_OK; + + return E_NOINTERFACE; + } */ + + + // IDispatch + STDMETHOD(GetTypeInfoCount)(UINT* pctinfo) + {return E_NOTIMPL;} + + STDMETHOD(GetTypeInfo)(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo) + {return E_NOTIMPL;} + + STDMETHOD(GetIDsOfNames)(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId) + {return E_NOTIMPL;} + + STDMETHOD(Invoke)(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, + DISPPARAMS __RPC_FAR *pDispParams, VARIANT __RPC_FAR *pVarResult, EXCEPINFO __RPC_FAR *pExcepInfo, UINT __RPC_FAR *puArgErr) + { + switch(dispIdMember) { + case DISPID_STATUSTEXTCHANGE: + _callback->StatusTextChange((BStr)Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_COMMANDSTATECHANGE: + _callback->CommandStateChange(Variant(pDispParams->rgvarg[1]), Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_DOWNLOADBEGIN: + _callback->DownloadBegin(); + break; + + case DISPID_PROGRESSCHANGE: // sent when download progress is updated + _callback->ProgressChange(Variant(pDispParams->rgvarg[1]), Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_WINDOWMOVE: // sent when main window has been moved + _callback->WindowMove(); + break; + + case DISPID_WINDOWRESIZE: // sent when main window has been sized + _callback->WindowResize(); + break; + + case DISPID_WINDOWACTIVATE: // sent when main window has been activated + _callback->WindowActivate(); + break; + + case DISPID_PROPERTYCHANGE: // sent when the PutProperty method is called + _callback->PropertyChange((BStr)Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_TITLECHANGE: // sent when the document title changes + _callback->TitleChange((BStr)Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_TITLEICONCHANGE: // sent when the top level window icon may have changed. + _callback->TitleIconChange((BStr)Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_FRAMEBEFORENAVIGATE: + if (pDispParams->cArgs != 6) + return E_INVALIDARG; + if (V_VT(&pDispParams->rgvarg[0]) != (VT_BOOL|VT_BYREF)) + return E_INVALIDARG; + _callback->FrameBeforeNavigate( + (BStr)Variant(&pDispParams->rgvarg[5]), Variant(&pDispParams->rgvarg[4]), + (BStr)Variant(&pDispParams->rgvarg[3]), &pDispParams->rgvarg[2], + (BStr)Variant(&pDispParams->rgvarg[1]), *V_BOOLREF(&pDispParams->rgvarg[0])); + break; + + case DISPID_FRAMENAVIGATECOMPLETE: + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + _callback->FrameNavigateComplete((BStr)Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_FRAMENEWWINDOW: + if (pDispParams->cArgs != 6) + return E_INVALIDARG; + if (V_VT(&pDispParams->rgvarg[0]) != (VT_BOOL|VT_BYREF)) + return E_INVALIDARG; + _callback->FrameNewWindow((BStr)Variant(&pDispParams->rgvarg[5]), Variant(&pDispParams->rgvarg[4]), + (BStr)Variant(&pDispParams->rgvarg[3]), &pDispParams->rgvarg[2], + (BStr)Variant(&pDispParams->rgvarg[1]), *V_BOOLREF(&pDispParams->rgvarg[0])); + break; + + case DISPID_BEFORENAVIGATE2: // hyperlink clicked on + if (pDispParams->cArgs != 7) + return E_INVALIDARG; + if (V_VT(&pDispParams->rgvarg[0]) != (VT_BOOL|VT_BYREF)) + return E_INVALIDARG; + _callback->BeforeNavigate2(Variant(pDispParams->rgvarg[6]), + pDispParams->rgvarg[5], &pDispParams->rgvarg[4], + pDispParams->rgvarg[3], &pDispParams->rgvarg[2], + pDispParams->rgvarg[1], *V_BOOLREF(&pDispParams->rgvarg[0])); + break; + + case DISPID_NEWWINDOW2: // sent when a new window should be created + if (pDispParams->cArgs != 2) + return E_INVALIDARG; + if (V_VT(&pDispParams->rgvarg[0]) != (VT_BOOL|VT_BYREF)) + return E_INVALIDARG; + if (V_VT(&pDispParams->rgvarg[1]) != (VT_DISPATCH|VT_BYREF)) + return E_INVALIDARG; + _callback->NewWindow2(V_DISPATCHREF(&pDispParams->rgvarg[1]), *V_BOOLREF(&pDispParams->rgvarg[0])); + break; + + case DISPID_NAVIGATECOMPLETE2:// UIActivate new document + if (pDispParams->cArgs != 2) + return E_INVALIDARG; + + // notify the navigator + NavigateComplete2(Variant(pDispParams->rgvarg[1]), Variant(pDispParams->rgvarg[0])); + + _callback->NavigateComplete2(Variant(pDispParams->rgvarg[1]), Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_ONQUIT: + _callback->OnQuit(); + break; + + case DISPID_ONVISIBLE: // sent when the window goes visible/hidden + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + _callback->OnVisible(Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_ONTOOLBAR: // sent when the toolbar should be shown/hidden + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + _callback->OnToolbar(Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_ONMENUBAR: // sent when the menubar should be shown/hidden + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + _callback->OnMenubar(Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_ONSTATUSBAR: // sent when the statusbar should be shown/hidden + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + _callback->OnStatusbar(Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_ONFULLSCREEN: // sent when kiosk mode should be on/off + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + _callback->OnFullscreen(Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_DOCUMENTCOMPLETE:// new document goes ReadyState_Complete + _callback->DocumentComplete(); + break; + + case DISPID_DOWNLOADCOMPLETE: + _callback->DownloadComplete(); + break; + + case DISPID_ONTHEATERMODE: // sent when theater mode should be on/off + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + _callback->OnTheatermode(Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_ONADDRESSBAR: // sent when the address bar should be shown/hidden + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + _callback->OnAddressbar(Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_WINDOWSETRESIZABLE:// sent to set the style of the host window frame + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + _callback->WindowSetResizable(Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_WINDOWCLOSING: // sent before script window.close closes the window + if (pDispParams->cArgs != 2) + return E_INVALIDARG; + if (V_VT(&pDispParams->rgvarg[0]) != (VT_BOOL|VT_BYREF)) + return E_INVALIDARG; + _callback->WindowClosing(Variant(pDispParams->rgvarg[1]), *V_BOOLREF(&pDispParams->rgvarg[0])); + break; + + case DISPID_WINDOWSETLEFT: // sent when the put_left method is called on the WebOC + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + _callback->WindowSetLeft(Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_WINDOWSETTOP: // sent when the put_top method is called on the WebOC + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + _callback->WindowSetTop(Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_WINDOWSETWIDTH: // sent when the put_width method is called on the WebOC + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + _callback->WindowSetWidth(Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_WINDOWSETHEIGHT: // sent when the put_height method is called on the WebOC + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + _callback->WindowSetHeight(Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_CLIENTTOHOSTWINDOW:// sent during window.open to request conversion of dimensions + if (pDispParams->cArgs != 2) + return E_INVALIDARG; + if (V_VT(&pDispParams->rgvarg[0]) != (VT_I4|VT_BYREF)) + return E_INVALIDARG; + if (V_VT(&pDispParams->rgvarg[1]) != (VT_I4|VT_BYREF)) + return E_INVALIDARG; + _callback->ClientToHostWindow(*V_I4REF(&pDispParams->rgvarg[1]), *V_I4REF(&pDispParams->rgvarg[0])); + break; + + case DISPID_SETSECURELOCKICON:// sent to suggest the appropriate security icon to show + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + _callback->SetSecureLockIcon(Variant(pDispParams->rgvarg[0])); + break; + + case DISPID_FILEDOWNLOAD: { // Fired to indicate the File Download dialog is opening + if (pDispParams->cArgs != 1) //@@ every time 2 ?! + return E_INVALIDARG; + Variant var(pDispParams->rgvarg[0]); + _callback->FileDownload(var);} + break; + + case DISPID_NAVIGATEERROR: // Fired to indicate the a binding error has occured + if (pDispParams->cArgs != 5) + return E_INVALIDARG; + if (V_VT(&pDispParams->rgvarg[0]) != (VT_BOOL|VT_BYREF)) + return E_INVALIDARG; + _callback->NavigateError(Variant(pDispParams->rgvarg[4]), Variant(pDispParams->rgvarg[3]), + Variant(pDispParams->rgvarg[2]), Variant(pDispParams->rgvarg[1]), + *V_BOOLREF(&pDispParams->rgvarg[0])); + break; + + case DISPID_PRIVACYIMPACTEDSTATECHANGE:// Fired when the user's browsing experience is impacted + if (pDispParams->cArgs != 1) + return E_INVALIDARG; + _callback->PrivacyImpactedStateChange(Variant(pDispParams->rgvarg[0])); + break; + + default: + return NOERROR; + } + + return S_OK; + } + +protected: + BrowserNavigator& _navigator; + + void NavigateComplete2(IDispatch* pDisp, const Variant& url) + { + String adr = (BStr)url; + + _navigator.navigated(adr); + } +}; + + +struct DWebBrowserEventsHandler : public DWebBrowserEventsImpl +{ + DWebBrowserEventsHandler(HWND hwnd, IWebBrowser* browser) + : _hwnd(hwnd), + _browser(browser, IID_IWebBrowser2), + _connector(browser, DIID_DWebBrowserEvents, this) + { + } + +protected: + HRESULT BeforeNavigate(const String& url, long flags, const String& targetFrameName, VARIANT* postData, const String& headers, VARIANT_BOOL* cancel) + { + return S_OK; + } + + HRESULT NavigateComplete(const String& url) + {return S_OK;} + + HRESULT StatusTextChange(const String& text) + { + _status = text; + SetWindowText(_hwnd, FmtString(_T("%#s - %#s"), _title.c_str(), _status.c_str())); + return S_OK; + } + + HRESULT ProgressChange(long Progress, long ProgressMax) + {return S_OK;} + + HRESULT CommandStateChange(long command, VARIANT_BOOL enable) + {return S_OK;} + + HRESULT DownloadComplete() + {return S_OK;} + + HRESULT DownloadBegin() + {return S_OK;} + + HRESULT NewWindow(const String& url, long flags, const String& targetFrameName, VARIANT* postData, const String& headers, VARIANT_BOOL* processed) + {return S_OK;} + + HRESULT TitleChange(const String& text) + { + _title = text; + SetWindowText(_hwnd, FmtString(_T("%#s - %#s"), _title.c_str(), _status.c_str())); + return S_OK; + } + + HRESULT TitleIconChange(const String& text) + {return S_OK;} + + HRESULT FrameBeforeNavigate(const String& url, long flags, const String& targetFrameName, VARIANT* postData, const String& headers, VARIANT_BOOL* cancel) + {return S_OK;} + + HRESULT FrameNavigateComplete(const String& url) + {return S_OK;} + + HRESULT FrameNewWindow(const String& url, long flags, const String& targetFrameName, VARIANT* postData, const String& headers, VARIANT_BOOL* processed) + {return S_OK;} + + HRESULT Quit(VARIANT_BOOL* cancel) + {return S_OK;} + + HRESULT WindowMove() + {return S_OK;} + + HRESULT WindowResize() + {return S_OK;} + + HRESULT WindowActivate() + {return S_OK;} + + HRESULT PropertyChange(const BStr& property) + { + Variant value; + _browser->GetProperty(property, &value); + return S_OK; + } + +protected: + HWND _hwnd; + String _title, _status; + SIfacePtr _browser; + EventConnector _connector; +}; + + + // Eventhandler using DWebBrowserEvents2Impl + +struct DWebBrowserEvents2Handler : public DWebBrowserEvents2Impl +{ + typedef DWebBrowserEvents2Impl super; + + DWebBrowserEvents2Handler(HWND hwnd, IWebBrowser* browser) + : _hwnd(hwnd), + _navigator(browser), + DWebBrowserEvents2Impl(_navigator), + _browser(browser, IID_IWebBrowser2), + _connector(browser, DIID_DWebBrowserEvents2, this) + { + } + +protected: + void BeforeNavigate2(IDispatch* pDisp, const Variant& url, const Variant& flags, + const Variant& targetFrameName, const Variant& postData, + const Variant& headers, VARIANT_BOOL& cancel) + { + //String adr = (BStr)url; + } + + void NavigateComplete2(IDispatch* pDisp, const Variant& url) + { + //String adr = (BStr)url; + super::NavigateComplete2(pDisp, url); + } + + void StatusTextChange(const BStr& text) + { + _status = text; + SetWindowText(_hwnd, FmtString(_T("%#s - %#s"), _title.c_str(), _status.c_str())); + } + + void ProgressChange(long Progress, long ProgressMax) + { + } + + void WindowMove() + { + } + + void WindowResize() + { + } + + void WindowActivate() + { + } + + void PropertyChange(const BStr& Property) + { + Variant value; + _browser->GetProperty(Property, &value); + } + + void CommandStateChange(long command/*CSC_NAVIGATEFORWARD, CSC_NAVIGATEBACK*/, bool enable) + { + } + + void DownloadBegin() + { + } + + void NewWindow2(IDispatch** ppDisp, VARIANT_BOOL& cancel) + { + //*ppDisp = ; + //cancel = TRUE; + } + + void TitleChange(const BStr& text) + { + _title = text; + SetWindowText(_hwnd, FmtString(_T("%#s - %#s"), _title.c_str(), _status.c_str())); + } + + void TitleIconChange(const BStr& text) + { + } + + void FrameBeforeNavigate(const BStr& url, long flags, const BStr& targetFrameName, VARIANT* postData, const BStr& headers, VARIANT_BOOL& cancel) + { + } + + void FrameNavigateComplete(const BStr& url) + { + } + + void FrameNewWindow(const BStr& url, long flags, const BStr& targetFrameName, VARIANT* postData, const BStr& headers, VARIANT_BOOL& processed) + { + } + + void OnQuit() + { + } + + void OnVisible(bool Visible) + { + } + + void OnToolbar(bool Visible) + { + } + + void OnMenubar(bool Visible) + { + } + + void OnStatusbar(bool Visible) + { + } + + void OnFullscreen(bool Visible) + { + } + + void DocumentComplete() + { + } + + void OnTheatermode(bool Visible) + { + } + + void OnAddressbar(bool Visible) + { + } + + void WindowSetResizable(bool Visible) + { + } + + void WindowClosing(VARIANT_BOOL IsChildWindow, VARIANT_BOOL& cancel) + { + } + + void WindowSetLeft(long Left) + { + } + + void WindowSetTop(long Top) + { + } + + void WindowSetWidth(long Width) + { + } + + void WindowSetHeight(long Height) + { + } + + void ClientToHostWindow(long& CX, long& CY) + { + } + + void SetSecureLockIcon(long SecureLockIcon) + { + } + + void FileDownload(Variant& cancel) + { + } + + void NavigateError(IDispatch* pDisp, const Variant& url, const Variant& Frame, const Variant& StatusCode, VARIANT_BOOL& cancel) + { + } + + void PrivacyImpactedStateChange(bool bImpacted) + { + } + +protected: + HWND _hwnd; + BrowserNavigator _navigator; + SIfacePtr _browser; + EventConnector _connector; + + String _title, _status; +}; + + + /// encapsulation of Web control in MDI child windows +struct WebChildWindow : public IPCtrlWindow > +{ + typedef IPCtrlWindow > super; + + WebChildWindow(HWND hwnd, const WebChildWndInfo& info); + ~WebChildWindow(); + + static WebChildWindow* create(HWND hmdiclient, const FileChildWndInfo& info) + { + ChildWindow* child = ChildWindow::create(hmdiclient, info._pos.rcNormalPosition, + WINDOW_CREATOR_INFO(WebChildWindow,WebChildWndInfo), CLASSNAME_CHILDWND, NULL, &info); + + ShowWindow(*child, info._pos.showCmd); + + return static_cast(child); + } + + IWebBrowser2* get_browser() + { + return _control; + } + +protected: + DWebBrowserEventsHandler* _evt_demo1; + DWebBrowserEvents2Handler* _evt_demo2; +}; diff --git a/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp b/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp index d8da29eb13c..f9c79fc4021 100644 --- a/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp +++ b/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp @@ -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(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(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; } diff --git a/reactos/subsys/system/explorer/taskbar/quicklaunch.h b/reactos/subsys/system/explorer/taskbar/quicklaunch.h index b9bedf5b1ab..8d93adeddd7 100644 --- a/reactos/subsys/system/explorer/taskbar/quicklaunch.h +++ b/reactos/subsys/system/explorer/taskbar/quicklaunch.h @@ -78,4 +78,5 @@ protected: int _btn_dist; void AddShortcuts(); + void AddButton(HBITMAP hbmp, LPCTSTR name, Entry* entry); }; diff --git a/reactos/subsys/system/explorer/utility/shellclasses.h b/reactos/subsys/system/explorer/utility/shellclasses.h index 00fb302822a..535814be5c8 100644 --- a/reactos/subsys/system/explorer/utility/shellclasses.h +++ b/reactos/subsys/system/explorer/utility/shellclasses.h @@ -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 struct SIfacePtr p->AddRef(); } + SIfacePtr(IUnknown* unknown, REFIID riid) + { + CHECKERROR(unknown->QueryInterface(riid, (LPVOID*)&_p)); + //@@ _p->AddRef(); + } + ~SIfacePtr() { Free(); @@ -360,7 +366,7 @@ template 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 struct SIfacePtr SIfacePtr& operator=(T* p) { Free(); - p->AddRef(); - _p = p; + + if (p) { + p->AddRef(); + _p = p; + } return *this; } @@ -387,6 +396,16 @@ template struct SIfacePtr h->Release(); } + HRESULT CreateInstance(REFIID clsid, REFIID riid) + { + return CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, riid, (LPVOID*)&_p); + } + + template 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 }; -#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 diff --git a/reactos/subsys/system/explorer/utility/utility.h b/reactos/subsys/system/explorer/utility/utility.h index bf317b27a0d..d15087ea70e 100644 --- a/reactos/subsys/system/explorer/utility/utility.h +++ b/reactos/subsys/system/explorer/utility/utility.h @@ -40,6 +40,11 @@ #include // for SelectBrush(), ListBox_SetSel(), SubclassWindow(), ... #include +#ifndef _MSC_VER +#include +#include // for VARIANT +#endif + #include // for alloca() #include #include // 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;} diff --git a/reactos/subsys/system/explorer/utility/window.cpp b/reactos/subsys/system/explorer/utility/window.cpp index 51d903f2b47..efd80d5f6b2 100644 --- a/reactos/subsys/system/explorer/utility/window.cpp +++ b/reactos/subsys/system/explorer/utility/window.cpp @@ -238,7 +238,7 @@ Window* Window::create_controller(HWND hwnd) } -LRESULT Window::Init(LPCREATESTRUCT pcs) +LRESULT Window::Init(LPCREATESTRUCT pcs) { return 0; }